DBAtlas · 数据库运维图谱

使用 SQL 检查主库/备库角色和主备切换就绪状态

OracleData Guard

命令

SELECT name, db_unique_name, database_role, open_mode, protection_mode,
       switchover_status, force_logging, flashback_on, dataguard_broker
FROM   v$database;

-- State of redo destinations and gaps (on the primary):
SELECT dest_id, dest_name, status, type, database_mode,
       recovery_mode, gap_status, error
FROM   v$archive_dest_status
WHERE  status <> 'INACTIVE';

-- Missing archivelog range on the standby:
SELECT thread#, low_sequence#, high_sequence# FROM v$archive_gap;

作用

显示数据库角色、打开模式、保护模式、switchover_status(TO STANDBY / TO PRIMARY / SESSIONS ACTIVE / NOT ALLOWED)、FORCE LOGGING 和 flashback 状态,以及 redo 目标的错误和间隙(gap)。

适用场景

作为主备切换/故障转移前的预检查、新建备库后,以及在未使用 broker 的环境中进行基础监控。

注意

只读。如果 FORCE_LOGGING=NO,NOLOGGING 操作会在备库上留下损坏块;Data Guard 主库必须启用 ALTER DATABASE FORCE LOGGING。如果 FLASHBACK_ON=NO,故障转移后旧主库无法 reinstate,必须重建。

在 DBAtlas 中打开 →

相关内容