ora11_node_dg(4)主庫當機後,從庫升為主庫,重新搭建DG

fjzcau發表於2015-12-31

主庫當機後,從庫切換為主庫,重新搭建DG過程如下,


  1. 1、修改primary端初始化引數檔案 (不用修改,目前就是這樣的配置)

  2. alter system set log_archive_config = 'DG_CONFIG=(zzdb,zzdb_dg)' scope=both;
  3. alter system set log_archive_dest_1 = 'LOCATION=/oracle/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=zzdb_dg' scope=both;
  4. alter system set log_archive_dest_2 = 'SERVICE=zzdb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=zzdb' scope=both;
  5. alter system set log_archive_dest_state_1 = enable;
  6. alter system set log_archive_dest_state_2 = enable;
  7. alter system set fal_server=zzdb scope=both;
  8. alter system set fal_client=zzdb_dg scope=both;
  9. alter system set standby_file_management=AUTO scope=both;
  10. alter system set db_file_name_convert='/oracle/product/oradata/zzdb','/oracle/product/oradata/zzdb' scope=spfile;
  11. alter system set log_file_name_convert='/oracle/product/oradata/zzdb','/oracle/product/oradata/zzdb' scope=spfile;


  12. 2、現primary端pfile引數檔案和密碼檔案,並且複製到standby節點(原primary節點)段相應位置

  13. SQL> create pfile from spfile;
  14. cd $ORACLE_HOME/dbs
  15. scp initzzdb.ora orapwzzdb ora11-node1:$ORACLE_HOME/dbs
  16. cd $ORACLE_BASE
  17. scp -r admin/ diag/ ora11-node1:$ORACLE_BASE


  18. 3、修改standby(原primary節點)的監聽檔案及初始化引數檔案

  19. --複製現primary節點的監聽檔案
  20.   
  21. --啟動監聽
  22. [oracle@ora11-node1 dbs]$ lsnrctl start


  23. --修改引數檔案
  24. [oracle@ora11-node1 ~]$ sqlplus / as sysdba
  25. SQL> startup nomount;
  26. SQL> create spfile from pfile='$ORACLE_HOME/dbs/initzzdb.ora';
  27. SQL> shutdown abort;
  28. SQL> startup nomount;
  29. SQL>
  30. alter system set db_unique_name=zzdb scope=spfile;
  31. alter system set log_archive_config='DG_CONFIG=(zzdb,zzdb_dg)' scope=both;
  32. alter system set log_archive_dest_1 = 'LOCATION=/oracle/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=zzdb' scope=spfile;
  33. alter system set log_archive_dest_2 = 'SERVICE=zzdb_dg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=zzdb_dg' scope=spfile;
  34. alter system set fal_server=zzdb_dg scope=spfile;
  35. alter system set fal_client=zzdb scope=spfile;

  36. SQL> shutdown abort;
  37. SQL> startup nomount;


  38. 4、在primary端透過Rman建立備庫,在 ora11-node2 上執行如下命令

  39. #primary備份資料庫
  40. mkdir -p /oracle/db_backup
  41. rman target / <<!
  42. run {
  43.   CONFIGURE DEVICE TYPE DISK PARALLELISM 3;
  44.   backup database format '/oracle/db_backup/%d_%s_%p_%t.%T';
  45. }
  46. !

  47. # primary生成備庫控制檔案
  48. rman target / <<!
  49. run {
  50.   allocate channel c1 device type disk format '/oracle/db_backup/CON_%U';
  51.   backup current controlfile for standby;
  52. }
  53. !

  54. # cp備份檔案和控制檔案到standby
  55. cd /oracle/db_backup
  56. scp * ora11-node1:/oracle/db_backup

  57. #standby節點,恢復控制檔案
  58. rman target / <<!
  59. run {
  60.   restore controlfile from '/oracle/db_backup/CON_0bqq71jt_1_1';
  61.   alter database mount;
  62. }
  63. !

  64. #standby節點,透過rman進行恢復
  65. rman target / <<!
  66.   CONFIGURE DEVICE TYPE DISK PARALLELISM 3;
  67.   restore database;
  68. !

  69. #至此已經恢復完成


  70. 5、在 standby 端 檢視standby日誌
  71. SQL> SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;

  72. 若沒有新增:

  73. SQL> alter database add standby logfile
  74. group 4 ('/oracle/product/oradata/zzdb/zzdb_dgredo04.log') size 50m,
  75. group 5 ('/oracle/product/oradata/zzdb/zzdb_dgredo05.log') size 50m,
  76. group 6 ('/oracle/product/oradata/zzdb/zzdb_dgredo06.log') size 50m,
  77. group 7 ('/oracle/product/oradata/zzdb/zzdb_dgredo07.log') size 50m;


  78. 6、在standby端開啟實時日誌應用

  79. SQL> alter database recover managed standby database using current logfile disconnect from session;

  80. recover managed standby database disconnect from session;

  81. startup;


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

相關文章