Oracle Data Guard Complete Tutorial: Architecture, Configuration, Commands, Monitoring, Troubleshooting and Interview Questions

Oracle Data Guard – Complete Guide for Oracle DBAs

Oracle Data Guard is one of the most important topics for an Oracle Database Administrator working in production environments. It is widely used in banking, financial services, telecom, healthcare and enterprise applications to provide High Availability (HA), Disaster Recovery (DR) and data protection.

This tutorial covers Oracle Data Guard from basic concepts to advanced production-level administration. It includes architecture, background processes, configuration, RMAN commands, SQL commands, DGMGRL commands, monitoring, troubleshooting and scenario-based interview questions.

The examples primarily use Oracle Database 19c syntax. Most concepts also apply to later releases, but always validate commands and features against your installed Oracle version.

Table of Contents

  1. What is Oracle Data Guard?
  2. Why do we need Data Guard?
  3. Data Guard architecture
  4. Primary and standby database
  5. Data Guard background processes
  6. Redo transport and redo apply
  7. Types of standby databases
  8. Data Guard protection modes
  9. Important initialization parameters
  10. Step-by-step physical standby configuration
  11. Standby Redo Logs configuration
  12. Starting and stopping Redo Apply
  13. Data Guard Broker configuration
  14. Switchover and failover
  15. Monitoring commands for Oracle DBAs
  16. Replication lag and archive gap troubleshooting
  17. Common production issues and solutions
  18. Data Guard versus RAC
  19. Data Guard interview questions and answers
  20. Advanced scenario-based interview questions
  21. Daily DBA health-check checklist
  22. Important commands cheat sheet

1. What Is Oracle Data Guard?

Oracle Data Guard is an Oracle Database high availability and disaster recovery solution.

It maintains one or more synchronized copies of a production database, called standby databases.

The production database is called the Primary Database, and its synchronized copy is called the Standby Database.

When transactions are executed on the primary database, Oracle generates redo information. This redo information is transported to the standby database and applied there.

If the primary database fails, the standby database can take over the production role through a failover operation.

Simple example

Consider a banking organization:

DatabaseLocationRole
PRODDBMumbai Data CenterPrimary
DRDBHyderabad Data CenterPhysical Standby

The production database processes all banking transactions.

The DR database receives redo information from PRODDB and applies it continuously.

If the Mumbai data center becomes unavailable, the DBA can activate DRDB as the new production database.

Important points

  • Primary database handles production transactions.
  • Standby database maintains a synchronized copy.
  • Redo Transport sends redo information.
  • Redo Apply applies redo information.
  • Switchover performs a planned role transition.
  • Failover performs an unplanned role transition.

2. Why Do We Need Oracle Data Guard?

The major objectives are:

High Availability: Reduce database downtime during failures.

Disaster Recovery: Maintain a database at a remote location.

Data Protection: Protect committed transactions against data loss according to the configured protection mode.

Business Continuity: Continue business operations after a database or site failure.

Reporting: Offload read-only workloads to an eligible standby database.

Planned Maintenance: Perform certain maintenance operations with reduced downtime using role transitions.

Real-world banking example

Suppose a banking application processes 10,000 transactions per minute.

If the primary database server crashes, business operations may stop.

With Data Guard, a standby database is available at the DR location. Depending on the protection mode and the redo successfully received, the DBA can perform a failover and restore database services.

3. Oracle Data Guard Architecture

Oracle Data Guard has two major components:

  1. Redo Transport Services.
  2. Redo Apply Services.

Architecture flow

Application transactions execute on the primary database.

The redo information is generated and transported to the standby database.

The standby database receives redo information through the RFS process and applies it using Redo Apply.

Simplified architecture:

            APPLICATION

                |

                |

          PRIMARY DB

                |

          Online Redo Logs

                |

            LGWR / LNS

                |

          REDO TRANSPORT

                |

          Network / Oracle Net

                |

                RFS

                |

        Standby Redo Logs

                |

                MRP

                |

            STANDBY DB

Understand the complete flow

Step 1: Application executes INSERT, UPDATE or DELETE statements on the primary database.

Step 2: Oracle generates redo records.

Step 3: LGWR writes redo from the redo log buffer into online redo logs.

Step 4: Redo transport processes send redo information to the standby database.

Step 5: RFS receives the redo information on the standby.

Step 6: RFS writes received redo into Standby Redo Logs when configured.

Step 7: MRP applies the redo information to the physical standby database.

Step 8: The standby database is synchronized according to the redo transport and apply status.

4. Important Data Guard Terminology

TermMeaning
Primary DatabaseProduction database
Standby DatabaseSynchronized copy of primary
Redo DataInformation required to reproduce database changes
Redo TransportSending redo from primary to standby
Redo ApplyApplying redo on standby
Online Redo LogsRedo logs used by primary
Standby Redo LogsLogs used to receive redo on standby
Archive LogsArchived copies of filled redo logs
SwitchoverPlanned role transition
FailoverUnplanned role transition
Data Guard BrokerCentralized Data Guard management
FALFetch Archive Log mechanism
FSFOFast-Start Failover

5. Oracle Data Guard Background Processes

This is an important interview topic.

5.1 LGWR – Log Writer

LGWR writes redo information from the redo log buffer into online redo log files.

It operates on the primary database.

5.2 LNS – Log Network Server

LNS participates in transporting redo information from the primary database to the standby database.

It is particularly relevant to LGWR-based redo transport.

5.3 RFS – Remote File Server

RFS runs on the standby database.

It receives redo information from the primary database and writes it into standby redo logs or other configured destinations.

5.4 MRP – Managed Recovery Process

MRP applies redo information received by the standby database.

It is associated with Redo Apply on a physical standby database.

5.5 ARCH – Archiver Process

ARCH archives online redo log files and participates in archive-based redo transport.

