查看原文
其他

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

赵海 twt企业IT社区 2022-07-03

来自社区交流分享


■ 计划内切换

(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;


更多相关文章请点击阅读原文


长按二维码关注公众号

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存