adg强制切换

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了adg强制切换相关的知识,希望对你有一定的参考价值。

参考技术A 确保配置了主库和从库的初始化参数,使得切换完成后,DATAGUARD机制可以顺利的运行。
ractorac的adg切换只需在其中一个节点执行相应命令即可。

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;


以上是关于adg强制切换的主要内容,如果未能解决你的问题,请参考以下文章

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

Oracle ADG数据库切换

oracle11g ADG主备切换

ADG 备库不允许切换日志

12c Oracle ADG日志切换hang

Oracle 11g R2 ADG 运维