Upload
tienhtran7391
View
234
Download
1
Embed Size (px)
8/6/2019 Oracle Dataguard 11g Doc V1.01
1/20
Oracle Data Guard 11g
Basic Concept, ImplementationAnd 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
8/6/2019 Oracle Dataguard 11g Doc V1.01
2/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 2 of20
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
8/6/2019 Oracle Dataguard 11g Doc V1.01
3/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 3 of20
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
Primary Standby
Hostname dgprim.tap.com dgstby.tap.com
Global Db name prim.tap.com stby.tap.com
Db_unique_name Prim Stby
Oracle SID Prim Stby
Listener Ports 1521 1521
TNS_NAMES Prim Stby
Listener LISTENER(with static service entry) LISTENER (with static service entry)
ORACLE_BASE /u01/app/oracle /u01/app/oracle
ORADATA /u01/app/oracle/oradata/prim/ /u01/app/oracle/oradata/stby/
Archive Dest /u01/app/oracle/oradata/archive/ /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.
8/6/2019 Oracle Dataguard 11g Doc V1.01
4/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 4 of20
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 standbymachine 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>Shutdownimmediate;SQL>Startupmount;SQL>Alterdatabasearchivelog;SQL>Alterdatabaseopen;
8/6/2019 Oracle Dataguard 11g Doc V1.01
5/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 5 of20
g.) Register database services into listener
h.) Add entry in tnsnames.ora
8/6/2019 Oracle Dataguard 11g Doc V1.01
6/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 6 of20
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/stbymkdir-p/u01/app/oracle/flash_recovery_area
8/6/2019 Oracle Dataguard 11g Doc V1.01
7/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 7 of20
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 onprimary 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 standbycommand 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 convertinginstance parameter values and also set the parameters which is specifically for standby database.
8/6/2019 Oracle Dataguard 11g Doc V1.01
8/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 8 of20
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
8/6/2019 Oracle Dataguard 11g Doc V1.01
9/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 9 of20
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
8/6/2019 Oracle Dataguard 11g Doc V1.01
10/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 10 of20
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.
8/6/2019 Oracle Dataguard 11g Doc V1.01
11/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 11 of20
4. Performing Switchover and failover Operations
4.1. Performing a switch over to a Physical Standby DatabaseThis 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
8/6/2019 Oracle Dataguard 11g Doc V1.01
12/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 12 of20
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
8/6/2019 Oracle Dataguard 11g Doc V1.01
13/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 13 of20
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.
8/6/2019 Oracle Dataguard 11g Doc V1.01
14/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 14 of20
f.) Restart the database
g.) Verify the role of the database. Now your database is ready for primary role
8/6/2019 Oracle Dataguard 11g Doc V1.01
15/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 15 of20
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 _DGMGRL. 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
8/6/2019 Oracle Dataguard 11g Doc V1.01
16/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 16 of20
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
8/6/2019 Oracle Dataguard 11g Doc V1.01
17/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 17 of20
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.
8/6/2019 Oracle Dataguard 11g Doc V1.01
18/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 18 of20
5.2. Performing Switchover from Data guard broker
a.) Use the following statement to perform switchover
8/6/2019 Oracle Dataguard 11g Doc V1.01
19/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 19 of20
5.3. Performing Failover from data guard broker
a.) To check the status of the dataguard configuration use the following statement from dgmgrlcommand line interface.
b.) Use the following statement to perform fail over .
c.) Verify the configuration again using show configuration command
8/6/2019 Oracle Dataguard 11g Doc V1.01
20/20
Oracle Dataguard Concepts V1.0
Muhammad Aamir Copyrights reserved Page 20 of20
6. References
Following are the reference
http://wiki.oracle.com/page/Data+Guard+Architecture
http://www.oracle.com/technetwork/tutorials/index.html
http://wiki.oracle.com/page/Data+Guard+Architecturehttp://www.oracle.com/technetwork/tutorials/index.htmlhttp://www.oracle.com/technetwork/tutorials/index.htmlhttp://wiki.oracle.com/page/Data+Guard+Architecture