Dataguard Implementation
Dataguard Implementation
and Failover
Version 1.0
Updated
Reference No.
Page 1
Table of Contents
DATAGUARD OVERVIEW..................................................................................... 4
Step 1................................................................................................................................................................ 5
Step 2................................................................................................................................................................ 5
Step 3................................................................................................................................................................ 5
Step 4................................................................................................................................................................ 5
Step 5................................................................................................................................................................ 6
Step 6................................................................................................................................................................ 6
Step 7................................................................................................................................................................ 6
Step 8................................................................................................................................................................ 6
Step 9................................................................................................................................................................ 7
Step 10.............................................................................................................................................................. 7
Step 11.............................................................................................................................................................. 8
Step 12.............................................................................................................................................................. 8
Step 13.............................................................................................................................................................. 9
Step 14.............................................................................................................................................................. 9
Step 15.............................................................................................................................................................. 9
Step 16............................................................................................................................................................ 10
Step 17............................................................................................................................................................ 10
Page 2
Failover Step 2............................................................................................................................................... 11
APPENDIX A ......................................................................................................... 15
DB_FILE_NAME_CONVERT.................................................................................................................... 16
Page 3
Dataguard Overview
Document Outline
This document will provide the reader with step-by-step instructions on how to create a Data Guard
environment. This document has been developed with Egg specifics in mind.
This document assumes that the standby database has already been built.
Oracle Data Guard ensures high availability, data protection, and disaster recovery for enterprise
data. Data Guard provides a comprehensive set of services that create, maintain, manage, and
monitor one or more standby databases to enable production Oracle databases to survive
disasters and data corruptions. Data Guard maintains these standby databases as transactionally
consistent copies of the production database. Then, if the production database becomes
unavailable because of a planned or an unplanned outage, Data Guard can switch any standby
database to the production role, thus minimizing the downtime associated with the outage. Data
Guard can be used with traditional backup, restoration, and cluster techniques to provide a high
level of data protection and data availability.
The example given is for database ACC2. You will need to change the database name (SID) for
each database
Page 4
Step By Step Guide
Step 1
Place primary database in FORCE LOGGING mode using following SQL statement:
Step 2
NAME
---------------------------------------------------------------------
/u107/oradata/ACC2/ACC2_system01.dbf
/u107/oradata/ACC2/ACC2_undo_rbs1.dbf
/u107/oradata/ACC2/ACC2_users01.dbf
/u107/oradata/ACC2/ACC2_tools01.dbf
/u109/oradata/ACC2/ACC2_ACCURATE_DATA01.dbf
/u108/oradata/ACC2/ACC2_ACCURATE_INDEX01.dbf
/u109/oradata/ACC2/ACC2_ACCURATE_DATA02.dbf
/u109/oradata/ACC2/ACC2_ACCURATE_DATA03.dbf
/u108/oradata/ACC2/ACC2_ACCURATE_INDEX02.dbf
Step 3
'ALTERTABLESPACE'||TABLESPACE_NAME||'BEGINBACKUP;'
-------------------------------------------------------------
alter tablespace SYSTEM begin backup;
alter tablespace UNDO_RBS1 begin backup;
alter tablespace USERS begin backup;
alter tablespace TOOLS begin backup;
alter tablespace TEMP begin backup;
alter tablespace ACCURATE_DATA begin backup;
alter tablespace ACCURATE_INDEX begin backup;
Step 4
Page 5
scp -p /u107/oradata/ACC2/ACC2_system01.dbf shark-9:/u103/oradata/ACC2/.
scp -p /u107/oradata/ACC2/ACC2_undo_rbs1.dbf shark-9:/u103/oradata/ACC2/.
scp -p /u107/oradata/ACC2/ACC2_users01.dbf shark-9:/u103/oradata/ACC2/.
scp -p /u107/oradata/ACC2/ACC2_tools01.dbf shark-9:/u103/oradata/ACC2/.
scp -p /u109/oradata/ACC2/ACC2_ACCURATE_DATA01.dbf shark-9:/u103/oradata/ACC2/.
scp -p /u108/oradata/ACC2/ACC2_ACCURATE_INDEX01.dbf shark-9:/u103/oradata/ACC2/.
scp -p /u109/oradata/ACC2/ACC2_ACCURATE_DATA02.dbf shark-9:/u103/oradata/ACC2/.
scp -p /u109/oradata/ACC2/ACC2_ACCURATE_DATA03.dbf shark-9:/u103/oradata/ACC2/.
scp -p /u108/oradata/ACC2/ACC2_ACCURATE_INDEX02.dbf shark-9:/u103/oradata/ACC2/.
Step 5
Issue the following command on primary database to create control file for the
standby database.
SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS
2 '/opt/app/oracle/<filename>.ctl’;
Database altered.
The filename for newly created standby control file must be different of current
control file of the primary database. Also control file for standby database must
be created after the last timestamp for the backup Datafiles.
Step 6
Step 7
Step 8
#=========================================================================
# Dataguard STANDBY config
# ========================================================================
standby_archive_dest='/u104/oradata/ACC2/archive'
Page 6
DB_FILE_NAME_CONVERT =('/u107/oradata/ACC2/' , '/u103/oradata/ACC2/' ,
'/u109/oradata/ACC2/' , '/u103/oradata/ACC2/' ,
'/u108/oradata/ACC2/' , '/u103/oradata/ACC2/' )
log_file_name_convert=('/u101/oradata/ACC2/' , '/u103/oradata/ACC2/' ,
'/u102/oradata/ACC2' , '/u103/oradata/ACC2/' ,
'/u104/oradata/ACC2/' , '/u103/oradata/ACC2/')
standby_file_management=AUTO
remote_archive_enable=TRUE
#===========================================================================
# Dataguard LIVE config
# =========================================================================
#log_archive_dest_2 = 'SERVICE=ACC2_SHARK1 reopen=120'
#log_archive_dest_state_1 = enable
#log_archive_dest_state_2 = enable
#remote_archive_enable = true
#log_archive_dest_1 = 'location=/u105/oradata/ACC2/archive'
# standby_file_management=MANUAL
Step 9
Step 10
Page 7
Step 11
ACC2_SHARK1.WORLD=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=tcp)
(HOST=shark-9)
(PORT=1521)
)
(CONNECT_DATA=
(SID=ACC2)
(SERVER=DEDICATED)
)
)
Step 12
Database altered.
SQL>
Page 8
Step 13
#===========================================================================
# Dataguard LIVE config
# =========================================================================
log_archive_dest_2 = 'SERVICE=ACC2_SHARK9 reopen=120'
log_archive_dest_state_1 = enable
log_archive_dest_state_2 = enable
remote_archive_enable = true
#===========================================================================
#===========================================================================
# Dataguard STANDBY config
# =========================================================================
#standby_file_management=manual
#remote_archive_enable=TRUE
#standby_archive_dest='/u105/oradata/ACC2/archive'
log_archive_dest_1 = 'location=/u105/oradata/ACC2/archive'
and
log_archive_start = TRUE
Step 14
Step 15
The example includes the DISCONNECT FROM SESSION option so that log apply
services run in a background session.
Database altered.
To cancel this
Page 9
Step 16
On standby database query the V$ARCHIVED_LOG view to verify that redo log
received.
On Primary
SQL> alter system switch logfile;
System altered.
On standby
SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY
SEQUENCE#;
Step 17
Finished
Page 10
Failover Process
Failover Step 1
To transition the current primary database to a physical standby database role, use the
following SQL statement on the primary database:
After this statement completes, the primary database is converted into a standby
database. The current control file is backed up to the current SQL session trace file
before the switchover operation. This makes it possible to reconstruct a current
control file, if necessary.
Failover Step 2
Shut down the former primary instance and restart it without mounting the database:
Page 11
Failover Step 3
Hash out the primary dataguard config and un hash the standby config
in the init.ora
#===========================================================================
# Dataguard LIVE config
# =========================================================================
#log_archive_dest_2 = 'SERVICE=ACC2_SHARK9 reopen=120'
#log_archive_dest_state_1 = enable
#log_archive_dest_state_2 = enable
#remote_archive_enable = true
#===========================================================================
#===========================================================================
# Dataguard STANDBY config
# =========================================================================
standby_file_management=manual
remote_archive_enable=TRUE
standby_archive_dest='/u105/oradata/ACC2/archive'
Failover Step 4
At this point in the switchover process, both databases are configured as standby
databases
Failover Step 5
You can switch a physical standby database from the standby role to the primary role
when the standby database instance is either mounted in managed recovery mode or
open for read-only access. It must be mounted in one of these modes so that the
primary database switchover operation request can be coordinated.
Page 12
Failover Step 6
Shut down the target standby instance and restart it using the appropriate initialization
parameters for the primary role:
Failover Step 7
Amend init.ora
Hash out the primary dataguard config and un hash the standby config
in the init.ora
#=========================================================================
# Dataguard STANDBY config
# ========================================================================
#standby_archive_dest='/u104/oradata/ACC2/archive'
#DB_FILE_NAME_CONVERT =('/u107/oradata/ACC2/' , '/u103/oradata/ACC2/' ,
'/u109/oradata/ACC2/' , '/u103/oradata/ACC2/' ,
'/u108/oradata/ACC2/' , '/u103/oradata/ACC2/' )
#log_file_name_convert=('/u101/oradata/ACC2/' , '/u103/oradata/ACC2/' ,
'/u102/oradata/ACC2' , '/u103/oradata/ACC2/' ,
'/u104/oradata/ACC2/' , '/u103/oradata/ACC2/')
#standby_file_management=AUTO
#remote_archive_enable=TRUE
#===========================================================================
# Dataguard LIVE config
# =========================================================================
log_archive_dest_2 = 'SERVICE=ACC2_SHARK1 reopen=120'
log_archive_dest_state_1 = enable
log_archive_dest_state_2 = enable
remote_archive_enable = true
Failover Step 8
SQL> STARTUP;
The target physical standby database is now transitioned to the primary database role.
Page 13
Failover Step 8
Issue the following statement to begin managed recovery operations on the new
physical standby database:
Failover Step 9
Failover Step 10
Failover Complete
Page 14
Appendix A
control_files - Specify the path name and filename for the standby control file.
log_archive_start - Not modified. The same as the setting for the primary
database, TRUE
standby_archive_dest - Specify the location of the archived redo logs that will be
received from the primary database.
log_archive_dest_1 - Specify the location where the redo logs are to be archived
on the standby system. (If a switchover occurs and this instance becomes the
primary database, then this parameter will specify the location where the online
redo logs will be archived.)
Page 15
database INSTANCE_NAME initialization parameter.
(Refer Annexure for initialization parameter settings for primary and standby
database.)
DB_FILE_NAME_CONVERT
Parameter String
type
Syntax DB_FILE_NAME_CONVERT = [(]'string1' , 'string2' ,
'string3' , 'string4' , ...[)]
Where:
You can use as many pairs of primary and standby replacement strings
as required. You can use single or double quotation marks. The
parentheses are optional.
DB_FILE_NAME_CONVERT = ('/dbs/t1/','/dbs/t1/s_','dbs/t2/
','dbs/t2/s_')
Default None
value
Parameter Static
class
If you specify an odd number of strings (the last string has no corresponding
replacement string), an error is signalled during startup. If the filename being
converted matches more than one pattern in the pattern/replace string list, the first
matched pattern takes effect. There is no limit on the number of pairs that you can
Page 16
specify in this parameter (other than the hard limit of the maximum length of
multivalue parameters).
Set the value of this parameter to two strings. The first string is the pattern found in
the datafile names on the primary database. The second string is the pattern found in
the datafile names on the standby database.
You can also use DB_FILE_NAME_CONVERT to rename the datafiles in the clone
controlfile when setting up a clone database during tablespace point-in-time recovery
Document Information
Document Modification History:
Server:
Page 17