Oracle Data Guard: Features, Configuration & Best Practices

ADVERTISEMENT

Oracle Data Guard is a powerful feature for database high availability, disaster recovery, and data protection. This guide provides a detailed walkthrough of its features, types of standby databases, processes involved, configuration steps, and key commands. By the end of this post, you’ll have a deep understanding of Oracle Data Guard and how to manage it efficiently.

Main Uses of Standby Databases

Use CaseDescription
High AvailabilityEnsures continuous availability of the database.
Data ProtectionSafeguards data through redundancy.
Disaster RecoveryProvides recovery options during catastrophic events.
Backup ManagementFacilitates backups from standby databases.
ReportingOffloads reporting tasks to standby databases.

Types of Standby Databases

TypeDescription
Physical Standby– Exact block-for-block copy of the primary database.
– Maintained using REDO-APPLY.
Logical Standby– Converts data from the primary into SQL statements.
– Maintained using SQL-APPLY (LSP process applies redo).
Snapshot Standby– A fully updatable standby database converted from a physical standby.
Cascaded Standby– Receives redo logs from another standby to reduce primary system load.
Active Data Guard– Physical standby in read-only mode while applying redo.
– Enables reporting and RMAN backups on standby, offloading production load.
Transient Logical Standby– Supports rolling database upgrades by temporarily converting a physical standby to a logical standby.

Redo Transport Services

TypeDescription
Synchronous– Guarantees Zero Data Loss.
– Primary commits changes only after LNS confirms redo write on standby.
Asynchronous– Does not guarantee Zero Data Loss.
LGWR does not wait for LNS confirmation.

Apply Services

TypeDescription
Real-time Apply– Used in physical standby databases.
– Applies changes as they are received without waiting for archiving.
SQL Apply– Converts redo data into SQL statements and applies them on a logical standby database.

Role Transitions

TypeDescription
Switchover– Switches roles between primary and standby.
– No data loss occurs.
Failover– Promotes standby to primary in case of primary failure.
– Risk of data loss if in MAXIMUM performance mode.

Affirm and Noaffirm

TypeDescription
Affirm– Ensures redo is written to the standby’s disks.
Noaffirm– Ensures redo is received by one of the standby databases.

Protection Modes

ModeTransport MethodDescription
Maximum ProtectionSYNC / LGWR– Guarantees Zero Data Loss.
– Shuts down primary if redo cannot be written to standby.
Maximum AvailabilitySYNC / LGWR– Operates like MAXIMUM PROTECTION but allows primary to continue if standby synchronization fails temporarily.
Maximum PerformanceASYNC / LGWR / ARCH– Focuses on performance, with minimal data loss in normal operation.

Physical Standby Database Related Processes

DatabaseProcessDescription
Primary DatabaseLGWRLog Writer flushes log buffers from the SGA to Online Redo Log files.
LNSLogWriter Network Service reads redo flushed by LGWR and sends it over the network to the standby.
ARCHArchives Online Redo Log (ORL) files to archive log files.
Standby DatabaseRFSRemote File Server receives redo from the primary, writes it to Standby Redo Log (SRL) files.
ARCHArchives SRL files into archived log files, similar to primary database.
MRPManaged Recovery Process coordinates media recovery management.

Data Guard Broker Configuration

StepDescription
PurposeProvides unified administration for Data Guard, including switchover and failover.
Configuration FilesMaintains information in flat files, with redundant copies stored on each database in the Data Guard configuration.
ParametersControlled by:
DG_BROKER_CONFIG_FILE_1
DG_BROKER_CONFIG_FILE_2.

Configuration Steps

StepCommands/Actions
1. Configure ParametersPrimary:
ALTER SYSTEM SET dg_broker_config_file_1='path';
ALTER SYSTEM SET dg_broker_config_file_2='path';
ALTER SYSTEM SET dg_broker_start=TRUE SCOPE=BOTH;
ALTER SYSTEM SET local_listener='';
Standby:
Repeat the same steps on the standby database.
2. Verify TNSEnsure connectivity between the primary (tns_prod) and standby (tns_stby).
3. Configure DGMGRLCommands:
dgmgrl
CONNECT sys/password@tns_prod
CONNECT sys/password@tns_stby
SHOW CONFIGURATION
4. Create ConfigurationPrimary:
CREATE CONFIGURATION 'PROD' AS PRIMARY DATABASE IS 'PROD_DB' CONNECT IDENTIFIER IS 'tns_prod';
Ensure LOG_ARCHIVE_DEST_2 is empty.
5. Add StandbyADD DATABASE 'DR' AS CONNECT IDENTIFIER IS 'DR';
6. Enable ConfigurationENABLE CONFIGURATION;

Switchover and Switchback Commands Using DGMGRL

ActionCommand
Perform Switchover to StandbySWITCHOVER TO DR;
Convert Standby to Snapshot StandbyCONVERT DATABASE 'DR' TO SNAPSHOT STANDBY;
Convert Back to Physical StandbyCONVERT DATABASE 'DR' TO PHYSICAL STANDBY;

Useful Commands to Show Data Guard Configuration

CommandDescription
SHOW CONFIGURATION;Displays the overall Data Guard configuration.
SHOW CONFIGURATION VERBOSE;Provides detailed information about the configuration.
SHOW DATABASE 'PRIM';Displays details of the primary database.
SHOW DATABASE VERBOSE 'PRIM';Provides detailed information about the primary database.
VALIDATE DATABASE 'PRIM';Validates the primary database setup.
VALIDATE DATABASE VERBOSE 'PRIM';Provides detailed validation output for the primary database.
SHOW DATABASE 'PRIM' SENDQENTRIES;Shows the send queue entries for the primary database.
SHOW DATABASE 'DR' RECVQENTRIES;Shows the receive queue entries for the standby database.
VALIDATE NETWORK CONFIGURATION FOR ALL;Validates the network configuration for all databases

Edit Database Properties

ActionCommand
Disable Apply ModeEDIT DATABASE 'DR' SET STATE='APPLY-OFF';
Disable Transport ModeEDIT DATABASE 'DR' SET STATE='TRANSPORT-OFF';
Enable Apply ModeEDIT DATABASE 'DR' SET STATE='APPLY-ON';
Enable Transport ModeEDIT DATABASE 'DR' SET STATE='TRANSPORT-ON';

Change Protection Mode

ActionCommand
Change Log Transport to SynchronousEDIT DATABASE 'chennai' SET PROPERTY 'LogXptMode'='SYNC';
EDIT DATABASE 'delhi' SET PROPERTY 'LogXptMode'='SYNC';
Set Protection Mode to Max AvailabilityEDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;

Enable Fast-Start Failover

StepCommand
Ensure Protection ModeSet to MAX AVAILABILITY.
Enable Fast-Start FailoverENABLE FAST_START FAILOVER;
Show Fast-Start Failover StatusSHOW FAST_START FAILOVER;
Start Observernohup dgmgrl sys/oracle@orcl "start observer file='/home/oracle/fsfo.dat'" -logfile $HOME/observer.log &

ADVERTISEMENT

You might like

Leave a Reply

Your email address will not be published. Required fields are marked *