Disclaimer

Sunday, 4 October 2026

Oracle Data Guard Switchover and Failover in OCI

 

Oracle Data Guard Switchover and Failover in OCI

Oracle Data Guard is a high availability and disaster recovery solution that maintains one or more synchronized standby databases for a production (primary) database. In Oracle Cloud Infrastructure (OCI), Data Guard operations such as Switchover, Failover, and Reinstate can be performed using the dbaascli utility, making database role transitions simple and automated.


Environment Details


Understanding Oracle Data Guard

Oracle Data Guard protects databases against:

  • Hardware failures
  • Storage failures
  • Site outages
  • Planned maintenance activities
  • Human errors

A Data Guard configuration consists of:

Primary Database

The production database that receives all read-write transactions.

Physical Standby Database

An exact block-by-block copy of the primary database that continuously receives and applies redo from the primary.

Redo Transport Services

Transfers redo generated on the primary to the standby.

Redo Apply Services

Applies redo on the standby database to keep it synchronized.



Switchover

What is a Switchover?

A Switchover is a planned role reversal between the primary and standby databases with zero or minimal downtime and no data loss.

Common Use Cases

  • Operating system patching
  • Database upgrades
  • Exadata maintenance
  • Data center migration
  • Planned DR testing

Role Transition

Before Switchover:

Primary  : ORCL

Standby  : ORCLDG

After Switchover:

Primary  : ORCLDG
Standby  : ORCL



OCI Data Guard Switchover: ORCL (Primary) to ORCLDG (Primary)


Step 1: Verify Data Guard Association

List the Data Guard associations:

dbscli list-dataguard-associations

Note the Data Guard Association ID.

Step 2: Check Data Guard Details
dbscli get-dataguard-association --dataguard-association-id <dg_id>

Validate:

  • Primary Database = ORCL
  • Standby Database = ORCLDG
  • Protection Mode
  • Transport Status
  • Apply Status
  • Overall Health = SUCCESS

Step 3: Connect to the Current Primary Host and Execute Switchover

dbaascli dataguard switchover \
--dbname ORCL \
--targetStandbyDBUniqueName ORCLDG \
--waitForCompletion true



The command performs:

  1. Synchronizes remaining redo.
  2. Stops Primary services on ORCL.
  3. Converts ORCLDG to Primary.
  4. Converts ORCL to Physical Standby.
  5. Starts Data Guard services automatically.



Step 5: Monitor Progress

Check operation status:

dbaascli job list

View detailed job information:
dbaascli job getDetails --jobID <job_id>

Step 6: Validate New Roles

SELECT DATABASE_ROLE, OPEN_MODE FROM V$DATABASE;

DATABASE_ROLE : PRIMARY
OPEN_MODE     : READ WRITE


Step 7: Verify Data Guard Synchronization
Check Data Guard statistics:
SELECT NAME, VALUE FROM V$DATAGUARD_STATS;


===============================================================

FAILOVER and REINSTATE in OCI Data Guard

Objective

Perform a Failover when the Primary database becomes unavailable and then Reinstate the failed Primary database to restore the Data Guard configuration.



Initial Configuration

Before Failover


Primary  : ORCL
Standby  : ORCLDG


Step 1: Perform Failover

When to Use Failover

Failover is performed when:

  • Primary database is unavailable.
  • Server crash.
  • Storage failure.
  • Site failure.
  • Database cannot be recovered within acceptable business timelines.

Unlike Switchover, Failover is an emergency operation.


Execute Failover

Run the following command on the standby environment:


dbaascli dataguard failover \
--dbname ORCL \
--useImmediateFailover \

--waitForCompletion true

Result of Failover

Before:

ORCL    = Primary
ORCLDG  = Standby


After:
ORCLDG  = Primary
ORCL    = Failed Primary

Validation After Failover

Connect to ORCLDG and verify:


SELECT DATABASE_ROLE, OPEN_MODE FROM V$DATABASE;


Step 2: Reinstate the Failed Primary

What is Reinstate?

After a Failover, the original Primary database cannot automatically rejoin the configuration.

Reinstate converts the failed Primary database into a Physical Standby and restores Data Guard protection.

Reinstate Works Only If

✅ Flashback Database is enabled

Without Flashback Database, a full standby rebuild may be required.


Current State After Failover
ORCLDG = PRIMARY
ORCL   = FAILED PRIMARY

Goal:
ORCLDG = PRIMARY
ORCL   = PHYSICAL STANDBY


Method A: Reinstate Using DGMGRL

Connect to the database:
dgmgrl /


Check current configuration:

DGMGRL> show configuration;

Example:
Configuration - DG_CONFIG
  Protection Mode: MaxPerformance
  Members:
  ORCLDG - Primary database
  ORCL   - Disabled
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS


Reinstate ORCL:

DGMGRL> reinstate database 'ORCL';

Expected Output:
Reinstating database "ORCL", please wait...
Operation succeeded.


Verify:
DGMGRL> show configuration;

Expected:
ORCLDG - Primary database
ORCL   - Physical standby database


Method B: Reinstate Using dbaascli

Connect to the ORCL server.

Set Oracle environment:


export ORACLE_SID=ORCL

Execute Reinstate:

dbaascli dataguard reinstate \
--dbname ORCL \
--primaryDBUniqueName ORCLDG \
--waitForCompletion true

Note: After failover, ORCLDG is the new Primary. Therefore --primaryDBUniqueName should point to ORCLDG.

Final State After Reinstate

Primary  : ORCLDG
Standby  : ORCL







No comments:

Post a Comment

End-to-End Data Guard Recovery: Standby Controlfile Restore, Catalog, Switch Database to Copy, and MRP Restart

  To perform this operation safely on a  Production environment , you must execute these steps in a precise, logical sequence. Since you are...