我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

ORACLEDataGuard主备库角色切换

主备库切换原因:
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状态

新闻标题:ORACLEDataGuard主备库角色切换
网站链接:http://mswzjz.cn/article/gogcco.html

其他资讯