5.6 DMON – Data Guard Monitor

DMON is associated with Data Guard Broker. It manages broker-related configuration and monitoring activities.

Interview question: Explain LGWR, LNS, RFS and MRP.

Answer:

LGWR writes redo information into the online redo logs on the primary database. LNS transports redo information to the standby database. RFS receives the redo on the standby side and writes it into standby redo logs. MRP applies that redo information to the standby database.

Remember this simplified flow:

Primary: LGWR → LNS → Network

Standby: RFS → Standby Redo Logs → MRP

Actual transport processes depend on the configured transport mechanism and Oracle release.

6. Redo Transport Services

Redo Transport Services transfer redo information from the primary database to the standby database.

There are two commonly discussed transport modes.

6.1 SYNC

SYNC stands for synchronous redo transport.

The primary database waits for acknowledgement from the standby destination according to the configured acknowledgement mode before completing the protected commit.

It is used for strong data protection.

Common attributes:

  • SYNC
  • AFFIRM or NOAFFIRM

With AFFIRM, acknowledgement occurs after redo is written to the standby redo log.

6.2 ASYNC

ASYNC stands for asynchronous redo transport.

The primary database does not wait for the standby to acknowledge every commit.

This reduces commit latency but creates a possibility of data loss if the primary fails before the latest redo reaches the standby.

Comparison

FeatureSYNCASYNC
TransportSynchronousAsynchronous
Primary waits for standby acknowledgementYes, according to acknowledgement configurationNo
Commit latencyCan increaseUsually lower
Network latency impactHigherLower
Typical usageMaximum Protection / AvailabilityMaximum Performance

Example LOG_ARCHIVE_DEST_2 configuration

Synchronous:

ALTER SYSTEM SET LOG_ARCHIVE_DEST_2 =

‘SERVICE=DRDB ASYNC=NO

LGWR SYNC AFFIRM

VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

DB_UNIQUE_NAME=DRDB’

SCOPE=BOTH;

Asynchronous:

ALTER SYSTEM SET LOG_ARCHIVE_DEST_2 =

‘SERVICE=DRDB ASYNC

LGWR ASYNC

VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

DB_UNIQUE_NAME=DRDB’

SCOPE=BOTH;

These are illustrative configurations. Validate transport attributes, service names and protection-mode requirements before applying them in production.

7. Types of Standby Databases

Oracle Data Guard supports three main standby database types.

7.1 Physical Standby

A physical standby database maintains a physical copy of the primary database.

It uses Redo Apply to keep the database synchronized.

Features:

  • Block-for-block physical copy.
  • Supports Redo Apply.
  • Suitable for disaster recovery.
  • Can be opened read-only in an eligible Active Data Guard configuration.

Check database role:

SELECT NAME, DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE

FROM V$DATABASE;

7.2 Logical Standby

A logical standby database maintains logical data consistency rather than a physical block-for-block copy.

It uses SQL Apply.

Features:

  • Supports logical transformations.
  • Supports certain reporting workloads.
  • Uses SQL Apply to process changes.

7.3 Snapshot Standby

A snapshot standby is a temporary read-write standby database.

It can be used for:

  • Testing.
  • Development.
  • Patch validation.
  • Application testing.

Changes made during snapshot standby operation are discarded when it is converted back to a physical standby, after which accumulated redo can be applied.

Example Broker commands:

DGMGRL> CONVERT DATABASE ‘DRDB’

      TO SNAPSHOT STANDBY;

DGMGRL> CONVERT DATABASE ‘DRDB’

      TO PHYSICAL STANDBY;

8. Oracle Data Guard Protection Modes

There are three main protection modes.

8.1 Maximum Protection

Provides the highest level of data protection.

It requires synchronous redo transport with the required standby acknowledgement.

If the required protection cannot be maintained, the primary database shuts down rather than continue without the configured protection.

Use case: Critical financial applications where zero data loss is mandatory.

8.2 Maximum Availability

Provides zero data loss under normal operating conditions while maintaining primary availability.

It uses synchronous redo transport.

If the standby destination becomes unavailable, the primary can continue processing transactions after the applicable timeout and protection behavior takes effect.

Use case: Banking and business-critical systems.

8.3 Maximum Performance

Prioritizes primary database performance.

It typically uses asynchronous redo transport.

Some redo may not have reached the standby when the primary fails.

Use case: Applications where performance is important and some data loss may be acceptable.

Protection mode comparison

FeatureMaximum ProtectionMaximum AvailabilityMaximum Performance
TransportSYNCSYNCUsually ASYNC
Main objectiveHighest protectionProtection + availabilityPerformance
Data lossZeroZero in normal protected operationPossible
Primary behavior on standby failureShuts down if required protection is lostCan continue after timeoutContinues
Typical useCritical financial systemsBusiness-critical systemsPerformance-sensitive systems

Command to check protection mode

SELECT

  PROTECTION_MODE,

  PROTECTION_LEVEL,

  DATABASE_ROLE,

  SWITCHOVER_STATUS

FROM V$DATABASE;

9. Important Initialization Parameters

These parameters are frequently asked in Oracle DBA interviews.

9.1 DB_NAME

The DB_NAME identifies the database.

For a primary and physical standby database, DB_NAME is normally the same.

9.2 DB_UNIQUE_NAME

Identifies each database uniquely within the Data Guard configuration.

Example:

Primary:

DB_NAME=PROD

DB_UNIQUE_NAME=PROD

Standby:

DB_NAME=PROD

DB_UNIQUE_NAME=DRPROD

9.3 LOG_ARCHIVE_CONFIG

Defines the Data Guard configuration members.

Example:

ALTER SYSTEM SET LOG_ARCHIVE_CONFIG =

‘DG_CONFIG=(PROD,DRPROD)’

SCOPE=BOTH;

