You are on page 1of 20

Oracle Data Guard 11g Basic Concept, Implementation And Administration

Author: Muhammad Aamir Creation date: 07th January, 2011 Doc version: 1.0

Change Control:
Change Record Date Author Version Change Reference

07/01/2011

Muhammad Amir

1.0

Document Created

Oracle Dataguard Concepts V1.0

1. Introduction
This document is intended to serve as definitive reference of Oracle Data Guard technology and concepts, and helps you configure and implement physical standby databases. Oracle Data Guard is the most effective solution available today to protect the core asset of any enterpriseits data, and make it available on a 24x7 basis even in the face of disasters and other calamities.

2. Concepts
A Data Guard configuration consists of one production database and one or more standby databases. The databases in a Data Guard configuration are connected by Oracle Net and may be dispersed geographically. There are no restrictions on where the databases are located, provided they can communicate with each other. Figure 1 shows a typical Data Guard Configuration that contain primary database that transmit redo data to standby database The following data guard services manages the transmission of redo data, the application of redo data, and changes to the database role - Redo transport services Control the automated transfer of redo data from the production database to one or more archival destinations. - Apply services Apply redo data on the standby database to maintain transactional synchronization with the primary databases. Redo can be applied either from archival redo log files or if real time apply is enabled, directly from standby redo log files - Role transition This service changes the role of a database from standby database to primary or from primary database to standby database using either a switchover or failover operations. You can use to manage Data Guard using the SQL command-line interfaces or the Data Guard broker interfaces, including a command-line interface (DGMGRL) and a graphical user interface that is integrated in Oracle Enterprise Manager
Figure 1 : Typical Data Guard Configuration

Muhammad Aamir Copyrights reserved

Page 2 of 20

Oracle Dataguard Concepts V1.0

3. Creating Physical standby database Using RMAN


In this section you create a Data Guard physical standby database using RMAN active database duplication and we are using the following pre-configured Virtual Machines with the configuration given below. Assumptions: - Operating System: Oracle Enterprise Linux 5 update 3 32 bit (complete installation) - Oracle Software: Oracle 11g Release 2 - 32 bit with latest patches - Memory (Each VM Server): 1.5 GB - Swap Space (Each VM Server): 3 GB - Preconfigured database on primary machine - Installation of Oracle binaries on standby machine - Connectivity between nodes (Entries in host file of both nodes) And the following configuration use for host name and databases Hostname Global Db name Db_unique_name Oracle SID Listener Ports TNS_NAMES Listener ORACLE_BASE ORADATA Archive Dest Primary dgprim.tap.com prim.tap.com Prim Prim 1521 Prim LISTENER(with static service entry) /u01/app/oracle /u01/app/oracle/oradata/prim/ /u01/app/oracle/oradata/archive/ Standby dgstby.tap.com stby.tap.com Stby Stby 1521 Stby LISTENER (with static service entry) /u01/app/oracle /u01/app/oracle/oradata/stby/ /u01/app/oracle/oradata/archive/

3.1. Preparing the Primary Database


On primary site we assumed that we have already running database. Firstly we must ensure that the primary database is properly configured. Perform the following tasks on the primary database to prepare for standby database a.) Enable force logging

b.) Add standby log files on primary database (it is recommended to create standby redo logs on primary database to make things easier during switchover and failover), standby log files are required to store redo received from primary database, and must have at least one more redo log group than the redo log on the primary database. Muhammad Aamir Copyrights reserved Page 3 of 20

Oracle Dataguard Concepts V1.0

Verify standby log files

c.) Set the log_archive_config parameter, this parameter enables the full data Guard functionality and it contains the db_unique_name of each database in the configuration.

d.) Set the log_archive_dest_2 parameter to specify the destination of the remote physical standby machine where it transmits the redo data.

e.) Set standby_file_management parameter, its made changes automatically into standby database when data files are added or dropped from the primary database

f.) Enable archiving if it is not enable


SQL>Shutdown immediate; SQL>Startup mount; SQL>Alter database archivelog; SQL>Alter database open;

Muhammad Aamir Copyrights reserved

Page 4 of 20

Oracle Dataguard Concepts V1.0

g.) Register database services into listener

h.) Add entry in tnsnames.ora

Muhammad Aamir Copyrights reserved

Page 5 of 20

Oracle Dataguard Concepts V1.0 i.) Copy tnsnames.ora to standby database using OS utility

Note: At this stage all the preparation of primary site was done now prepare standby machine

3.2. Preparing the Standby Server


On this machine we assumed that we have only installed oracle software binaries and have only password file and tnsnames.ora file which was copy from primary site. a.) Register static service entry for standby database in listener.ora

b.) Copy password file to standby database using OS utility

c.) Create required directories


mkdir -p /u01/app/oracle/oradata/stby mkdir -p /u01/app/oracle/flash_recovery_area

Muhammad Aamir Copyrights reserved

Page 6 of 20

Oracle Dataguard Concepts V1.0 d.) Create dummy init parameter file to start the instance on primary side

e.) Start the standby database server into no mount state

Note: At this stage all the preparation of standby site was done now we are going to run the script on primary database which will configure standby server automatically

3.3. Run RMAN Duplicate from Primary DB


