Data Guard Basics: Primary and Standby Databases
What is Data Guard?
Data Guard keeps one or more standby databases in sync with the primary by sending it the redo. If the primary fails, a standby takes over in minutes, with little or no data loss.
Simple example: The primary is the main office. The standby is an identical office in another city, receiving a copy of every change. If the main office burns down, staff move to the other office and work continues.
The Parts
| Part | Role |
|---|---|
| Primary database | Serves users and generates redo |
| Standby database | A copy that continuously applies the redo |
| Redo transport | Sends redo from primary to standby (LGWR or ARCn) |
| Redo apply (MRP) | Applies the redo on the standby |
| Broker (DGMGRL) | Command-line tool that manages the configuration |
Types of Standby
| Type | Description |
|---|---|
| Physical standby | Exact block-for-block copy, kept by redo apply. The most common. |
| Active Data Guard | Physical standby that is open read-only while applying redo (extra-cost option) |
| Logical standby | Applies SQL instead of redo. Rarely used today. |
Protection Modes
| Mode | Data loss | Impact on primary |
|---|---|---|
| Maximum Performance | Possible, tiny | No wait for the standby. Default. |
| Maximum Availability | Zero when the standby is reachable | Commits wait for the standby (SYNC) |
| Maximum Protection | Zero, always | Primary shuts down if it cannot reach a standby |
Switchover vs Failover
| Switchover | Failover | |
|---|---|---|
| When | Planned (maintenance, patching) | Primary is lost |
| Data loss | None | Maybe, depending on mode |
| Roles | Primary and standby swap | Standby becomes the new primary |
| Old primary | Becomes a standby | Must be rebuilt or reinstated |
Check the Role
sql
SELECT name, database_role, open_mode, protection_mode, switchover_status
FROM v$database;
Manage with the Broker
bash
dgmgrl sys@primary_db
DGMGRL> SHOW CONFIGURATION;
DGMGRL> SHOW DATABASE standby_db;
DGMGRL> VALIDATE DATABASE standby_db;
DGMGRL> SWITCHOVER TO standby_db; -- planned
DGMGRL> FAILOVER TO standby_db; -- emergency
Is the Standby in Sync?
sql
-- on the standby
SELECT name, value, time_computed
FROM v$dataguard_stats
WHERE name IN ('transport lag','apply lag');
Monitor: Alert when apply lag passes a few minutes. A standby that is hours behind is not a safe disaster plan.
Setup Steps (Overview)
- Primary runs in ARCHIVELOG with force logging:
ALTER DATABASE FORCE LOGGING; - Create standby redo logs on both sides.
- Duplicate the primary with
RMAN DUPLICATE ... FOR STANDBY FROM ACTIVE DATABASE. - Configure redo transport and start redo apply.
- Create the broker configuration.
Practice: Data Guard needs two servers or containers. Oracle Free is limited, so practice the broker commands in a lab or in Oracle Cloud, and read the Data Guard Concepts guide for the full setup.
Conclusion
Data Guard keeps a live copy of your database elsewhere. Know the three protection modes, the difference between switchover and failover and watch lag.
Quick Summary: Standby = copy fed by redo. Switchover = planned swap. Failover = emergency takeover.

