Overview

Oracle Data Guard maintains one or more standby databases by shipping and applying the redo of a primary database. It provides disaster recovery, high availability and (Active Data Guard) read offload. It requires ARCHIVELOG mode (oracle-rman-backup).

Note

Data Guard needs two instances and, for some features, Enterprise Edition options. It was not executed in the Free test container; this note is based on Oracle documentation.

Core concepts

  • Physical standby: block-identical copy kept current by redo apply (managed recovery); logical standby applies SQL (rare). A standby can be opened read-only while applying redo with the Active Data Guard option.
  • Redo transport: SYNC (primary waits until the standby has written redo), ASYNC, and Far Sync instances to relay redo over long distances without affecting the primary.
  • Protection modes: Maximum Performance (async, no commit delay), Maximum Availability (sync, falls back to async if the standby is unreachable), Maximum Protection (sync; the primary stops if no standby acknowledges).
  • Switchover = planned role swap, no data loss; failover = standby takes over after the primary fails. Fast-Start Failover with an observer automates it; the Data Guard broker (DGMGRL) manages the configuration.
  • Standby maintenance: lag views V$DATAGUARD_STATS, V$ARCHIVE_GAP; standby redo logs receive redo in real time. A snapshot standby opens read-write for testing and then returns.
  • Compare: PostgreSQL streaming replication (pg-replication-failover), SQL Server Always On (sqlserver-always-on); RAC (oracle-rac) protects against instance failure, Data Guard against site or storage failure; they combine as Maximum Availability Architecture (MAA).

Worked example

Broker commands from the documentation (not executed):

DGMGRL> CREATE CONFIGURATION dg_conf AS PRIMARY DATABASE IS prod CONNECT IDENTIFIER IS prod;
DGMGRL> ADD DATABASE stby AS CONNECT IDENTIFIER IS stby MAINTAINED AS PHYSICAL;
DGMGRL> ENABLE CONFIGURATION;
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability;
DGMGRL> VALIDATE DATABASE stby;
DGMGRL> SWITCHOVER TO stby;

Lag check on the standby:

SELECT name, value, time_computed FROM v$dataguard_stats WHERE name IN ('transport lag', 'apply lag');

Pitfalls and production notes

  • Test switchover regularly and measure the real recovery time; document client reconnection (Fast Application Notification, connection descriptors with FAILOVER).
  • A standby is not a backup: a logical corruption or a dropped table replicates quickly. Combine with backups and flashback (a delayed apply or Flashback Database on the standby helps) (oracle-flashback).
  • Network bandwidth must exceed the peak redo rate (see Redo size in oracle-awr-ash).
  • Keep primary and standby at compatible patch levels; Data Guard Standby-First patching allows rolling updates (oracle-patching-upgrades).
  • Monitor the observer and have it run on a third host.

Practice questions

  1. Which protection mode can stop the primary and when would you accept that?
  2. How does Active Data Guard differ from a plain physical standby?
  3. Why are standby redo logs recommended?

References

  • Oracle Data Guard Concepts and Administration

oracle-rman-backup · oracle-rac · oracle-flashback · pg-replication-failover · sqlserver-always-on