码迷,mamicode.com
首页 > 其他好文 > 详细

DataGuard开启failover

时间:2017-03-19 01:09:27      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:date   ati   ssi   oracle   sts   byte   style   primary   故障   


1、修改保护模式

  1. DGMGRL> edit configuration set protection mode as maxAvailability;
  2. Succeeded.

2、修改日志同步方式

  1. DGMGRL> show database verbose xiaohe ‘LogXptMode‘
  2. LogXptMode = ‘ASYNC‘
  3. DGMGRL> show database verbose xiaohedg ‘LogXptMode‘
  4. LogXptMode = ‘ASYNC‘
  5. DGMGRL> edit database xiaohe set property LogXptMode = ‘SYNC‘;
  6. Property "logxptmode" updated
  7. DGMGRL> edit database xiaohedg set property LogXptMode = ‘SYNC‘;
  8. Property "logxptmode" updated
  9. DGMGRL>
  10. DGMGRL> show database verbose xiaohe ‘LogXptMode‘
  11. LogXptMode = ‘SYNC‘
  12. DGMGRL> show database verbose xiaohedg ‘LogXptMode‘
  13. LogXptMode = ‘SYNC‘

3、在dgmgrl中配置主库与standby数据库的FastStartFailoverTarget属性

  1. DGMGRL> show database verbose xiaohe ‘FastStartFailoverTarget‘;
  2. FastStartFailoverTarget = ‘xiaohedg‘
  3. DGMGRL> show database verbose xiaohedg ‘FastStartFailoverTarget‘;
  4. FastStartFailoverTarget = ‘xiaohe‘

这里已经不用配置了, 如果需要配置, 使用如下的命令:
edit database xiaohedg set property FastStartFailoverTarget=‘xiaohe‘;

4、启动observer

DGMGRL> start observer
Observer started


5、在另外一个终端查看failover状态

可以看到Observer: xiaohe_dg1, 这里监控的就是主库。

  1. DGMGRL> show fast_start failover
  2. Fast-Start Failover: DISABLED
  3. Threshold: 30 seconds
  4. Target: (none)
  5. Observer: xiaohe_dg1
  6. Lag Limit: 30 seconds
  7. Shutdown Primary: TRUE
  8. Auto-reinstate: TRUE
  9. Configurable Failover Conditions
  10. Health Conditions:
  11. Corrupted Controlfile YES
  12. Corrupted Dictionary YES
  13. Inaccessible Logfile NO
  14. Stuck Archiver NO
  15. Datafile Offline YES
  16. Oracle Error Conditions:
  17. (none)


6、激活failover功能

  1. DGMGRL> enable fast_start failover;
  2. Enabled.

7、模拟故障

(1)、将主库给shutdown abort
  1. SQL> shutdown abort;
  2. ORACLE instance shut down.

(2)、等一两分钟, 查看observer的日志
  1. DGMGRL> start observer
  2. Observer started
  3. 23:56:08.19 Saturday, March 18, 2017
  4. Initiating Fast-Start Failover to database "xiaohe"...
  5. Performing failover NOW, please wait...
  6. Failover succeeded, new primary is "xiaohe"
  7. 23:56:11.64 Saturday, March 18, 2017


(3)、查看备库是否已经切换为主库
  1. SQL> select open_mode from v$database;
  2. OPEN_MODE
  3. --------------------
  4. READ WRITE

(4)、将故障的库重新启动
启动数据库报错:
  1. SQL> startup
  2. ORACLE instance started.
  3. Total System Global Area 839282688 bytes
  4. Fixed Size 2233000 bytes
  5. Variable Size 494931288 bytes
  6. Database Buffers 339738624 bytes
  7. Redo Buffers 2379776 bytes
  8. Database mounted.
  9. ORA-16649: possible failover to another database prevents this database from
  10. being opened



查看日志,下面的红色部分是新产生的日志:

  1. DGMGRL> start observer
  2. Observer started
  3. 23:56:08.19 Saturday, March 18, 2017
  4. Initiating Fast-Start Failover to database "xiaohe"...
  5. Performing failover NOW, please wait...
  6. Failover succeeded, new primary is "xiaohe"
  7. 23:56:11.64 Saturday, March 18, 2017
  8. 00:05:46.24 Sunday, March 19, 2017
  9. Initiating reinstatement for database "xiaohedg"...
  10. Reinstating database "xiaohedg", please wait...
  11. Operation requires shutdown of instance "xiaohedg" on database "xiaohedg"
  12. Shutting down instance "xiaohedg"...
  13. ORA-01109: database not open
  14. Database dismounted.
  15. ORACLE instance shut down.
  16. Operation requires startup of instance "xiaohedg" on database "xiaohedg"
  17. Starting instance "xiaohedg"...
  18. ORACLE instance started.
  19. Database mounted.
  20. Continuing to reinstate database "xiaohedg" ...
  21. Reinstatement of database "xiaohedg" succeeded
  22. 00:06:42.78 Sunday, March 19, 2017

等了几分钟后, 数据库自动恢复正常了。

经测试, 但故障的库只需要启动到mount状态, failover就能自动将库打开。


















DataGuard开启failover

标签:date   ati   ssi   oracle   sts   byte   style   primary   故障   

原文地址:http://www.cnblogs.com/xiaohe001/p/6577184.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!