首页 > 代码库 > DataGuard开启failover
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" updated
DGMGRL> edit database xiaohedg set property LogXptMode = ‘SYNC‘;
Property "logxptmode" updated
DGMGRL>
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 failover
Fast-Start Failover: DISABLED
Threshold: 30 seconds
Target: (none)
Observer: xiaohe_dg1
Lag Limit: 30 seconds
Shutdown Primary: TRUE
Auto-reinstate: TRUE
Configurable Failover Conditions
Health Conditions:
Corrupted Controlfile YES
Corrupted Dictionary YES
Inaccessible Logfile NO
Stuck Archiver NO
Datafile Offline YES
Oracle 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 observer
Observer started
23:56:08.19 Saturday, March 18, 2017
Initiating 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> startup
ORACLE instance started.
Total System Global Area 839282688 bytes
Fixed Size 2233000 bytes
Variable Size 494931288 bytes
Database Buffers 339738624 bytes
Redo Buffers 2379776 bytes
Database mounted.
ORA-16649: possible failover to another database prevents this database from
being opened
查看日志,下面的红色部分是新产生的日志:
DGMGRL> start observer
Observer started
23:56:08.19 Saturday, March 18, 2017
Initiating 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
00:05:46.24 Sunday, March 19, 2017
Initiating 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 open
Database 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" succeeded
00:06:42.78 Sunday, March 19, 2017
等了几分钟后, 数据库自动恢复正常了。
经测试, 但故障的库只需要启动到mount状态, failover就能自动将库打开。
DataGuard开启failover
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。