12c RAC下搭建物理備用

hooca發表於2016-06-08
基本可以參考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。不能反過來,否則會報錯。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22621861/viewspace-2117362/,如需轉載,請註明出處,否則將追究法律責任。

相關文章