12c RAC下搭建物理备用

基本可以参考11g下的方法:http://blog.itpub.net/22621861/viewspace-1374443/

稍有区别的地方有:
1)静态监听配置

点击(此处)折叠或打开

  1. SID_LIST_LISTENER =
  2.   (SID_LIST =
  3.     (SID_DESC =
  4.       (SID_NAME = jiangsu)
  5.       (ORACLE_HOME = /u01/app/oracle/product/12.1.0/db_1)
  6.       (GLOBAL_DBNAME = jiangsu)
  7.     )
  8.   )
2)Primary若是RAC,密码文件会在ASM里

点击(此处)折叠或打开

  1. $ srvctl config database -db racdb
  2. Database unique name: racdb
  3. Database name: racdb
  4. Oracle home: /u01/app/oracle/product/12.1.0/db_1
  5. Oracle user: oracle
  6. Spfile: +DATA/RACDB/PARAMETERFILE/spfile.272.912277345
  7. Password file: +DATA/RACDB/PASSWORD/pwdracdb.257.912274501
需先用asmcmd将其复制到文件系统,再传给Standby。

点击(此处)折叠或打开

  1. ASMCMD> cp pwdracdb.257.912274501 /tmp
  2. copying +DATA/RACDB/PASSWORD/pwdracdb.257.912274501 -> /tmp/pwdracdb.257.912274501
3) 备用日志文件多线程

点击(此处)折叠或打开

  1. SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 500M;
  2. SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 500M;
  3. SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 500M;
  4. SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 SIZE 500M;
  5. SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 SIZE 500M;
  6. SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 SIZE 500M;
如果redo log有2个thread和2个group,就按照上例创建2个thread和各3个备用日志组。

4)spfile的链接
使用duplicate时,默认寻找spfile的路径在+DATA/racdb/spfileracdb.ora,而这并不是spfile的实际路径,因此需要在asmcmd中进行链接

点击(此处)折叠或打开

  1. ASMCMD> mkalias +DATA/RACDB/PARAMETERFILE/spfile.272.912277345 +DATA/racdb/spfileracdb.ora
5)去掉RAC相关参数

点击(此处)折叠或打开

  1. set cluster_database='FALSE'
  2.     set remote_listener=''
6)开启redo apply的命令从12c开始有变化

点击(此处)折叠或打开

  1. SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
  2. or

  3. SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING ARCHIVED LOGFILE DISCONNECT;
前一句相当于之前的using current logfile

完整示例:

点击(此处)折叠或打开

  1. connect target sys/oracle@racdb
  2. connect auxiliary sys/oracle@stby
  3. run {
  4.    allocate channel prmy1 type disk;
  5.    allocate channel prmy2 type disk;
  6.    allocate channel prmy3 type disk;
  7.    allocate channel prmy4 type disk;
  8.    allocate channel prmy5 type disk;
  9.    allocate auxiliary channel stby1 type disk;
  10.    duplicate target database for standby from active database
  11.      spfile
  12.         parameter_value_convert 'racdb','stby'
  13.         set 'db_unique_name'='stby'
  14.         set control_files='/oradata/STBY/controlfile/control01.ctl','/fra/STBY/controlfile/control02.ctl'
  15.         set db_create_file_dest='/oradata'
  16.         set db_create_online_log_dest_1='/oradata'
  17.         set db_create_online_log_dest_2='/fra'
  18.     set db_recovery_file_dest='/fra'
  19.         set DB_RECOVERY_FILE_DEST_SIZE='45G'
  20.     set cluster_database='FALSE'
  21.     set remote_listener=''
  22.     set DB_FILE_NAME_CONVERT='+DATA/RACDB/','/oradata/STBY/'
  23.         set audit_file_dest='/u01/app/oracle/admin/stby/adump'
  24.               set log_archive_max_processes='4'
  25.               set fal_client='stby'
  26.               set fal_server='racdb'
  27.               set standby_file_management='AUTO'
  28.               set log_archive_config='dg_config=(racdb,stby)'
  29.               set log_archive_dest_2='service=racdb LGWR ASYNC
  30.                   valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE)
  31.                   db_unique_name=racdb'
  32. nofilenamecheck;
  33.            sql channel prmy1 "alter system set
  34.                        log_archive_config=''dg_config=(racdb,stby)''";
  35.            sql channel prmy1 "alter system set
  36.                        log_archive_dest_2=''service=stby LGWR ASYNC
  37.                        valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE)
  38.                        db_unique_name=stby''";
  39.            sql channel prmy1 "alter system set log_archive_max_processes=4";
  40.            sql channel prmy1 "alter system set fal_client=racdb";
  41.            sql channel prmy1 "alter system set fal_server=stby";
  42.            sql channel prmy1 "alter system set standby_file_management=AUTO"; 
  43.            sql channel prmy1 "alter system archive log current";
  44.            allocate auxiliary channel stby type disk;
  45.            sql channel stby "alter database recover managed standby database
  46.                               disconnect";
  47. }
然后,Primary端需要更改spfile参数并重启:

点击(此处)折叠或打开

  1. alter system set DB_FILE_NAME_CONVERT='/oradata/STBY/','+DATA/RACDB/' scope=spfile;

完成。
注意,另一个相似的参数log_file_name_convert不要配置,因为经测试新创建logfile时设置该参数并不能自动在Standby端同步建立log文件。所以Standby端需手动建立log文件。
MOS ID 1367014.1曾建议在OMF下,不要设置log_file_name_convert和db_file_name_convert参数。但PDB确实需要db_file_name_convert参数,当Primary端新建PDB时将在Standby端依此转换路径。

另外,如果要以ADG方式运行,必须先启动到只读打开模式,再开启redo apply。不能反过来,否则会报错。


请使用浏览器的分享功能分享到微信等