DataGuard开启failover
1、修改保护模式
DGMGRL> edit configuration set protection mode as maxAvailability;Succeeded.
2、修改日志同步方式
DGMGRL> show database verbose xiaohe 'LogXptMode'LogXptMode = 'ASYNC'DGMGRL> show database verbose xiaohedg 'LogXptMode'LogXptMode = 'ASYNC'DGMGRL> edit database xiaohe set property LogXptMode = 'SYNC';Property "logxptmode" updatedDGMGRL> edit database xiaohedg set property LogXptMode = 'SYNC';Property "logxptmode" updatedDGMGRL>DGMGRL> show database verbose xiaohe 'LogXptMode'LogXptMode = 'SYNC'DGMGRL> show database verbose xiaohedg 'LogXptMode'LogXptMode = 'SYNC'
3、在dgmgrl中配置主库与standby数据库的FastStartFailoverTarget属性
DGMGRL> show database verbose xiaohe 'FastStartFailoverTarget';FastStartFailoverTarget = 'xiaohedg'DGMGRL> show database verbose xiaohedg 'FastStartFailoverTarget';FastStartFailoverTarget = 'xiaohe'
这里已经不用配置了, 如果需要配置, 使用如下的命令:
edit database xiaohedg set property FastStartFailoverTarget='xiaohe';
4、启动observer
DGMGRL> start observer
Observer started
5、在另外一个终端查看failover状态
可以看到Observer: xiaohe_dg1, 这里监控的就是主库。
DGMGRL> show fast_start failoverFast-Start Failover: DISABLEDThreshold: 30 secondsTarget: (none)Observer: xiaohe_dg1Lag Limit: 30 secondsShutdown Primary: TRUEAuto-reinstate: TRUEConfigurable Failover ConditionsHealth Conditions:Corrupted Controlfile YESCorrupted Dictionary YESInaccessible Logfile NOStuck Archiver NODatafile Offline YESOracle Error Conditions:(none)
6、激活failover功能
DGMGRL> enable fast_start failover;Enabled.
7、模拟故障
(1)、将主库给shutdown abort
SQL> shutdown abort;ORACLE instance shut down.
(2)、等一两分钟, 查看observer的日志
DGMGRL> start observerObserver started23:56:08.19 Saturday, March 18, 2017Initiating Fast-Start Failover to database "xiaohe"...Performing failover NOW, please wait...Failover succeeded, new primary is "xiaohe"23:56:11.64 Saturday, March 18, 2017
(3)、查看备库是否已经切换为主库
SQL> select open_mode from v$database;OPEN_MODE--------------------READ WRITE
(4)、将故障的库重新启动
启动数据库报错:
SQL> startupORACLE instance started.Total System Global Area 839282688 bytesFixed Size 2233000 bytesVariable Size 494931288 bytesDatabase Buffers 339738624 bytesRedo Buffers 2379776 bytesDatabase mounted.ORA-16649: possible failover to another database prevents this database frombeing opened
查看日志,下面的红色部分是新产生的日志:
DGMGRL> start observerObserver started23:56:08.19 Saturday, March 18, 2017Initiating Fast-Start Failover to database "xiaohe"...Performing failover NOW, please wait...Failover succeeded, new primary is "xiaohe"23:56:11.64 Saturday, March 18, 201700:05:46.24 Sunday, March 19, 2017Initiating reinstatement for database "xiaohedg"...Reinstating database "xiaohedg", please wait...Operation requires shutdown of instance "xiaohedg" on database "xiaohedg"Shutting down instance "xiaohedg"...ORA-01109: database not openDatabase dismounted.ORACLE instance shut down.Operation requires startup of instance "xiaohedg" on database "xiaohedg"Starting instance "xiaohedg"...ORACLE instance started.Database mounted.Continuing to reinstate database "xiaohedg" ...Reinstatement of database "xiaohedg" succeeded00:06:42.78 Sunday, March 19, 2017
等了几分钟后, 数据库自动恢复正常了。
经测试, 但故障的库只需要启动到mount状态, failover就能自动将库打开。

浙公网安备 33010602011771号