Disaster Recovery with Oracle Data Guard

Disaster Recovery with Oracle Data Guard in Oracle Database: While Oracle RAC protects against hardware failure of individual servers within a single data…

While Oracle RAC protects against hardware failure of individual servers within a single data center, Oracle Data Guard provides complete business continuity across geographic regions, protecting against data center outages, natural disasters, and site failures.


Data Guard Architecture

Data Guard maintains one or more synchronized standby copies of the production database (Primary Database) at remote locations:

[ PRIMARY DATA CENTER (US-East) ]           [ DISASTER RECOVERY SITE (EU-West) ]
        [ Primary Database ]                               [ Standby Database ]
                 |                                                  |
           (Generates Redo)                                   (Applies Redo)
                 |                                                  |
                 v                                                  ^
          [ LGWR / NSS ] ─── Encrypted Redo Transport (WAN) ───> [ RFS Process ]
                                                                    |
                                                                    v
                                                            [ Standby Redo Logs ]
                                                                    |
                                                                    v
                                                             [ MRP0 Process ]
  1. Transactions commit on the Primary Database, generating redo entries.
  2. The network transport service (NSS / LNS) streams redo over WAN to the remote standby.
  3. The Remote File Server (RFS) process on the standby receives the redo and writes it to Standby Redo Logs.
  4. The Managed Recovery Process (MRP0) applies redo to the physical database blocks.

Protection Modes

Protection ModeRedo TransportData Loss (RPO)Description
Maximum PerformanceASYNCMinimal (seconds)Commits return immediately on primary without waiting for network ACK. Zero latency impact.
Maximum AvailabilitySYNCZero (under normal WAN)Commits wait for ACK from standby. Falls back to ASYNC if standby is temporarily unreachable.
Maximum ProtectionSYNCAbsolute Zero GuaranteedPrimary database will intentionally halt and shut down if the last standby cannot acknowledge redo.

Active Data Guard: Real-Time Reporting

In standard Data Guard, a physical standby applying redo is kept in a closed recovery state. Active Data Guard enables the standby to be opened in READ-ONLY mode while redo apply continues in real time:

-- Verify database role and open mode
SELECT database_role, open_mode, protection_mode FROM v$database;
-- Primary: PRIMARY | READ WRITE | MAXIMUM AVAILABILITY
-- Standby: PHYSICAL STANDBY | READ ONLY WITH APPLY | MAXIMUM AVAILABILITY

-- Check real-time replication lag
SELECT name, value, time_computed
FROM v$dataguard_stats
WHERE name IN ('transport lag', 'apply lag');

Switchover vs Failover

  • Switchover: Planned role reversal (e.g., for scheduled hardware maintenance). Zero data loss; primary becomes standby, and standby becomes primary seamlessly.
  • Failover: Unplanned emergency transition when the primary site is destroyed. The standby becomes primary. Fast-Start Failover (FSFO) automates this in under 30 seconds via an independent observer process.

Exercises

  1. Write a monitoring script using V$DATAGUARD_STATS that alerts if apply lag exceeds 60 seconds.
  2. Explain how Active Data Guard offloads heavy analytical reporting workloads from production.
  3. What is the role of the Data Guard Observer in automated Fast-Start Failover (FSFO)?