In this demonstration I Use the following RMAN script to duplicate the current primary database. a.) Create rman script and grant executes permission to it. Cat /u01/app/oracle/backup.txt In this script I use the duplicate target database for standby command which performs the actual data movement at the standby server and for active database command is used to create the standby database from actively running primary database and parameter_value_convert is used to converting instance parameter values and also set the parameters which is specifically for standby database.

Muhammad Aamir Copyrights reserved

Page 7 of 20

Oracle Dataguard Concepts V1.0

b.) Run RMAN and connect to the primary database and make an auxiliary connection to the standby database

c.) Run RMAN and connect to the primary database and make and auxiliary connection to the standby database

Output of the script

Muhammad Aamir Copyrights reserved

Page 8 of 20

Oracle Dataguard Concepts V1.0

Note: at the end of the script you see the finished successfully which means your standby server is ready d.) Now you need to run the following command on STANDBY NODE to start redo Apply services

3.4. Test and Verify Standby Services


a.) Execute the query to verify the status

b.) Now at this stage your database is configured for data guard

Muhammad Aamir Copyrights reserved

Page 9 of 20

Oracle Dataguard Concepts V1.0 c.) To Use the Data guard as an active data guard restart the database and run the recovery command as mention below. Make sure the sequence of shutdown is proper, you must shutdown primary first and then standby and then start standby first and then primary database.

Note: Make sure the database startup and shutdown sequence is right.

Muhammad Aamir Copyrights reserved

Page 10 of 20

Oracle Dataguard Concepts V1.0

4. Performing Switchover and failover Operations


4.1. Performing a switch over to a Physical Standby Database
This section describes how to perform a switch over to a physical standby database. a.) First verify that the primary database can be switched to the standby role

b.) Issue the following SQL Statement to start the switchover on the primary database

c.) Shutdown and then mount the former primary database.

Note: at this stage in a switchover process the original primary database is a physical standby database

Muhammad Aamir Copyrights reserved

Page 11 of 20

Oracle Dataguard Concepts V1.0

d.) Now verify that the switchover target is ready to be switched to the primary role, run the query on standby database

e.) Switch the target physical standby database role to the primary role.

f.) And then open the new primary database

g.) Verify the status of database on old standby or new primary, the role become change now.

h.) Now Start the Redo Apply services on new standby site

i.) Verify the status of new standby site

Muhammad Aamir Copyrights reserved

Page 12 of 20

Oracle Dataguard Concepts V1.0

4.2. Performing a failover to a Physical Standby Database


This section provides examples that create a broker configuration named Config1 that includes a a.) This section describes how to perform a fail over to a physical standby database.

b.) Verify the archive log gaps make sure no gaps found.

c.) Run the following statement to initiate the failover

d.) This statement convert the standby database to the primary role

e.) If your database is not open in read only mode run the following to open the database.

Muhammad Aamir Copyrights reserved

Page 13 of 20

Oracle Dataguard Concepts V1.0 f.) Restart the database

g.) Verify the role of the database. Now your database is ready for primary role

Muhammad Aamir Copyrights reserved

Page 14 of 20

Oracle Dataguard Concepts V1.0

5. Data Guard Broker DGMGRL


This section describes you how to use DGMGRL tool to create, manage, and monitor a broker configuration

5.1. Create and Enable Broker Configuration


This section provides examples that create a broker configuration named Config1 that includes a primary and Standby database named prim and stby and enable the configuration a.) To enable the Data guard Configuration you need to set the dg_broker_start parameter to TRUE on both side primary and standby database

b.) Create the services with a specific name must be statically registered with the local listener on both side primary and database that include the <db_unique_name>_DGMGRL.<db_domain> values for the GLOBAL_DBNAME. This setting allows DGMGRL to restart instances during the course of broker operations. Reload the listener and verify the status of services Primary site Listener.ora

Muhammad Aamir Copyrights reserved

Page 15 of 20

Oracle Dataguard Concepts V1.0

Standby site Listener.ora

c.) Restart the listener on both side and make sure that the services registered properly.

d.) Invoke the DGMGRL to create dataguard configuration and connect with primary database

Muhammad Aamir Copyrights reserved

Page 16 of 20

Oracle Dataguard Concepts V1.0 Note: you must connect with primary database when you are configuring broker and if you connecting remotely you must specify primary connection string e.) Creating the broker configuration for the primary database

f.) Add your physical standby database to the configuration

g.) Use the SHOW CONFIGURATION command to verify that the stby database was added to the configuration

h.) To Enable the entire configuration use the following command

i.) Use show command to verify the configuration status is started.

Muhammad Aamir Copyrights reserved

Page 17 of 20

Oracle Dataguard Concepts V1.0

5.2. Performing Switchover from Data guard broker


a.) Use the following statement to perform switchover

Muhammad Aamir Copyrights reserved

Page 18 of 20

Oracle Dataguard Concepts V1.0

5.3. Performing Failover from data guard broker


a.) To check the status of the dataguard configuration use the following statement from dgmgrl command line interface.

b.) Use the following statement to perform fail over .

c.) Verify the configuration again using show configuration command

Muhammad Aamir Copyrights reserved

Page 19 of 20

Oracle Dataguard Concepts V1.0

6. References
Following are the reference http://wiki.oracle.com/page/Data+Guard+Architecture http://www.oracle.com/technetwork/tutorials/index.html

Muhammad Aamir Copyrights reserved

Page 20 of 20

You might also like