9.4 LOG_ARCHIVE_DEST_1

Configures a local archive destination.

9.5 LOG_ARCHIVE_DEST_2

Configures a remote redo transport destination.

Example:

ALTER SYSTEM SET LOG_ARCHIVE_DEST_2 =

‘SERVICE=DRPROD ASYNC

VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

DB_UNIQUE_NAME=DRPROD’

SCOPE=BOTH;

9.6 LOG_ARCHIVE_DEST_STATE_2

Enables or disables the configured destination.

ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE

SCOPE=BOTH;

9.7 FAL_SERVER

Defines the Oracle Net service used by a standby database to request missing archived redo logs.

Example:

ALTER SYSTEM SET FAL_SERVER=’PROD’

SCOPE=BOTH;

9.8 DB_FILE_NAME_CONVERT

Used to convert primary data file paths into standby data file paths when required.

9.9 LOG_FILE_NAME_CONVERT

Used to convert primary online redo log paths into standby log paths when required.

9.10 STANDBY_FILE_MANAGEMENT

Controls automatic creation of standby data files when data files are added on the primary.

ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO

SCOPE=BOTH;

Check parameters

SHOW PARAMETER DB_NAME;

SHOW PARAMETER DB_UNIQUE_NAME;

SHOW PARAMETER LOG_ARCHIVE_CONFIG;

SHOW PARAMETER LOG_ARCHIVE_DEST;

SHOW PARAMETER FAL_SERVER;

SHOW PARAMETER STANDBY_FILE_MANAGEMENT;

10. Step-by-Step Physical Standby Configuration

This is one of the most important practical interview topics.

Let’s configure a physical standby database.

Example environment

ParameterPrimaryStandby
Hostnameprodhostdrhost
DB_NAMEPRODPROD
DB_UNIQUE_NAMEPRODDRPROD
Oracle SIDPRODPROD
RolePrimaryPhysical Standby
Oracle Version19c19c

Both servers should have compatible Oracle software, network connectivity, storage and sufficient resources.

Step 1: Check the primary database

Connect to the primary database:

SELECT NAME, DBID, OPEN_MODE, DATABASE_ROLE

FROM V$DATABASE;

Check ARCHIVELOG mode:

ARCHIVE LOG LIST;

If the database is not in ARCHIVELOG mode, enable it during a planned maintenance window:

SHUTDOWN IMMEDIATE;

STARTUP MOUNT;

ALTER DATABASE ARCHIVELOG;

ALTER DATABASE OPEN;

Step 2: Enable FORCE LOGGING

On the primary database:

ALTER DATABASE FORCE LOGGING;

Verify:

SELECT FORCE_LOGGING

FROM V$DATABASE;

FORCE LOGGING helps ensure that database operations generate redo needed for standby consistency.

Step 3: Set Data Guard parameters on primary

ALTER SYSTEM SET LOG_ARCHIVE_CONFIG =

‘DG_CONFIG=(PROD,DRPROD)’

SCOPE=BOTH;

ALTER SYSTEM SET LOG_ARCHIVE_DEST_2 =

‘SERVICE=DRPROD ASYNC

VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

DB_UNIQUE_NAME=DRPROD’

SCOPE=BOTH;

ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE

SCOPE=BOTH;

Set standby file management:

ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO

SCOPE=BOTH;

Step 4: Configure Oracle Net connectivity

Configure listener and TNS entries on both servers.

Example TNS entry:

PROD =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)

(HOST = prodhost)

(PORT = 1521))

(CONNECT_DATA =

(SERVICE_NAME = PROD))

)

DRPROD =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)

(HOST = drhost)

(PORT = 1521))

(CONNECT_DATA =

(SERVICE_NAME = DRPROD))

)

Test connectivity:

tnsping PROD

tnsping DRPROD

Test remote database authentication:

sqlplus sys@PROD as sysdba

sqlplus sys@DRPROD as sysdba

The remote SYSDBA authentication requires a compatible password file.

Step 5: Prepare the standby initialization parameters

Example standby parameter settings:

DB_NAME=PROD

DB_UNIQUE_NAME=DRPROD

LOG_ARCHIVE_CONFIG=’DG_CONFIG=(PROD,DRPROD)’

LOG_ARCHIVE_DEST_1=

‘LOCATION=/u01/arch

VALID_FOR=(ALL_LOGFILES,ALL_ROLES)

DB_UNIQUE_NAME=DRPROD’

LOG_ARCHIVE_DEST_2=

‘SERVICE=PROD ASYNC

VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)

DB_UNIQUE_NAME=PROD’

FAL_SERVER=PROD

STANDBY_FILE_MANAGEMENT=AUTO

Configure file conversion parameters if the primary and standby use different file paths.

Example:

DB_FILE_NAME_CONVERT=

(‘/u01/oradata/PROD/’,

‘/u02/oradata/PROD/’)

LOG_FILE_NAME_CONVERT=

(‘/u01/oradata/PROD/’,

‘/u02/oradata/PROD/’)

These paths are examples. Use the actual primary and standby storage layout.

Step 6: Create standby using RMAN active duplication

On the standby server, prepare the Oracle environment and start the auxiliary instance in NOMOUNT mode using the standby initialization parameters.

STARTUP NOMOUNT PFILE=’/u01/app/oracle/product/19c/dbhome_1/dbs/initPROD.ora’;

Connect RMAN from a host with connectivity to both databases:

rman target sys@PROD auxiliary sys@DRPROD

Execute:

DUPLICATE TARGET DATABASE

FOR STANDBY

FROM ACTIVE DATABASE

DORECOVER;

RMAN copies the primary database files and creates the standby database.

Important:

  • Verify available network bandwidth.
  • Check storage capacity.
  • Verify password file compatibility.
  • Ensure Oracle Net connectivity.
  • Use appropriate file naming or OMF configuration.
  • Follow the Oracle version-specific RMAN duplication procedure.

