Setting Up A Hot Standby Database: Chris Lawson Database Specialists, Inc
Setting Up A Hot Standby Database: Chris Lawson Database Specialists, Inc
Setting Up A Hot Standby Database: Chris Lawson Database Specialists, Inc
Standby Database
Chris Lawson
Database Specialists, Inc.
www.dbspecialists.com
clawson@dbspecialists.com
Hot Standby Overview
DB1 Archive Logs DB2
Primary Standby
Read-only Read-only
Client Client Client Client
Read-only Read-only
Client Client Client Client
• Note:
– reopen=180 means wait 180 seconds before re-attempting
failed archive.
– optional means continue even if archival to second
destination fails.
Standby Control File Explanation
DB1 DB2
Primary Standby
db_file_name_convert=('/u01','/u02')
db_name=[same as primary]
lock_name_space=standby1
Needed if primary & secondary share same host
log_archive_dest_1="location=/u00/app/oracle/admin/sec/arch"
Used for manual recovery of archive logs
standby_archive_dest = /u00/app/oracle/admin/sec/arch
Typically set same as previous parameter
db_file_name_convert = ('/u01/oradata/prime','/u02/oradata/sec')
log_file_name_convert = ('/u01/prime','/u02/sec')
Prepare Standby Database
• If using password-file authentication, create password file for
standby: orapwd file=orapw[SID]
Note: Database Configuration Assistant will create init.ora file with
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE, which implies need
for the above password file.
• Connect internal, then perform startup nomount;
• Perform alter database mount standby database;
• Set standby database in Managed (automatic) Recovery Mode
recover managed standby database;
Note: Prompt will not return; documentation suggests “run on the
main console.”
• Suggestion: Put last command above in script and run as nohup.
Checking Transfer of
Archive Logs
• When the hot standby is working properly, two things are
happening:
1. Archive logs are being transferred; and
2. These logs are being automatically applied
• On the primary database, perform
alter system switch log file;
• A new archive log should appear within a few minutes in the
standby database archive location.
• If no log appears, check the alert.log for the primary database
to check for problems connecting to the standby.
• Also check v$archive_dest to confirm that all log
destinations are enabled.
Checking Application of
Archive Logs
On the standby database, review the last portion of the
alert.log. As each log is applied, there should be a new
entry listing the log number
Media Recovery Start: Managed Standby Recovery
Media Recovery Log
Media Recovery Waiting for thread 1 seq# 465
Wed Jun 21 10:48:06 2000
Media Recovery Log /u00/app/oracle/admin/db2/arch/arch_1_465.arc
Media Recovery Waiting for thread 1 seq# 466
Wed Jun 21 10:48:22 2000
Media Recovery Log /u00/app/oracle/admin/db2/arch/arch_1_466.arc
Media Recovery Log /u00/app/oracle/admin/db2/arch/arch_1_467.arc
Media Recovery Waiting for thread 1 seq# 468
Checking Application of
Archive Logs (continued)
• If logs are not being applied, be sure that the
expected archive log exists on the standby.
• If there is a “gap,” then the log should be
manually copied to the standby server, and manual
recovery performed.
• Once the gap is “plugged,” then the automatic
recovery can be restarted.
Mode Change
The standby database mode can be switched back
and forth at will:
Switch to Read-Only Mode
• First, cancel managed recovery:
recover managed standby database cancel;
• Then, set to read-only:
alter database open read only;
Switch back to Managed Recovery
(This restarts the archive log application)
• First, confirm there are no sessions active;
• Then, resume automatic recovery:
recover managed standby database;
When Disaster Strikes:
Activating Standby Database
• Important! Opening standby database will terminate the
standby recovery process.
• Reversal back to recovery processing is NOT possible, as an
implicit resetlogs is performed upon activation.
• This is very similar to what is done in a database “clone”,
running alter database open resetlogs;
• If primary still operational, eke out last archive log using
alter system archive log current;
• Manually transfer archive log if necessary, putting in archive
destination.
• Apply as many logs as are available using manual recovery:
recover standby database;
Activating Standby Database
(continued)
• Activate standby:
alter database activate standby database;
shutdown immediate;
startup mount;
alter database open read write;
• Prepare the new database for the archive mode
(presumably).
• Take physical backup of the newly activated
database.
• Set up new standby database, using the new
physical backup.
Restarting Interrupted Log Transfer
If the standby database is briefly stopped, the archive
log transfer from the primary may be interrupted, and
the transfer error may need to be manually reset.
Primary Standby
New parameter * tells
/u01/ data /u02/ data
Standby to to look in /u02
Primary Standby
/u01/ data /u02/ data Parameter corrects these files