首页 > 代码库 > Data Guard 主备库角色转换
Data Guard 主备库角色转换
1. switchover操作
1.1 备库先关闭实时日志应用
standby>alter database recover managed standby database cancel;
1.2 主库先判断是否可以支持switchover操作
primary> select switchover_status from v$database;
该值为:TO STANDBY;表示支持。
该值为:SESSION ACTIVE;表示主库有激活会话。不妨碍switchover操作。
1.3 启动switchover;主库转换physical standby。
若上值为第二种情况;后面需加 with shutdown session
即 alter database commit to switchover to physical standby with shutdown session;
primary> alter database commit to switchover to physical standby; Database altered.
1.4 重启原primary库
Primary> shutdown immediate; ORA- 01507 : database not mounted ORACLE instance shut down. Primary> startup ORACLE instance started. Total System Global Area 1.5132E+10 bytes Fixed Size 2243112 bytes Variable Size 2013267416 bytes Database Buffers 1.3086E+10 bytes Redo Buffers 30552064 bytes Database mounted. Database opened.
1.5 物理standby切换为primary
standby>alter database commit to switchover to primary; alter database commit to switchover to primary * ERROR at line 1: ORA-16139: media recovery required standby>alter database recover managed standby database disconnect from session; Database altered. standby>alter database commit to switchover to primary; Database altered.
1.6 重启新primary
standby> alter database open; Database altered.
1.7 新physical standby启动实时日志应用
Primary> alter database recover managed standby database using current logfile disconnect from session;
2.failover操作
模拟主库挂掉
Primary> shutdown abort; ORACLE instance shut down.
2.1 检查归档文件是否连续
查询待转换standby 数据库的V$ARCHIVE_GAP 视图,确认归档文件是否连接
StandBy> SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP; no rows selected
如果有,则拷贝过来;
手工的注册这些日志:
StandBy> ALTER DATABASE REGISTER LOGFILE ‘路径‘;
2.2 启动failover,备库切换主库操作。
StandBy> alter database recover managed standby database finish force; Database altered. StandBy> alter database commit to switchover to primary; Database altered. StandBy> alter database open; Database altered.
2.3 将原primary库重建备库操作
参考博客:http://www.cnblogs.com/lottu/p/7054731.html;http://www.cnblogs.com/lottu/p/7058774.html
实施数据库克隆(辅助实例启动到nomount状态后)
应用redo日志操作;或者 启动实时应用redo日志操作。
参考文献:《三思笔记第10.2.4章节》
Data Guard 主备库角色转换
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。