Step 7: Verify standby database

On the standby:

SELECT NAME, DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE

FROM V$DATABASE;

Expected role:

DATABASE_ROLE = PHYSICAL STANDBY

Step 8: Configure Standby Redo Logs

Standby Redo Logs are required for real-time redo apply and are strongly recommended for production configurations.

First check the primary online redo log groups:

SELECT GROUP#, THREAD#, BYTES/1024/1024 SIZE_MB

FROM V$LOG

ORDER BY THREAD#, GROUP#;

Check standby redo logs:

SELECT GROUP#, THREAD#, BYTES/1024/1024 SIZE_MB, STATUS

FROM V$STANDBY_LOG

ORDER BY THREAD#, GROUP#;

General sizing rule:

  • Standby Redo Log size should be at least the size of the largest online redo log.
  • Configure at least one more standby redo log group than the number of online redo log groups for each redo thread.

Example:

ALTER DATABASE ADD STANDBY LOGFILE

GROUP 10 (‘/u02/oradata/PROD/srl10.log’) SIZE 500M;

ALTER DATABASE ADD STANDBY LOGFILE

GROUP 11 (‘/u02/oradata/PROD/srl11.log’) SIZE 500M;

ALTER DATABASE ADD STANDBY LOGFILE

GROUP 12 (‘/u02/oradata/PROD/srl12.log’) SIZE 500M;

ALTER DATABASE ADD STANDBY LOGFILE

GROUP 13 (‘/u02/oradata/PROD/srl13.log’) SIZE 500M;

The 500 MB size is illustrative. Use the actual online redo log size and correct number of groups for your environment.

Step 9: Start Redo Apply

On the physical standby:

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE

DISCONNECT FROM SESSION;

This starts Redo Apply in the background.

Step 10: Verify Data Guard synchronization

On standby:

SELECT PROCESS, STATUS, THREAD#, SEQUENCE#

FROM V$MANAGED_STANDBY;

For newer Oracle releases, prefer:

SELECT ROLE, THREAD#, SEQUENCE#, ACTION

FROM V$DATAGUARD_PROCESS;

Check lag:

SELECT NAME, VALUE, UNIT, TIME_COMPUTED

FROM V$DATAGUARD_STATS;

Check database role:

SELECT DATABASE_ROLE, OPEN_MODE

FROM V$DATABASE;

The physical standby configuration is now ready for validation.

11. Standby Redo Logs – Detailed Explanation

This is a frequently asked Oracle DBA interview topic.

What are Standby Redo Logs?

Standby Redo Logs are log files on the standby database that receive redo information directly from the primary database.

They enable real-time redo apply when configured appropriately.

Difference between Online Redo Logs and Standby Redo Logs

Online Redo LogsStandby Redo Logs
Used by primary databaseUsed by standby database
Store primary redoReceive transported redo
Written by primary redo processesWritten by standby receiving processes
Used for instance recoveryUsed for standby redo reception and apply

Why should standby redo logs be larger in number?

They allow the standby to continue receiving redo while previously filled logs are archived and processed.

The usual recommendation is at least one additional standby redo log group per redo thread compared with the online redo log group count.

Interview question: Can Data Guard work without standby redo logs?

Yes, archived-log-based transport and apply can operate without standby redo logs. However, real-time apply requires standby redo logs, so they are strongly recommended for production configurations.

12. Starting and Stopping Redo Apply

Check whether recovery is running

SELECT PROCESS, STATUS, THREAD#, SEQUENCE#

FROM V$MANAGED_STANDBY;

Or:

SELECT ROLE, THREAD#, SEQUENCE#, ACTION

FROM V$DATAGUARD_PROCESS;

Start Redo Apply

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE

DISCONNECT FROM SESSION;

Stop Redo Apply

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Check standby open mode

SELECT OPEN_MODE, DATABASE_ROLE

FROM V$DATABASE;

Important interview point

A physical standby can be mounted while Redo Apply is running.

An eligible Active Data Guard physical standby can be open read-only while Redo Apply continues, subject to licensing and configuration requirements.

13. Oracle Data Guard Broker

Oracle Data Guard Broker simplifies configuration, management and monitoring.

It can be managed using:

  • DGMGRL command-line interface.
  • Oracle Enterprise Manager Cloud Control.

Check Broker status

SHOW PARAMETER DG_BROKER_START;

Enable Broker on both databases:

ALTER SYSTEM SET DG_BROKER_START=TRUE

SCOPE=BOTH;

Connect:

dgmgrl sys@PROD

Create a Broker configuration

DGMGRL> CREATE CONFIGURATION ‘DG_CONFIG’

AS PRIMARY DATABASE IS ‘PROD’

CONNECT IDENTIFIER IS PROD;

Add standby:

DGMGRL> ADD DATABASE ‘DRPROD’

AS CONNECT IDENTIFIER IS DRPROD

MAINTAINED AS PHYSICAL;

Enable configuration:

DGMGRL> ENABLE CONFIGURATION;

Important Broker commands

Show configuration:

DGMGRL> SHOW CONFIGURATION;

Show database:

DGMGRL> SHOW DATABASE VERBOSE ‘PROD’;

Show standby:

DGMGRL> SHOW DATABASE VERBOSE ‘DRPROD’;

Check configuration status:

DGMGRL> SHOW CONFIGURATION VERBOSE;

Enable database:

DGMGRL> ENABLE DATABASE ‘DRPROD’;

Disable database:

DGMGRL> DISABLE DATABASE ‘DRPROD’;

Enable apply:

DGMGRL> EDIT DATABASE ‘DRPROD’ SET STATE=’APPLY-ON’;

Disable apply:

