Oracle dataguard
Quick reference notes of terminology explanations and useful commands
Prepared by : Rubin Philip
Oracle Dataguard
The main uses of standby database:
1. High availability
2. Data protection
3. Disaster recovery
4. For taking backup
5. Reporting
Types of standby databases
Type of standby database Description
Physical Standby • Exact block -for-block copy of primary database.
• Maintained using REDO-APPLY
Logical Standby • Convert the data received from primary into SQL statements and
execute the SQL statements in the standby database. (LSP process
applies the redo)
• Maintained using SQL-APPLY
Snapshot Standby • A fully updatable standby database converted from physical standby
database.
Cascaded Standby • A standby database receives its redo from another standby database
to reduce the load on the primary system.
Active Data guard • Physical standby can be opened in read only mode while the redo
from primary is getting applied.
• Reporting queries can be offloaded to standby database to avoid load
in the production system.
• RMAN backups also can be taken from standby database.
Transient Logical Standby • It allows a rolling database upgrade by converting physical standby
database temporarily to logical standby database.
Redo transport services
Type Description
Synchronous Redo Transport • Zero data loss approach
• Changes at the primary side are committed only when LGWR receives
the confirmation from LNS that the changes have been written to the
standby database as well.
Asynchronous Redo Transport • There is no “Zero Data Loss” approach in this redo transport method!
• Unlike Synchronous Redo Transport, LGWR background process does
not expect validation from LNS background process.
Apply Services
Type Description
Real-time apply • It uses in physical standby database.
• Apply services can apply the changes to the standby database as it is
received, without waiting for standby redo log files to be archived.
SQL apply • It converts the redo data into SQL and apply it on the logical standby
database.
Role Transitions
Type Description
Switchover • Allows the primary database to change its role with a standby
database.
• There is no data loss during a switchover.
Failover • Changes a standby database to the role of primary database in
response to primary database failure
• Chances of data loss if the database running on MAXIMUM
performance protection mode.
• If flashback is enabled on the primary, it can be reinstated as standby
database once the reason for the failure is corrected.
Affirm and No affirm
Type Description
Affirm It ensures that the redos are written to the disks in standby side.
Noaffirm It ensures that redos are received in one of the standby sides.
Protection Modes
Maximum Protection Maximum Availability Maximum Protection
SYNC/LGWR SYNC/LGWR ASYNC/LGWR/ARCH
Primary database needs to It provides highest level of As its name says it provides maximum level
write redo to at least one of the protection of data without of data protection that a database can have
standby databases and compromising availability of without compromising performance of
acknowledge. Otherwise, database. database.
primary will be shut down. If the primary database cannot
write its redo stream to at least This is default Protection mode in
one synchronized standby Dataguard.
database, it operates as if it
were in maximum performance
mode to preserve primary
database availability until it is
again able to write its redo
stream to a synchronized
standby database.
Zero data loss is guaranteed Zero data loss in normal Minimal data loss in a normal operation.
operation but not guaranteed
Flow diagram of physical standby database:
PHYSICAL STANDBY DATABASE RELATED PROCESSES
On the Primary Database:
LGWR : The log writer process flushes log buffers from the SGA to Online Redo Log files.
LNS : The LogWriter Network Service (LNS) reads the redo being flushed from the redo buffers by the LGWR and
sends the redo over network to the standby database.
ARCH : The archiver processes archive the ORL files to archive log files.
On the Standby Database:
RFS : The main objective of the Remote File Server process is to perform a network receive of redo transmitted
from the primary site and then writes the network buffer (redo data) to the standby redo log (SRL) files.
ARCH : The archive processes on the standby site perform the same functions performed on the primary site,
except that on the standby site, an ARCH process generates archived log files from the SRLs.
MRP: The managed recovery process coordinates media recovery management.
Configuration of dataguard broker
Dataguard broker provides a unified method to perform dataguard administration, switchover, failover.
Dataguard broker keeps the information in a flat file, where redundant copies of the file are kept in each database
in the dataguard configuration.
DG_BROKER_CONFIG_FILE_1 and DG_BROKER_CONFIG_FILE_2 are the parameters controls the location of the
configuration files.
Step 1: Configuration:
On the primary side
alter system set dg_broker_config_file_1=
alter system set dg_broker_config_file_2=
alter system set dg_broker_start=true scope=both;
alter system set local_listener=””;
On the standby side
alter system set dg_broker_config_file_1=
alter system set dg_broker_config_file_2=
alter system set dg_broker_start=true scope=both;
alter system set local_listener=””;
Step2:Verify the TNS between prod and standby
Step3: Login to DGMGRL and check the configuration
• dgmgrl
• connect sys/password@tns_prod
• connect sys/password@tns_stby
• show configuration
• prod: create configuration ‘PROD’ as primary database is ‘PROD_DB’ connect identifier is ‘tns_prod’; [Make
sure log_Archive_dest_2 parameter is empty]
• standby: add database ‘DR’ as connect identifier is ‘DR’;
• show configuration
• enable configuration
Switchover and switchback using DGMGRL
switchover to DR;
convert database 'DR' to snapshot standby;
convert database 'DR' to physical standby;
Useful commands to show configuration of dataguard and individual database
show configuration
show configuration verbose
show database ‘PRIM’
show database verbose ‘PRIM’
validate database ‘PRIM’
validate database verbose 'PRIM’
show database ‘PRIM’ sendQentries
show database ‘DR’ recvQentries
validate network configuration for all;
Edit database properties
edit database ‘DR’ set state=’APPLY-OFF’;
edit database ‘DR’ set state=’TRANSPORT-OFF’;
edit database ‘DR’ set state=’APPLY-ON’;
edit database ‘DR’ set state=’TRANSPORT-ON’;
Changing protection mode from max performance to max availability
DGMGRL> EDIT DATABASE ‘chennai’ SET PROPERTY ‘LogXptMode’=’SYNC’;
DGMGRL> EDIT DATABASE ‘delhi’ SET PROPERTY ‘LogXptMode’=’SYNC’;
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Enabling the fast-start failover
• Protection mode should be max availability
• DGMGRL> enable fast_start failover;
• DGMGRL> show fast_start failover;
• Start observer or nohup dgmgrl sys/oracle@orcl “start observer file=’/home/oracle/fsfo.dat’” -logfile
$HOME/observer.log &