Role Transitions in Oracle Data Guard

ADVERTISEMENT

Seamlessly switch roles between primary and standby databases to ensure high availability and disaster recovery.

What is a Role Transition?

In Oracle Data Guard, a Role Transition is when the role of a Primary database and one of its Standby databases is swapped or promoted, depending on the situation:

  • 🔁 Switchover → Planned, no data loss
  • Failover → Unplanned, recovery after failure

1. Introduction to Role Transitions

Oracle Data Guard allows either:

  • The Primary database to become a Standby, and
  • A Standby to take over as the Primary.

This helps maintain zero or minimal downtime during:

  • Maintenance
  • Disaster Recovery
  • Planned migration or upgrades

2. Preparing for a Role Transition

Before performing a role transition:

✅ Ensure:

  • The standby is fully synchronized
  • All configurations are correct
  • Flashback Database is enabled (for reversibility)
  • Monitoring tools (like dgmgrl or OEM) are in place

Use:

SELECT SWITCHOVER_STATUS FROM V$DATABASE;

If the result is TO STANDBY or TO PRIMARY, it’s ready.

3. Choosing the Target Standby for Role Transition

If you have multiple standby databases, choose one based on:

  • ✔️ Sync level (real-time or lagging?)
  • ✔️ Location (same region or DR site?)
  • ✔️ Performance capacity
  • ✔️ Recovery time objective (RTO)

👉 Use Data Guard Broker (dgmgrl) to get health and sync status of each standby.

🔁 4. Switchovers

A planned role transition — no data loss.

  • Performed when both primary and standby are healthy
  • Reversible
  • Used during patching, upgrades, or testing DR setups

✨ Steps:

  1. Verify readiness
  2. Issue switchover command
  3. Monitor the transition
  4. Confirm new roles
DGMGRL> SWITCHOVER TO standby_db;

5. Failovers

An unplanned role transition — usually due to primary failure.

  • Performed when the primary is not accessible
  • May involve data loss (depending on protection mode)
  • Cannot automatically go back to original state without reinstating

Steps:

  1. Confirm primary is inaccessible
  2. Promote the best standby
  3. Reinstate the original primary later (if recoverable)
DGMGRL> FAILOVER TO standby_db;

⚙️ 6. Role Transition Triggers

Role transitions can be:

Trigger TypeExample Scenario
ManualDBA initiates switch/failover during patching
AutomaticData Guard Fast-Start Failover (FSFO) detects primary crash
ScriptedVia shell or OEM automation

7. Transitions with Physical Standby

🔄 Switchover to Physical Standby:

  • MRP must be stopped
  • Redo apply must be in sync
  • Very fast transition

❗ Failover to Physical Standby:

  • Use ACTIVATE STANDBY DATABASE
  • May require applying missing logs
  • Reinstate primary if Flashback is enabled

8. Transitions with Logical Standby

🔄 Switchover to Logical Standby:

  • SQL Apply must be stopped
  • May require checking data compatibility
  • More flexible, but slightly slower

❗ Failover to Logical Standby:

  • Use ALTER DATABASE ACTIVATE LOGICAL STANDBY DATABASE
  • Ensure standby is fully caught up

⚠️ Not all failovers are supported for Logical Standby if major DDL differences exist.

9. Using Flashback Database After Role Transition

Flashback allows you to reverse role transitions quickly:

ScenarioUse Flashback?Command Example
After Switchover✅ YesFLASHBACK DATABASE TO SCN;
After Unsuccessful Failover✅ YesRestore original primary without rebuild
Flashback for testing✅ YesSafely simulate transitions

Requirements:

  • Flashback must be enabled
  • Fast recovery area configured

✅ Summary Table

OperationPlanned?Data Loss?Used WhenReversible?
Switchover✅ Yes❌ NoMaintenance, patching, testing✅ Yes
Failover❌ No⚠️ PossibleCrash, corruption, DR failover❌ No (unless flashback enabled)

ADVERTISEMENT