DGMGRL> EDIT DATABASE ‘DRPROD’ SET STATE=’APPLY-OFF’;

Enable transport:

DGMGRL> EDIT DATABASE ‘PROD’ SET STATE=’TRANSPORT-ON’;

Disable transport:

DGMGRL> EDIT DATABASE ‘PROD’ SET STATE=’TRANSPORT-OFF’;

What is the advantage of Broker?

Broker simplifies administration and provides centralized status reporting, role transitions and Fast-Start Failover management.

14. Switchover and Failover

This is one of the most important production DBA interview topics.

14.1 What is Switchover?

Switchover is a planned role transition between primary and standby databases.

The primary becomes standby, and the standby becomes primary.

It is generally performed during:

  • Planned maintenance.
  • Data center migration.
  • Server upgrades.
  • Infrastructure maintenance.
  • DR testing.

Switchover using DGMGRL

Check configuration:

DGMGRL> SHOW CONFIGURATION;

Check target:

DGMGRL> VALIDATE DATABASE ‘DRPROD’;

Perform switchover:

DGMGRL> SWITCHOVER TO ‘DRPROD’;

Verify:

DGMGRL> SHOW CONFIGURATION;

Check database roles:

SELECT DATABASE_ROLE, OPEN_MODE

FROM V$DATABASE;

14.2 What is Failover?

Failover is an unplanned role transition.

It is performed when the primary database becomes unavailable and the standby must take over.

Common reasons:

  • Primary server failure.
  • Data center outage.
  • Storage failure.
  • Severe database corruption.
  • Network or infrastructure disaster.

Failover using DGMGRL

After confirming that the primary cannot be recovered or that disaster recovery procedures require a role transition:

DGMGRL> FAILOVER TO ‘DRPROD’;

Verify:

DGMGRL> SHOW CONFIGURATION;

On the new primary:

SELECT DATABASE_ROLE, OPEN_MODE

FROM V$DATABASE;

Difference between Switchover and Failover

SwitchoverFailover
Planned activityUnplanned activity
Original primary is availableOriginal primary is unavailable or unusable
Usually no data lossData loss may occur
Used for maintenanceUsed during disasters
Can switch back through another switchoverOriginal primary requires reinstatement or rebuilding

Important: Never execute a failover just because the standby has lag. First determine primary availability, the last received and applied redo, data-loss exposure, and the recovery plan. A failover can cause data loss and split-brain risk if the original primary is still processing transactions.

15. Monitoring Commands for Oracle DBAs

A senior Oracle DBA should know these commands.

15.1 Check database role

SELECT NAME, DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE

FROM V$DATABASE;

15.2 Check protection mode

SELECT PROTECTION_MODE, PROTECTION_LEVEL

FROM V$DATABASE;

15.3 Check archive destinations

SELECT DEST_ID, STATUS, ERROR, DESTINATION

FROM V$ARCHIVE_DEST_STATUS;

15.4 Check Data Guard processes

SELECT ROLE, THREAD#, SEQUENCE#, ACTION

FROM V$DATAGUARD_PROCESS;

For older environments, DBAs may also encounter:

SELECT PROCESS, STATUS, THREAD#, SEQUENCE#

FROM V$MANAGED_STANDBY;

Note: V$MANAGED_STANDBY is deprecated from Oracle Database 12.2 onward. Prefer V$DATAGUARD_PROCESS.

15.5 Check apply lag and transport lag

Run on standby:

SELECT NAME, VALUE, UNIT, TIME_COMPUTED

FROM V$DATAGUARD_STATS;

Important values:

  • transport lag
  • apply lag
  • estimated startup time

15.6 Check archived logs

SELECT THREAD#, SEQUENCE#, APPLIED, FIRST_TIME, NEXT_TIME

FROM V$ARCHIVED_LOG

ORDER BY THREAD#, SEQUENCE#;

15.7 Check archive gap

SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE#

FROM V$ARCHIVE_GAP;

15.8 Check standby redo logs

SELECT GROUP#, THREAD#, SEQUENCE#, STATUS,

    BYTES/1024/1024 SIZE_MB

FROM V$STANDBY_LOG;

15.9 Check online redo logs

SELECT GROUP#, THREAD#, SEQUENCE#, STATUS,

    BYTES/1024/1024 SIZE_MB

FROM V$LOG;

15.10 Check Data Guard messages

SELECT MESSAGE, TIMESTAMP

FROM V$DATAGUARD_STATUS

ORDER BY TIMESTAMP DESC;

15.11 Check current archive sequence on primary

SELECT THREAD#, MAX(SEQUENCE#) LAST_ARCHIVED

FROM V$ARCHIVED_LOG

GROUP BY THREAD#;

15.12 Check alert log

Using ADRCI:

adrci

Then:

ADRCI> SHOW ALERT -TAIL 100

This is useful when investigating transport, apply and database errors.

16. Replication Lag and Archive Gap Troubleshooting

This is a very important senior DBA interview subject.

16.1 What is Transport Lag?

Transport lag indicates how far behind the standby is in receiving redo information from the primary.

Possible reasons:

  • Network connectivity issues.
  • Network latency.
  • Primary redo generation is too high.
  • Standby receiving process issues.
  • Archive destination errors.
  • Standby storage performance issues.

Check:

SELECT NAME, VALUE, UNIT

FROM V$DATAGUARD_STATS

WHERE NAME = ‘transport lag’;

16.2 What is Apply Lag?

Apply lag indicates how far behind the standby is in applying redo information that has been received.

Possible reasons:

  • Slow standby storage.
  • High CPU utilization.
  • Insufficient recovery resources.
  • Heavy redo generation.
  • Long-running recovery operations.
  • Apply process stopped.

Check:

SELECT NAME, VALUE, UNIT

FROM V$DATAGUARD_STATS

WHERE NAME = ‘apply lag’;

