Dataguard Switchover And Failover Using DGMGRL

Oracle Data Guard Broker Drill (19c): Switchover + Failover Using DGMGRL (End-to-End Runbook)

This week I ran a Data Guard Broker DR drill for a client on Oracle 19c, covering both planned role transition (Switchover) and unplanned role transition (Failover) using the DGMGRL utility. The goal was simple: prove that we can safely switch roles during planned maintenance, and also recover services quickly if the primary becomes unavailableβ€”while validating readiness and capturing the post-event cleanup steps.

The walkthrough below is written as a single, practical runbook (switchover + failover), keeping the same technical flow/commands used in the original procedures.

Β 

Β 

Lab / Drill Context

In my drill setup:

  • Primary DB initially: PRODDB
  • Physical Standby initially: PRODDB_ST
  • Broker config name shown as: prodΒ 
  • Protection mode observed: MaxAvailability (SYNC transport)
  • Note from the drill outcome:
  • After Switchover, the primary becomes PRODDB_ST Β 

Β 

What I validated before role transitions

Switchover readiness (planned activity)

A switchover is a planned role reversal (Primary ↔ Standby) with no data loss, typically for maintenance. Before doing it, I ensured:

  • Both databases were healthy (no broker warnings)
  • Intended states were correct (TRANSPORT-ON on primary, APPLY-ON on standby)
  • Standby Redo Logs were in place and redo transport/apply were running properly

Β 

Failover readiness (emergency activity)

A failover is triggered when the primary is unavailable/unrecoverable in time. Key checks I focused on:

  • Flashback Database enabled (helps reinstatement after failover)
  • Standby Redo Logs present to minimize/avoid data loss (depends on protection mode & last redo shipped)

Β 

Part A β€” Switchover Drill Using DGMGRLΒ 

Step 1: Check primary database (broker view)

I started by checking the primary with verbose output:

DGMGRL> SHOW DATABASE VERBOSE β€˜PRODDB’;

This confirms role, intended state, transport mode, connect identifiers, and overall broker health.

Β 

Step 2: Check target standby (broker view)

Next, I verified the standby that will become the new primary:

Β 
DGMGRL> SHOW DATABASE VERBOSE β€˜PRODDB_ST’;
DGMGRL> SHOW DATABASE β€˜PRODDB_ST’;
Β 
I specifically checked Transport Lag / Apply Lag and ensured APPLY was ON.
Β 
Β 

Step 3: Validate switchover readiness (broker + database)

Broker-side validation:

DGMGRL> VALIDATE DATABASE β€˜PRODDB’;

Database-side verification (switchover status):

Β 
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
Β 
In the drill, SWITCHOVER_STATUS showed TO STANDBY, meaning the primary was ready to switch.

I also confirmed overall configuration status:

DGMGRL> SHOW CONFIGURATION;
Β 

Β 

Step 4: Execute switchover

This is the exact command I ran to flip roles:

DGMGRL> switchover to β€˜PRODDB_ST’;

Broker handled the orchestration (connections, role transition, startup/mount/open steps) and confirmed:

  • New primary: PRODDB_ST
  • Old primary: PRODDB now becomes standby

Β 

Β 

Step 5: Post-switchover verification (SQL checks)

I verified roles on both sides:

Old Primary (now standby):

SQL> select status,instance_name,database_role,protection_mode from v$database,v$instance;
Β 

New Primary:

SQL> select status, instance_name, database_role, protection_mode from v$database,v$instance;
Β 
And finally, rechecked broker configuration:
Β 
DGMGRL> SHOW CONFIGURATION;

During the drill I also kept both alert logs open to monitor transitions in real time (log shipping/apply/service opens).

Β 
Β 
Β 
Β 
Β 

Part B β€” Failover Drill Using DGMGRL

In real incidents, failover is executed only when the primary is not accessible or cannot be restored within RTO. For the drill, I performed it in a controlled way and documented the aftermath.

Β 

Step 1: Confirm Flashback Database enabled (both sides)

BeforeΒ  failover, I confirmed flashback was enabled:

SQL> select flashback_on, instance_name, database_role from v$database,V$instance;

This was done on both databases in the drill output.

Β 

Step 2: Connect to DGMGRL and show configuration

I connected to the current primary PRODDB and checked the configuration:

$ dgmgrl
DGMGRL> connect sys/oracle@PRODDB
DGMGRL> SHOW CONFIGURATION;

This confirmed PRODDB as primary and PRODDB_ST as physical standby.

Β 

Step 3: Validate the target standby for failover

I validated the target standby PRODDB_ST to ensure it is ready:

DGMGRL> VALIDATE DATABASE β€˜PRODDB_ST’;

