Oracle ADG 切换场景及具体切换步骤

Posted twt企业IT社区

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle ADG 切换场景及具体切换步骤相关的知识,希望对你有一定的参考价值。

■ 计划内切换

(1)检查主库

select switchover_status from v$database;

SWITCHOVER_STATUS

SESSIONS ACTIVE

if [ switchover_status = "SESSIONS ACTIVE" | switchover_status = "TO STANDBY" ]; 

then { go to next step } 

else { cancel switchover and check database }

(2)主库切为备库

alter database commit to switchover to physical standby with session shutdown;

shutdown immediate;

startup mount;

(3)检查备库

select switchover_status from v$database;

SWITCHOVER_STATUS

TO PRIMARY

if [ switchover_status = "SESSIONS ACTIVE" | switchover_status = "TO PRIMARY" ]; 

then { go to next step }

else { cancel switchover and check database }

(4)备库切为主库

alter database commit to switchover to PRIMARY with session shutdown;

(5)原主库恢复日志应用

alter database recover managed standby database using current logfile disconnect from session;


■ 计划外切换

一、主备库日志没有缺口的场景

(1)备库检查日志缺口

select thread#,low_sequence#,high_sequence# from v$archive_gap;

未选定行

(2)备库停止日志接受并完成已收日志应用

alter database recover managed standby database cancel;

alter database recover managed standby database finish;

(3)检查备库状态

select switchover_status from v$database;

SWITCHOVER_STATUS

TO PRIMARY

if [ switchover_status = "SESSIONS ACTIVE" | switchover_status = "TO PRIMARY" ]; 

then { go to next step } 

else { cancel switchover and check database }

(4)备库切为主库

alter database commit to switchover to PRIMARY with session shutdown;

alter database open;

二、主库可以打开到 mount 状态

(1)将主库日志刷到备库

alter system flush redo to target_db_name;

(2)备库停止日志接受并完成已收日志应用

alter database recover managed standby database cancel;

alter database recover managed standby database finish;

(3)检查备库状态

select switchover_status from v$database;

SWITCHOVER_STATUS

TO PRIMARY

if [ switchover_status = "SESSIONS ACTIVE" | switchover_status = "TO PRIMARY" ]; 

then { go to next step } 

else { cancel switchover and check database }

(4)备库切为主库

alter database commit to switchover to PRIMARY with session shutdown;

alter database open;

三、主备库间日志缺口无法纠正

(1)强制激活备库

alter database activate physical standby database;

alter database open;


以上是关于Oracle ADG 切换场景及具体切换步骤的主要内容,如果未能解决你的问题,请参考以下文章

oracle11g ADG主备切换

12c Oracle ADG日志切换hang

Oracle 11g Dataguard 配置,维护与详解 (ADG)

Oracle11g ADG 搭建

ORACLE RAC19C到单实例ADG DUPLICATE ORA-01017 错误的解决办法

oracle10g升级到11g之后跨平台ADG遇到ORA-10561错误问题