16.3 Difference between Transport Lag and Apply Lag

Transport LagApply Lag
Redo has not reached standby yetRedo has reached standby but has not been applied
Network and transport issuesApply and standby performance issues
Investigate LNS, RFS, network and archive destinationsInvestigate MRP, CPU, I/O and recovery

16.4 Scenario: Transport lag is increasing. What will you do?

Answer:

First, I will identify whether redo transport is failing or delayed.

On primary:

SELECT DEST_ID, STATUS, ERROR

FROM V$ARCHIVE_DEST_STATUS;

I will also verify the destination configuration:

SHOW PARAMETER LOG_ARCHIVE_DEST_2;

Then I will check network connectivity:

tnsping DRPROD

I will inspect the primary alert log and standby alert log.

On standby, I will check receiving processes:

SELECT ROLE, THREAD#, SEQUENCE#, ACTION

FROM V$DATAGUARD_PROCESS;

I will check for archive gaps and verify whether standby storage has enough free space.

After identifying the root cause, I will correct connectivity, destination configuration, storage or process-related issues and verify whether the lag is reducing.

16.5 Scenario: Transport lag is zero, but apply lag is high.

Answer:

This means redo is reaching the standby, but the standby is not applying it quickly enough.

I will check whether MRP is running:

SELECT ROLE, THREAD#, SEQUENCE#, ACTION

FROM V$DATAGUARD_PROCESS;

Then I will check CPU utilization, I/O latency, storage throughput and recovery-related waits.

I will also review the standby alert log and compare redo generation with redo apply rates.

16.6 Scenario: Archive gap detected

First identify the missing sequence:

SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE#

FROM V$ARCHIVE_GAP;

Check whether the missing archive is available on primary:

SELECT THREAD#, SEQUENCE#, NAME

FROM V$ARCHIVED_LOG

WHERE THREAD# = 1

ORDER BY SEQUENCE#;

If the missing archive is available, transfer it to the standby using the approved recovery procedure.

Register the file on standby if it was copied manually:

ALTER DATABASE REGISTER LOGFILE

‘/u02/arch/arch_100.arc’;

Then verify that recovery resumes.

If the missing log is unavailable, determine whether it can be restored from RMAN backup. If not, evaluate standby roll-forward or rebuild options.

16.7 Scenario: MRP process is not running

Check:

SELECT ROLE, ACTION, THREAD#, SEQUENCE#

FROM V$DATAGUARD_PROCESS;

Check database status:

SELECT DATABASE_ROLE, OPEN_MODE

FROM V$DATABASE;

Review the alert log before restarting recovery.

Start Redo Apply if it is safe and the root cause has been addressed:

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE

DISCONNECT FROM SESSION;

16.8 Scenario: Standby database is not receiving redo

Check the following:

  1. Primary archive destination status.
  2. Listener availability.
  3. TNS connectivity.
  4. Password file compatibility.
  5. Standby RFS processes.
  6. Archive destination error.
  7. Network firewall and routing.
  8. Standby disk space.

Commands:

SELECT DEST_ID, STATUS, ERROR

FROM V$ARCHIVE_DEST_STATUS;

lsnrctl status

tnsping DRPROD

17. Common Production Issues and Solutions

ProblemPossible reasonDBA action
ORA-12514Listener does not know requested serviceVerify listener and service registration
ORA-12154TNS alias resolution issueCheck tnsnames.ora
ORA-16191Primary and standby redo transport authentication problemCheck password files and SYS authentication
ORA-16047DB_UNIQUE_NAME mismatchVerify destination DB_UNIQUE_NAME
ORA-16766Redo Apply stoppedCheck MRP and standby alert log
ORA-16853Apply lag exceeds configured thresholdInvestigate apply performance
ORA-16857Transport connectivity or redo transport delay threshold exceededCheck network and redo transport
ORA-10458Standby requires recovery before openingStart or complete recovery

These are examples of common errors. Always investigate the complete error stack and alert log before deciding on corrective action.

18. Oracle Data Guard vs Oracle RAC

This is a very common interview question.

Oracle RAC

Oracle Real Application Clusters allows multiple database instances to access the same database storage.

It primarily provides instance-level high availability and scalability.

Oracle Data Guard

Oracle Data Guard maintains a separate standby database and provides disaster recovery and data protection.

Comparison

FeatureOracle RACOracle Data Guard
Main purposeHigh availability and scalabilityDisaster recovery and data protection
Database storageShared storageSeparate database storage
InstancesMultiple instances access same databaseSeparate primary and standby databases
Site failure protectionDepends on RAC deploymentYes, through remote standby
Replication mechanismShared database architectureRedo transport and apply
Role transitionNot its main purposeSwitchover and failover

Can RAC and Data Guard work together?

Yes.

A common enterprise architecture is:

  • Primary RAC database at production site.
  • Physical standby RAC database at DR site.

This provides protection against both instance-level and site-level failures.

19. Oracle Data Guard Interview Questions and Answers

Basic questions

Q1. What is Oracle Data Guard?

Oracle Data Guard is an Oracle high availability and disaster recovery solution that maintains one or more standby databases by transporting and applying redo information.

Q2. What is the difference between primary and standby?

Primary handles application transactions. Standby receives and applies redo information from primary.

Q3. What is redo transport?

It transfers redo information from primary to standby.

Q4. What is redo apply?

It applies received redo information to the standby database.

Q5. What is the difference between physical and logical standby?

Physical standby maintains a physical copy of the primary and uses Redo Apply. Logical standby maintains logical consistency and uses SQL Apply.

Q6. What is Active Data Guard?

Active Data Guard is an Oracle licensed option that enables additional standby capabilities, including real-time query on a physical standby while Redo Apply continues.

Q7. What is Data Guard Broker?

It is a management framework that simplifies Data Guard configuration, monitoring and role transitions.