In the drill, readiness included:

  • Ready for Failover: Yes (Primary Running)

Β 

Step 4: Connect to the target standby

Then I connected to the standby that will become the new primary:

$ dgmgrl
DGMGRL> connect sys/oracle@PRODDB_ST
Β 
Β 

Step 5: Execute failover

This is the failover command I issued:

DGMGRL> FAILOVER TO β€˜PRODDB_ST’;

Broker confirmed: β€œFailover succeeded, new primary is proddb_st”

Β 

Β 

Step 6: Post-failover configuration check (expected warnings)

After failover, I checked:

DGMGRL> SHOW CONFIGURATION;

In the drill output, broker showed warnings like:

  • Standby database disabled
  • β€œthe standby database needs to be reinstated” (reinstate required for the old primary)

This is normal behavior after failoverβ€”the old primary typically must be reinstated (or rebuilt) before it can rejoin as a standby.

Β 

What I documented for the client (practical notes)

  • Switchover is the clean, preferred method for planned maintenance (no data loss, broker-managed transitions).
  • Failover is for emergencies; data loss depends on transport/protection mode and whether redo was fully shipped/applied. Having SRLs + Flashback ON greatly improves recovery and reinstatement workflow.
  • Always run VALIDATE DATABASE before the operation (it catches readiness issues early).
  • After failover, plan the reinstate (or rebuild) of the old primary.

Β 

Β 

Quick Command Summary

Switchover

DGMGRL> SHOW DATABASE VERBOSE β€˜PRODDB’;
DGMGRL> SHOW DATABASE VERBOSE β€˜PRODDB_ST’;
DGMGRL> VALIDATE DATABASE β€˜PRODDB’;
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
DGMGRL> SHOW CONFIGURATION;
DGMGRL> switchover to β€˜PRODDB_ST’;
DGMGRL> SHOW CONFIGURATION;

Β 

Failover

SQL> select flashback_on,instance_name,database_role from v$database,V$instance;
DGMGRL> connect sys/oracle@PRODDB
DGMGRL> SHOW CONFIGURATION;
DGMGRL> VALIDATE DATABASE β€˜PRODB_ST’;
DGMGRL> connect sys/oracle@PRODDB_ST
DGMGRL> FAILOVER TO β€˜PRODDB_ST’;
DGMGRL> SHOW CONFIGURATION;

Β 

Β 

DR Drill Checklist

DR Drill Checklist (Switchover + Failover)

A) Before Drill

Confirm maintenance/drill window approved

Confirm stakeholders on bridge (DBA/App/Infra/Network)

Take pre-drill backups (or confirm last good backup)

Capture baseline: SHOW CONFIGURATION (DGMGRL)

Confirm standby apply healthy (lag acceptable)

Confirm SWITCHOVER_STATUS = TO STANDBY (primary)

Confirm Flashback ON on both DBs (recommended)

Confirm monitoring/on-call ready (OEM, scripts, alerts)

Β 

B) Switchover Execution

VALIDATE DATABASE (primary)

SWITCHOVER TO β€˜<standby>’ executed

Verify roles in SQL on both nodes

Verify app/services on new primary

Confirm broker shows expected primary/standby roles

Save outputs and timestamps

Β 

C) Failover Drill (Controlled)

Confirm failover trigger criteria (primary unreachable / simulated incident)

VALIDATE DATABASE β€˜<target>’

FAILOVER TO β€˜<target>’ executed

Verify target is PRIMARY and open read/write

Confirm broker messages indicate reinstate needed for old primary

Capture all outputs, alert logs, and drill notes

Β 

D) After Drill

Confirm application fully stable

Confirm protection mode and transport settings

Plan reinstate/rebuild steps for old primary (if failover done)

Send DR drill summary (what changed, what verified, evidence links)

Update DR runbook with lessons learned

Β 

Β 

    About Syed Saad

    With 16 years of experience as a certified and skilled Oracle Database Administrator, I possess the expertise to handle various levels of database maintenance tasks and proficiently perform Oracle updates. Throughout my career, I have honed my analytical abilities, enabling me to swiftly diagnose and resolve issues as they arise. I excel in planning and executing special projects within time-sensitive environments, showcasing exceptional organizational and time management skills. My extensive knowledge encompasses directing, coordinating, and exercising authoritative control over all aspects of planning, organization, and successful project completions. Additionally, I have a strong aptitude for resolving customer relations matters by prioritizing understanding and effective communication. I am adept at interacting with customers, vendors, and management, ensuring seamless communication and fostering positive relationships.

    Check Also

    ORA-15041: Diskgroup DATA Space Exhausted

    ORA-15041: Diskgroup “DATA” Space Exhausted β€” How to Diagnose & Fix the Issue When working …

    Leave a Reply