当oracle data guard中如主库出现当机时,需要将从库切换为主库,以下从实验环境模拟主从库切换操作:
1.查看主从库角色
192.168.88.120:
192.168.88.119:
2.将主库(88.120)切换为从库
alter database commit to switchover to physical standby with sessionB shutdown;
shutdown immediate;
startup nomount;
alter database mount standby database;
startup nomount;
alter database mount standby database;
recover managed standby database disconnect;
3.主库切换完成,开启数据库
alter database open或shutdown以后startup
4..将从库切换为主库
alter database commit to switchover to primary;
shutdown immediate
startup
5.在从库上应用重做日志
alter database recover managed standby database disconnect from session;
6..查看切换后状态
192.168.88.119:
192.168.88.120:
7..验证切换是否成功(角色切换过来后需要查看日志是否能正确从新的主库同步到备用库)
在主从库上分别执行
SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
新主库88.119:
新从库88.120:
通过主从库新的归档应用和确认状态可查看到两个库的角色已经成功切换!
本文转自ttzztt 51CTO博客,原文链接:http://blog.51cto.com/tianzt/263522,如需转载请自行联系原作者