Q8. What is FAL_SERVER?

It specifies the Oracle Net service used by a standby database to request missing archived redo logs.

Q9. What is FORCE LOGGING?

It ensures that supported database operations generate redo even if an operation would otherwise bypass normal redo generation.

Q10. What is DB_UNIQUE_NAME?

It uniquely identifies each database in the Data Guard configuration.

Intermediate questions

Q11. What is the difference between SYNC and ASYNC?

SYNC uses synchronous redo transport and waits for the configured acknowledgement. ASYNC sends redo without waiting for acknowledgement for each commit.

Q12. What is the difference between switchover and failover?

Switchover is planned. Failover is unplanned and occurs when the primary cannot continue serving its role.

Q13. What is a standby redo log?

A standby redo log receives redo information transported from the primary.

Q14. Why do we configure one extra standby redo log group?

To provide an additional group for redo reception while another group is being archived or processed.

Q15. What is Maximum Availability?

It is a protection mode designed to provide zero data loss during normal protected operation while allowing the primary to continue if the standby destination becomes unavailable.

Q16. What is Maximum Performance?

It prioritizes primary performance and typically uses asynchronous redo transport.

Q17. What is Maximum Protection?

It provides the highest level of protection and shuts down the primary if the required synchronous protection cannot be maintained.

Q18. Can we open a physical standby database in read-only mode?

Yes, with an appropriate configuration. To keep Redo Apply running while the database is open read-only requires eligible Active Data Guard functionality.

Q19. What is real-time apply?

Real-time apply applies redo directly from standby redo logs before the entire redo log is archived.

Q20. How do you check Data Guard lag?

Use V$DATAGUARD_STATS on the standby database.

Advanced questions

Q21. What happens if the primary database crashes?

The DBA checks standby synchronization, determines data-loss exposure, verifies the primary recovery possibility and performs a failover if required.

Q22. What happens if the network between primary and standby goes down?

Redo transport is interrupted. The primary behavior depends on the protection mode and transport configuration. Once connectivity is restored, transport and recovery can catch up if the required redo is available.

Q23. What happens if MRP stops?

Redo may continue to arrive, but the standby will not apply it. Apply lag increases until recovery resumes.

Q24. How do you identify an archive gap?

Use V$ARCHIVE_GAP on the physical standby.

Q25. What is the difference between transport lag and apply lag?

Transport lag measures redo delivery delay. Apply lag measures redo application delay.

Q26. What is Fast-Start Failover?

It is a Broker-managed capability that can automatically fail over to a target standby when configured conditions are met and the observer determines that failover is necessary.

Q27. What is the Observer?

The Observer is an external process used by Fast-Start Failover to monitor the primary and target standby and initiate automatic failover when appropriate.

Q28. Can we have multiple standby databases?

Yes. Oracle Data Guard supports configurations with multiple standby destinations, subject to supported configuration limits and architecture.

Q29. Can we use Data Guard with RAC?

Yes. RAC primary and standby configurations are supported.

Q30. What happens after failover to the standby?

The standby assumes the primary role. The original primary must be reinstated using Flashback Database when possible or rebuilt as a standby.

20. Advanced Scenario-Based Interview Questions

These questions are particularly important for Senior Oracle DBA interviews.

Scenario 1: Primary database is down. What will you do?

Answer:

First, I will confirm whether the issue is database-level, server-level, storage-level or site-level.

I will check whether the primary can be recovered.

Then I will check the standby database role, transport lag, apply lag and latest received redo.

If the primary cannot be recovered within the required RTO, I will follow the disaster recovery procedure and perform a failover using Broker or the approved manual method.

After failover, I will validate the new primary and application connectivity.

Scenario 2: Standby database is 30 minutes behind primary. How will you troubleshoot?

Answer:

First, I will determine whether the 30-minute delay is transport lag or apply lag.

SELECT NAME, VALUE, UNIT

FROM V$DATAGUARD_STATS;

If transport lag is high, I will check network connectivity, primary archive destination errors, LNS and RFS processes.

If apply lag is high, I will check MRP, standby CPU, storage I/O and redo apply throughput.

Then I will identify the root cause and monitor whether the lag reduces after corrective action.

Scenario 3: Network connectivity between primary and standby is lost. What happens?

Answer:

Redo transport stops or is delayed.

The impact on primary commits depends on the protection mode and redo transport configuration.

In Maximum Protection, loss of the required protection can cause the primary to shut down.

In Maximum Availability, the primary can continue after the configured timeout and protection behavior takes effect.

In Maximum Performance, the primary can continue without waiting for standby acknowledgement, but potential data loss increases.

After connectivity returns, Oracle can transport and apply outstanding redo if the required logs are available.

Scenario 4: Primary database is generating redo faster than standby can apply it. What will you do?

Answer:

I will compare redo generation and apply rates.

I will check:

  • CPU utilization on standby.
  • Storage I/O latency.
  • Recovery processes.
  • Archive log generation.
  • Network bandwidth.
  • Standby redo log configuration.

If apply is the bottleneck, I will investigate storage and recovery performance and evaluate supported parallel apply options.

I will not assume that adding CPU alone will resolve the issue.

Scenario 5: Standby is receiving redo, but MRP is not applying it.

Answer:

I will check the MRP process, database state and standby alert log.

SELECT ROLE, ACTION, THREAD#, SEQUENCE#

FROM V$DATAGUARD_PROCESS;

I will investigate missing archive logs, recovery errors and storage issues.

After resolving the root cause, I will restart Redo Apply if required.

Scenario 6: The primary database is completely lost. Can we perform zero-data-loss failover?

Answer:

It depends on the protection mode and whether all required redo was successfully received by the standby.

A synchronous protection configuration can provide zero data loss under its protection guarantees.

