1. 首页
  2. IT资讯

ORACLE DataGuard 主备库角色切换

主备库切换原因:
1. switch:用户主动切换;
2. failover:主库出现故障,强行切换;
switch切换过程:先主库再备库
主库
1. 查看switchover_status:select database_role, switchover_status from v$database;
如果switchover_status为:to standby 则:
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY
否则用:ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
2. 重启数据库:
shutdown immediate;
startup nomount;
3. 以备库mount
alter database mount standby database;
备库
1. 应用redo:alter database recover managed standby database disconnect from session;
2. 查看switchover_status:select database_role, switchover_status from v$database;
如果switchover_status为:to primary 则:ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY
否则用:ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
3. 重启数据库
shutdown immediate;
startup;
failover 主备库切换
1.. 停止日志应用 alter database recover managed standby database cancel;
2. 关闭standby日志传输 alter database recover managed standby database finish force;
3. 切换到primary alter database commit to switchover to primary with session shutdown;
做这一步的时候,若存在gap,则会报ORA-16139:Switchover: Media recovery required – standby not in limbo 错误。
做测试的时候,若先起主库再起备库,且未等待备库相关日志传输完毕,就会出现这个问题。此时需要强制切换 alter database activate physical standby database;
4. 重启数据库到open状态

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29578568/viewspace-2136909/,如需转载,请注明出处,否则将追究法律责任。

主题测试文章,只做测试使用。发布者:布吉卡,转转请注明出处:http://www.cxybcw.com/195110.html

联系我们

13687733322

在线咨询:点击这里给我发消息

邮件:1877088071@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

QR code