环境: db version:11.2.0.3 主库:两节点的RAC 备库:两节点的RAC 是异地灾备,网络质量不太好。 步骤: 1.检查日志应用情况 standby database(备库检查): SQL> select thread#,SEQUENCE#,FIRST_TIME,next_time,applied from gv$archived_log order by sequence#;(确定日志都已经应用)
2.检查日志传输错误 SQL> SELECT STATUS, GAP_STATUS FROM V$ARCHIVE_DEST_STATUS WHERE DEST_ID = 2;
STATUS GAP_STATUS --------- ------------------------ VALID NO GAP
3.评估切换时间 --rac环境下备库只有一个实例可以为open状态。 set linesize 200 SQL> column name format a22 SQL> column value format a16 SQL> column unit format a28 SQL> column time_computed format a25 SQL> select * from v$dataguard_stats; NAME VALUE UNIT TIME_COMPUTED DATUM_TIME ---------------------- ---------------- ---------------------------- ------------------------- ------------------------------ transport lag +00 01:47:32 day(2) to second(0) interval 10/29/2014 10:48:15 10/29/2014 10:47:58 apply lag +00 01:47:32 day(2) to second(0) interval 10/29/2014 10:48:15 10/29/2014 10:47:58 apply finish time day(2) to second(3) interval 10/29/2014 10:48:15 estimated startup time 20 second 10/29/2014 10:48:15
SQL> alter database commit to switchover to physical standby with session shutdown; alter database commit to switchover to physical standby with session shutdown * ERROR at line 1: ORA-01105: mount is incompatible with mounts by other instances
5.登录主库操作 SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE; --确保状态为SESSION_ACTIVE 或者TO STANDBY(由于是异地可能在shut一个实例后,redo应用会有延迟,如果网络质量不太好,可等一等)
alter database commit to switchover to physical standby with session shutdown;--执行切换(最好把应用停掉) --执行完此操作后,数据库会自动shut
STARTUP MOUNT;--启动原来主库到mount
6.登录备库操作 SELECT SWITCHOVER_STATUS FROM V$DATABASE; --确保状态会SESSION_ACTIVE或者TO PRIMARY.
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN; --执行角色切换
9.检查是否同步 SELECT MAX(SEQUENCE#),THREAD# FROM V$ARCHIVED_LOG WHERE RESETLOGS_CHANGE# = (SELECT MAX(RESETLOGS_CHANGE#) FROM V$ARCHIVED_LOG) GROUP BY THREAD#;