DGbroker故障切换示例
1.主库故障
SQL> startup ORACLE instance started. Total System Global Area 1068937216 bytes Fixed Size 2260088 bytes Variable Size 910164872 bytes Database Buffers 150994944 bytes Redo Buffers 5517312 bytes ORA-00205: error in identifying control file, check alert log for more info
2.dgmgrl故障提示
DGMGRL> show configuration; Configuration - dgc Protection Mode: MaxPerformance Databases: atest1 - Primary database atest2 - Physical standby database Fast-Start Failover: DISABLED Configuration Status: ORA-16525: the Data Guard broker is not yet available ORA-16625: cannot reach database "atest1" DGM-17017: unable to determine configuration status
3.执行故障切换
DGMGRL> failover to atest2; Performing failover NOW, please wait... Failover succeeded, new primary is "atest2"
DGMGRL> show configuration; Configuration - dgc Protection Mode: MaxPerformance Databases: atest2 - Primary database atest1 - Physical standby database (disabled) ORA-16661: the standby database needs to be reinstated Fast-Start Failover: DISABLED Configuration Status: SUCCESS
查看状态如上,提示已切换成功,atest2已成为主库,而atest1处于故障中。
4.处理故障数据库(采用rman复制的方式)
a.故障库需要启动到nomount
b.登录rman
rlwrap rman target sys/123456@atest2 auxiliary sys/123456@atest1
c.执行数据库克隆
RMAN> duplicate target database for standby nofilenamecheck from active database; Starting Duplicate Db at 29-DEC-15 using target database control file instead of recovery catalog allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=1147 device type=DISK contents of Memory Script: { backup as copy reuse targetfile '/u01/app/oracle/product/11.2.0/db1/dbs/orapwatest' auxiliary format '/u01/app/oracle/product/11.2.0/db1/dbs/orapwatest' ; } executing Memory Script Starting backup at 29-DEC-15 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=19 device type=DISK Finished backup at 29-DEC-15 contents of Memory Script: { sql clone "alter system set control_files = ''/u01/app/oracle/oradata/ATEST/controlfile/o1_mf_c5fr9b0h_.ctl'', ''/u01/app/oracle/fast_recovery_area/ATEST/controlfile/o1_mf_c5fr9b6n_.ctl'' comment= ''Set by RMAN'' scope=spfile"; backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/ATEST/controlfile/o1_mf_c5fr9b0h_.ctl'; restore clone controlfile to '/u01/app/oracle/fast_recovery_area/ATEST/controlfile/o1_mf_c5fr9b6n_.ctl' from '/u01/app/oracle/oradata/ATEST/controlfile/o1_mf_c5fr9b0h_.ctl'; sql clone "alter system set control_files = ''/u01/app/oracle/oradata/ATEST/controlfile/o1_mf_c5fr9b0h_.ctl'', ''/u01/app/oracle/fast_recovery_area/ATEST/controlfile/o1_mf_c5fr9b6n_.ctl'' comment= ''Set by RMAN'' scope=spfile"; shutdown clone immediate; startup clone nomount; } executing Memory Script sql statement: alter system set control_files = ''/u01/app/oracle/oradata/ATEST/controlfile/o1_mf_c5fr9b0h_.ctl'', ''/u01/app/oracle/fast_recovery_area/ATEST/controlfile/o1_mf_c5fr9b6n_.ctl'' comment= ''Set by RMAN'' scope=spfile Starting backup at 29-DEC-15 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy copying standby control file output file name=/u01/app/oracle/product/11.2.0/db1/dbs/snapcf_atest.f tag=TAG20151229T212657 RECID=10 STAMP=899760418 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 Finished backup at 29-DEC-15 Starting restore at 29-DEC-15 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: copied control file copy Finished restore at 29-DEC-15 sql statement: alter system set control_files = ''/u01/app/oracle/oradata/ATEST/controlfile/o1_mf_c5fr9b0h_.ctl'', ''/u01/app/oracle/fast_recovery_area/ATEST/controlfile/o1_mf_c5fr9b6n_.ctl'' comment= ''Set by RMAN'' scope=spfile Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 1068937216 bytes Fixed Size 2260088 bytes Variable Size 910164872 bytes Database Buffers 150994944 bytes Redo Buffers 5517312 bytes contents of Memory Script: { sql clone 'alter database mount standby database'; } executing Memory Script sql statement: alter database mount standby database contents of Memory Script: { set newname for clone tempfile 1 to new; switch clone tempfile all; set newname for clone datafile 1 to new; set newname for clone datafile 2 to new; set newname for clone datafile 3 to new; set newname for clone datafile 4 to new; set newname for clone datafile 5 to new; set newname for clone datafile 6 to new; backup as copy reuse datafile 1 auxiliary format new datafile 2 auxiliary format new datafile 3 auxiliary format new datafile 4 auxiliary format new datafile 5 auxiliary format new datafile 6 auxiliary format new ; sql 'alter system archive log current'; } executing Memory Script executing command: SET NEWNAME renamed tempfile 1 to /u01/app/oracle/oradata/ATEST1/datafile/o1_mf_temp_%u_.tmp in control file executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME Starting backup at 29-DEC-15 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy input datafile file number=00005 name=/u01/app/oracle/oradata/ATEST2/datafile/o1_mf_system_c7sxhqz0_.dbf output file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_system_15qq2g9s_.dbf tag=TAG20151229T212723 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:35 channel ORA_DISK_1: starting datafile copy input datafile file number=00006 name=/u01/app/oracle/oradata/ATEST2/datafile/o1_mf_system_c7sxv77x_.dbf output file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_system_16qq2gcr_.dbf tag=TAG20151229T212723 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35 channel ORA_DISK_1: starting datafile copy input datafile file number=00001 name=/u01/app/oracle/oradata/ATEST2/datafile/o1_mf_system_06qovlhs_.dbf output file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_system_17qq2gdu_.dbf tag=TAG20151229T212723 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35 channel ORA_DISK_1: starting datafile copy input datafile file number=00002 name=/u01/app/oracle/oradata/ATEST2/datafile/o1_mf_sysaux_07qovlkt_.dbf output file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_sysaux_18qq2gf1_.dbf tag=TAG20151229T212723 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35 channel ORA_DISK_1: starting datafile copy input datafile file number=00003 name=/u01/app/oracle/oradata/ATEST2/datafile/o1_mf_undotbs1_08qovlnu_.dbf output file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_undotbs1_19qq2gg5_.dbf tag=TAG20151229T212723 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile copy input datafile file number=00004 name=/u01/app/oracle/oradata/ATEST2/datafile/o1_mf_users_09qovlod_.dbf output file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_users_1aqq2ggc_.dbf tag=TAG20151229T212723 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 29-DEC-15 sql statement: alter system archive log current contents of Memory Script: { switch clone datafile all; } executing Memory Script datafile 1 switched to datafile copy input datafile copy RECID=10 STAMP=899760656 file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_system_17qq2gdu_.dbf datafile 2 switched to datafile copy input datafile copy RECID=11 STAMP=899760656 file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_sysaux_18qq2gf1_.dbf datafile 3 switched to datafile copy input datafile copy RECID=12 STAMP=899760656 file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_undotbs1_19qq2gg5_.dbf datafile 4 switched to datafile copy input datafile copy RECID=13 STAMP=899760656 file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_users_1aqq2ggc_.dbf datafile 5 switched to datafile copy input datafile copy RECID=14 STAMP=899760656 file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_system_15qq2g9s_.dbf datafile 6 switched to datafile copy input datafile copy RECID=15 STAMP=899760656 file name=/u01/app/oracle/oradata/ATEST1/datafile/o1_mf_system_16qq2gcr_.dbf Finished Duplicate Db at 29-DEC-15
d.删除和重新添加备库
DGMGRL> remove database atest1; Removed database "atest1" from the configuration DGMGRL> add database atest1; Database "atest1" added DGMGRL> disable configuration; Disabled. DGMGRL> enable configuration; Enabled. DGMGRL> show configuration; Configuration - dgc Protection Mode: MaxPerformance Databases: atest2 - Primary database atest1 - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS
e.把故障库启动到open状态
SQL> alter database open;
Database altered.
5.如果需要,可以把主备库切换切回来
DGMGRL> switchover to atest1; Performing switchover NOW, please wait... Operation requires a connection to instance "atest" on database "atest1" Connecting to instance "atest"... Connected. New primary database "atest1" is opening... Operation requires startup of instance "atest" on database "atest2" Starting instance "atest"... ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance ORACLE instance started. Database mounted. Database opened. Switchover succeeded, new primary is "atest1" DGMGRL> show configuration; Configuration - dgc Protection Mode: MaxPerformance Databases: atest1 - Primary database atest2 - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS