Oracle 11G数据库DataGuard灾备切换方案
、检查
1、确定MRP进程在正常运行
备库执行如下SQL确定MRP进程正常:
SELECT PROCESS FROM V$MANAGED_STANDBY WHERE PROCESS LIKE 'MRP%';
主库执行如下SQL,确定备库是“REAL TIME八「「1丫”状态
SQL> SELECT RECOVERY_MODE FROM V$ARCHIVE_DEST_STATUS WHERE DEST_ID=2;
RECOVERYMODE
MANAGED REAL TIME APPLY
如果备库没有启用real-time apply,则需要重新将备库启动至real-time apply
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
2、确定有足够的归档进程
在所有的主备库实例上查询参数LOG_ARCHIVE_MAX_PROCESSES,确定其值大于等于4, 但不会太大
3、确定目标备库的REDOclear状态
虽然在发起SWITCHOVER TO PRIMARY命令时,备库的REDO会自动转换为CLEAR 状态,但依然建议在SWITCHOVER前REDO为CLEAR状态。
确保正确设置了 LOG_FILE_NAME_CONVERT参数。
使用如下SQL在目标备库上查看REDO状态:
SQL> SELECT DISTINCT L.GROUP# FROM V$LOG L, V$LOGFILE LF
WHERE L.GROUP# = LF.GROUP#
    AND L.STATUS NOT IN (\UNUSED’, CLEARING’,’CLEARING_CURRENT’); 如果如上的查询有结果,则需要停止备库的REDOAPPLY,并通过如下的SQL来对其进 CLEAR
SQL> ALTER DATABASE CLEAR LOGFILE GROUP <ORL GROUP# from the query above>;
4、确定没有大量的GAP
主库执行如下SQL查看主库当前的REDO SEQUENCE
SQLSELECT THREAD#, SEQUENCE# FROM V$THREAD;
在备库上执行如下查询,确定查询出来的结果与上面的结果相比较只差1-2个数值
SELECT THREAD#, MAX(SEQUENCE#) FROM V$ARCHIVED_LOG
WHERE APPLIED = 'YES'
AND RESETLOGS_CHANGE# = (SELECT RESETLOGS_CHANGE#
FROM V$DATABASEINCARNATION WHERE STATUS = yCURRENT’)
GROUP BY THREAD#;
5、确定主库以及目标备库的所有文件都为ONLINE
主备库分别执行如下SQL,查看tempfile是否正常,如果备库上缺失文件则需要进行 处理:
SELECT TMP.NAME FILENAME, BYTES, TS.NAME TABLESPACE
FROM V$TEMPFILE TMP, V$TABLESPACE TS WHERE TMP.TS#=TS.TS#;
在主备库分别执行如下SQL,查看数据文件状态,结果应该一致
SELECT NAME FROM V$DATAFILE WHERE STATUS=’OFFLINE’;
如果备库上有比主库多出的OFFLINE状态的数据文件,则将其ONLINE
ALTER DATABASE DATAFILE &FILEID ONLINE;
、切换
1、检查主库是否可切换至STANDBY
主库执行如下SQL执行检查
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVERSTATUS
TO STANDBY
如上的SQL查询结果如果为TO STANDBY或者SESSIONS ACTIVE表示主库可切 换至STANDBY,如果不为这两个值,则说明REDO传输存在问题。
2、停止主库第一个节点以外的所有实例(RAC
最好使用shutdown normal或者shutdown immediate方式停止数据库。如果使用了 shutdown abort将其他节点进行了关闭,则需等待RAC reconfig完成,且第一个节点 将其余REDO正常前滚或回滚
3、切换主库至STANDBY
将主库切换至STANDBY
ALTER DATABASE COMMIT TO SWITCHOVER TO STANDBY WITH SESSION SHUTDOWN;
如果遇到ORA-16139报错,且V$DATABASE视图中DATABASE_ROLE字段的值 已为“ PHYSICAL STANDBY”,则可继续(这种问题的出现其中一个可能是 数据库有大量的数据文件)。
4、确定STANDBY收至1EOR
在主库的ALERT日志中可以看到类似如下的信息:
Switchover: Primary controlfile converted to standby controlfile succesfully.
Tue Mar 15 16:12:15 2011
MRP0 started with pid=17, OS id=2717
MRP0: Background Managed Standby Recovery process started (SFO) Serial Media Recovery started
Managed Standby Recovery not using Real Time Apply
Online logfile pre-clearing operation disabled by switchover Media Recovery Log
/u01/app/flash_recovery_area/SFO/archivelog/2011_03_15/o1_mf_1_1 33_6qzl0yvd_.arc
Identified End-Of-Redo for thread 1 sequence 133
Resetting standby activation ID 0 (0x0)
Media Recovery End-Of-Redo indicator encountered
Media Recovery Applied until change 4314801
MRP0: Media Recovery Complete: End-Of-REDO (SFO)
MRP0: Background Media Recovery process shutdown (SFO)
Tue Mar 15 16:12:21 2011
Switchover: Complete - Database shutdown required (SFO)
oracle11g 创建数据库Completed: ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBWITH SESSION SHUTDOWN
同时在所有备库的ALERT日志中可以看到类似如下的信息:
Tue Mar 15 16:12:15 2011
RFS[8]: Assigned to RFS process 2715
RFS[8]: Identified database type as ,physical standby,: Client is Foreground pid 2568
Media Recovery Log
/u01/app/flash_recovery_area/NYC/archivelog/2011_03_15/o1_mf_1_1
33_6qzl0yjp_.arc
Identified End-Of-Redo for thread 1 sequence 133
Resetting standby activation ID 2680651518 (0x9fc77efe)
Media Recovery End-Of-Redo indicator encountered
Media Recovery Continuing
Resetting standby activation ID 2680651518 (0x9fc77efe)
Media Recovery Waiting for thread 1 sequence 134
5、检查STANDBY能够切换至PRIMARY
目标备库上执行如下SQL进行检查
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVERSTATUS
TO PRIMARY
如上的SQL查询结果如果为"TO PRIMARY或者"SESSIONS ACTIVE"表示目标备库可 切换至PRIMARY,如果不为这两个值,则说明REDO传输或者应用存在问题。
6、切换备库至PRIMARY
在目标备库执行如下命令
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
同时在alert日志中有类似如下信息
Tue Mar 15 16:16:44 2011
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN
ALTER DATABASE SWITCHOVER TO PRIMARY (NYC)
Maximum wait for role transition is 15 minutes.
Switchover: Media recovery is still active
Role Change: Canceling MRP - no more redo to apply

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。