If the latest redo was not received, zero-data-loss failover cannot be assumed.

Scenario 7: A standby database is not synchronized after a primary switchover.

Answer:

I will check the roles of both databases, Broker status, redo destinations, transport connectivity and apply state.

I will confirm that the old primary has been converted correctly into the new standby role and that the redo transport configuration is valid in the new roles.

Scenario 8: You need to perform patching on the production database with minimal downtime. What is your approach?

Answer:

If the maintenance procedure is supported by the environment, I will validate the standby, perform a planned switchover, patch the former primary while it operates as standby and follow the approved upgrade or patching procedure.

After validation, I can switch back if required.

For major database upgrades, I will evaluate supported Data Guard rolling upgrade methods rather than assuming that ordinary switchover alone is sufficient.

Scenario 9: Standby database is showing ORA-16766.

Answer:

This generally indicates that Redo Apply is stopped.

I will check the Broker status, MRP process, database alert log and any underlying recovery error before restarting apply.

Scenario 10: What will you check before a planned switchover?

Answer:

  1. Confirm both databases are healthy.
  2. Check transport and apply lag.
  3. Check Broker configuration.
  4. Verify standby is ready for switchover.
  5. Confirm application and service dependencies.
  6. Confirm backup and rollback plans.
  7. Obtain change approval.
  8. Perform switchover.
  9. Validate database roles and application connectivity.
  10. Confirm redo transport and apply in the reverse direction.

21. Daily Oracle Data Guard DBA Health-Check Checklist

A production DBA should regularly monitor the following.

CheckCommand or method
Primary database roleV$DATABASE
Standby database roleV$DATABASE
Protection modeV$DATABASE
Transport lagV$DATAGUARD_STATS
Apply lagV$DATAGUARD_STATS
Redo transport statusV$ARCHIVE_DEST_STATUS
MRP statusV$DATAGUARD_PROCESS
RFS statusV$DATAGUARD_PROCESS
Archive gapV$ARCHIVE_GAP
Standby redo logsV$STANDBY_LOG
Broker statusSHOW CONFIGURATION
Alert log errorsADRCI
Network connectivityTNSPING

Sample daily health-check SQL

— Database role and open mode

SELECT NAME, DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE

FROM V$DATABASE;

— Protection mode

SELECT PROTECTION_MODE, PROTECTION_LEVEL

FROM V$DATABASE;

— Transport and apply lag

SELECT NAME, VALUE, UNIT

FROM V$DATAGUARD_STATS;

— Data Guard processes

SELECT ROLE, THREAD#, SEQUENCE#, ACTION

FROM V$DATAGUARD_PROCESS;

— Archive destination errors

SELECT DEST_ID, STATUS, ERROR

FROM V$ARCHIVE_DEST_STATUS;

— Archive gap

SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE#

FROM V$ARCHIVE_GAP;

22. Important Oracle Data Guard Commands Cheat Sheet

PurposeCommand
Check database roleSELECT DATABASE_ROLE FROM V$DATABASE;
Check open modeSELECT OPEN_MODE FROM V$DATABASE;
Check protection modeSELECT PROTECTION_MODE FROM V$DATABASE;
Check lagSELECT * FROM V$DATAGUARD_STATS;
Check Data Guard processesSELECT * FROM V$DATAGUARD_PROCESS;
Check archive gapSELECT * FROM V$ARCHIVE_GAP;
Start redo applyALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Stop redo applyALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Enable force loggingALTER DATABASE FORCE LOGGING;
Check archive destinationSELECT * FROM V$ARCHIVE_DEST_STATUS;
Check BrokerSHOW CONFIGURATION;
Perform switchoverSWITCHOVER TO ‘DRPROD’;
Perform failoverFAILOVER TO ‘DRPROD’;
Enable BrokerALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;
Check listenerlsnrctl status
Check TNStnsping DRPROD

23. Final Interview Preparation: What Should You Be Able to Explain?

Before attending a Senior Oracle DBA interview, make sure you can explain these topics without looking at notes:

  1. Complete Data Guard architecture.
  2. Redo generation, transport and apply flow.
  3. LGWR, LNS, RFS, MRP and ARCH processes.
  4. Physical, logical and snapshot standby.
  5. SYNC versus ASYNC.
  6. Maximum Protection, Availability and Performance.
  7. All important Data Guard initialization parameters.
  8. Step-by-step physical standby configuration.
  9. RMAN DUPLICATE FOR STANDBY.
  10. Standby Redo Logs and their sizing.
  11. Data Guard Broker configuration.
  12. DGMGRL commands.
  13. Switchover versus failover.
  14. Transport lag versus apply lag.
  15. Archive gap troubleshooting.
  16. MRP stopped troubleshooting.
  17. Network failure troubleshooting.
  18. Primary database failure and DR activation.
  19. RAC versus Data Guard.
  20. Daily Data Guard health checks.

Conclusion

Oracle Data Guard is a critical technology for enterprise Oracle Database environments. Every Oracle DBA working in production should understand its architecture, configuration, monitoring and troubleshooting.

For a senior DBA, theoretical knowledge is not enough. You should be able to identify transport and apply problems, investigate archive gaps, understand protection modes, execute planned role transitions and follow disaster recovery procedures safely.

The commands and scenarios in this guide provide a practical foundation for Oracle Data Guard administration and interview preparation.

Recommended practice: Build a two-database Oracle 19c Data Guard lab, configure a physical standby using RMAN, monitor redo transport, stop and restart Redo Apply, test an archive gap recovery procedure, and perform a planned switchover.

Author: SmartTechWays.com – Oracle Database Administration Tutorials

Disclaimer: SQL and configuration examples are templates for learning. Validate database version, storage paths, service names, licensing, protection requirements and change approvals before running commands in production.

This entry was posted in Oracle on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply