DG中模拟failover故障与恢复
问题描述:情形是当主库真正出现异常之后,才会执行的操作,那么我们执行过failover 之后,如何在重新构建DG,这里我们利用flashback database来重构。模拟前主库要开启闪回区,否则要重新搭建DG了 1.由于主库已经不可访问,下面所有的操作都在备库完成,先取消实时同步 SQL> alter database recover managed standby database cancel;
2.强制取消redo接收
3.确认一下备库
4.切换为物理主库,然后open,确认一下切换成功,因为原先的主库还没有关闭,可能会产生一些连接,所以现在的状态是GAP,至此failover操作完成,原来的备库已经切换为主库,可以给业务提供服务了 SQL> alter database commit to switchover to primary with session shutdown; SQL> alter database open; SQL> select switchover_status,database_role,open_mode from v$database;
5.failover恢复,在新的主库执行,查询到scn值 SQL> select to_char(standby_became_primary_scn) from v$database;
6.在之前的主库现在的备库上执行,我的之前是startup状态,调整一下现在备库的状态 SQL> shutdown immediate SQL> startup mount
7.恢复闪回区scn值 SQL> flashback database to scn 1388059
8.更改状态 SQL> alter database convert to physical standby;
SQL> shutdown immediate SQL> startup
9.开启实时同步 SQL> alter database recover managed standby database using current logfile disconnect from session;
10.分别查看一下主备库的切换状态,以及数据库角色是否正常 SQL> select switchover_status,database_role,open_mode from v$database; 现在的备库:
现在的主库:已经不再显示GAP,现在指向备库,到此failover结束
11.相关命令 停止实时同步:SQL> alter database recover managed standby database cancel; 强制停掉redo apply:SQL> alter database recover managed standby database finish force; //危险操作,一旦执行,rfs、mrp进程就会停掉 转换物理备库:SQL> alter database commit to switchover to primary with session shutdown; 查询状态角色:SQL> select switchover_status,database_role,open_mode from v$database; 查询SCN号 :SQL> select to_char(standby_became_primary_scn) from v$database; 闪回到序列号:SQL> flashback database to scn 1388059 切换主库为备库:SQL> alter database convert to physical standby; 开启实时同步:SQL> alter database recover managed standby database using current logfile disconnect from session; |