Check primary/standby role and switchover readiness with SQL
OracleData GuardCommand
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;What it does
Shows the database role, open mode, protection mode, switchover_status (TO STANDBY / TO PRIMARY / SESSIONS ACTIVE / NOT ALLOWED), FORCE LOGGING and flashback state, plus errors and gaps for the redo destinations.
When to use it
As a precheck before switchover/failover, after building a new standby, and for basic monitoring where the broker is not used.
Caution
Read-only. If FORCE_LOGGING=NO, NOLOGGING operations leave corrupt blocks on the standby; ALTER DATABASE FORCE LOGGING must be enabled on a Data Guard primary. If FLASHBACK_ON=NO, the old primary cannot be reinstated after a failover and must be rebuilt.
Related
- Show the Data Guard broker configuration and database status (DGMGRL)
- Measure transport/apply lag, apply rate and Data Guard processes on the standby
- Validate the standby with the broker before switchover/failover (VALIDATE DATABASE)
- Perform a planned switchover (DGMGRL, role change without data loss)
- Perform a failover after losing the primary (DGMGRL)
- Recover the old primary as a standby after a failover (REINSTATE)