SQL> ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/backup/',+data/jlprojct/datafile/' scope =spfile; #静态参数,不重启,不起作用 ,所以不让重启可以不改它。
System altered.
SQL> ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='+DATA/jlprojct/onlinelog/','/backup/','+ARCH/jlprojct/onlinelog/','/backup/'scope =spfile; #静态参数,不重启,不起作用 ,所以不让重启可以不改它。
System altered.
三 ;修改主库的监听和tnsname.ora 文件
1,主库监听listener.ora文件 添加 (如果有就不修改)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=JLPROJCT)
(ORACLE_HOME=/oracle/product/11.2.3)
(SID_NAME=JLPROJCT1)))
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.15.26)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
2.主库tnsname.ora 添加备库的相关信息。
JLPROJCT3 = #备库的相关信息
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.15.9)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = JLPROJCT3)
(INSTANCE_NAME = JLPROJCT3)
)
)
db26 = #主库相关信息 执行duplicate之前 要rman 同时连接主库和备库,连接主库时,会用到这个连接字符串。
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.15.26)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = JLPROJCT)
四:在主库用scp 把listener.ora ,tnsname.ora ,initJLPROJCT1.ora,pfile.ora 传给备库 然后进行相应的修改(参数文件不需要修改内容,但是要改名 和备库实例名相对应 :[oracle@java3 dbs]$ mv orapwJLPROJCT orapwJLPROJCT3 )
[oracle@rac1 ~]$ scp listener.ora tnsnames.ora initJLPROJCT1.ora oracle@192.168.15.:`pwd`; #冒号后面的pwd 意思是说要把文件传到备库的当前路径下(也就是此时在主机上 pwd 显示的路径)
把监听的信息改成备库的,tnaname.ora添加主库的相关信息。
1.备库监听listener.ora 内容如下:
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=JLPROJCT3)
(ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome_1)
(SID_NAME=JLPROJCT3)))
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.15.9)(PORT = 1521)) #主机IP
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /opt/oracle
2.备库tnsname.ora 内容:
JLPROJCT = #主库相关信息 这里的连接字符串和主库tnsname.ora 里面的不一样,不影响,随便起的名字
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.15.26)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = JLPROJCT)
JLPROJCT3 = #备库的相关信息 如果仅仅是做standby 数据库,不填他自己这个也行。
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.15.9)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = JLPROJCT3)
(INSTANCE_NAME = JLPROJCT3)
)
)
备库参数文件修改 :
DB_NAME=JLPROJCT #因为就一个数据库 所以此处不变
DB_UNIQUE_NAME=JLPROJCT3 #这里要写成了备库数据库唯一名,便于区分主备库,即使转换角色也不改名。
LOG_ARCHIVE_CONFIG='DG_CONFIG=(JLPROJCT3,JLPROJCT)' #括号里面和主库括号里面的前后位置改变。
LOG_ARCHIVE_DEST_1=
'location=/opt/oracle #填上备库有的目录,保证有空闲空间 ,以及有权限读写,
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=JLPROJCT3' #备库名字
LOG_ARCHIVE_DEST_2=
'SERVICE=JLPROJCT ASYNC #主库的名字
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=JLPROJCT' #主库名字
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
FAL_SERVER=JLPROJCT #主库名字
DB_FILE_NAME_CONVERT='+data/jlprojct/datafile/','/backup/' #等号后的两个路径换位置
LOG_FILE_NAME_CONVERT=
'+DATA/jlprojct/onlinelog/','/backup/','+ARCH/jlprojct/onlinelog/','/backup/' #等号后的两个路径换位置