The Application DBA  

Standby Database Instantiation

Overview

The standby database can be instantiated using RMAN and the latest online backup and archivelog files from the primary database. The standby creation requires the use of a "standby controlfile" so the primary database backup needs to be made with the additional clause "include current controlfile for standby".  

With Oracle 11g the standby database can also be created live from the primary database using the “active database duplication” feature.

RMAN Primary Database Backup Script

$ORACLE_HOME/bin/rman target / nocatalog <<-EON
set snapshot controlfile name to '$ORACLE_BASE/admin/$ORACLE_SID/pfile/snap_$ORACLE_SID.ctl';
run {
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE';
set command id to 'rman_incr0_tape';
#
 backup
   incremental level = 0
   filesperset 1
   tag incr0_tape_$ORACLE_SID
   database
   include current controlfile for standby
   plus archivelog
   delete all input;
 }
 EON

RMAN Standby Database Creation Script

In order to create the standby database with RMAN the standby instance must be started in nomount mode. RMAN will then create a "duplicate" database for "standby".

#
$ORACLE_HOME/bin/rman nocatalog target sys/xxxxxx@DBNAME log=dupdb.log <<-EOF
connect auxiliary /
#
run {
   duplicate target database for standby
   nofilenamecheck
   dorecover;
}
exit;
EOF

Backup File Availability

RMAN expects to find the backups in the same place that they were created in. Depending on how backups are performed and what the media type is, additional tasks may be involved in making the backup media available for restore on a different server. In the case of disk backups this may mean copying the files to a directory that has the same name as the source, or creating a symbolic link. In the case of tape, it may mean insuring that the restore server has permisisons to access the backup tape library and has the appropriate environment variables set.

Legato NSR Requirements

For Legato environments, the NSR_CLIENT parameter will need to be set to the primary server’s host name and the standby server will have to be given explicit access permission to the primary server’s backup media in the Networker Administration utility.

Oracle 11g Active Duplication Feature

Starting in Oracle 11g the standby database can also be created live from the primary database using the “active database duplication” feature. The following script can be used for active duplication. Note that this script will create a new SPFILE and the set commands will override the settings from the primary database. An alternative is to pre-create a standby SPFILE and eliminate the "spfile" and “set” commands. This is also the strategy that can be used to re-instantiate an existing standby. The RMAN duplication will overwrite any existing control and data files if they are out of date.

Active Duplication With SPFILE Creation

#
$ORACLE_HOME/bin/rman nocatalog target sys/xxxxxx@dbsid_dg1 log=dupdb.log <<-EOF
connect auxiliary sys/xxxxxx@dbsid_dg2
#
run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate auxiliary channel stby1 type disk;
allocate auxiliary channel stby2 type disk;
#
duplicate target database
for standby
from active database
spfile
   set db_unique_name = 'ORADB_DG1'
   set control_files='/oradata/oradb/control01.ctl','/oradata/fast_recovery_area/oradb/control02.ctl'
   set fal_server = 'ORADB'
   set log_archive_dest_2 = 'SERVICE=ORADB ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORADB COMPRESSION=ENABLE'
   set log_archive_dest_state_2='DEFER'
   set db_recovery_file_dest='/oradata/fast_recovery_area'
   set memory_target='300M'
   set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=stby.llnl.gov)(PORT=1521))'
   set audit_file_dest='/oradata/admin/oradb/adump'
   set db_file_name_convert='/u02/oradata/oradb','/oradata/oradb'
   set log_file_name_convert='/u02/oradata/oradb','/oradata/oradb'
   set diagnostic_dest='/oradata'
dorecover
nofilenamecheck;
}

Active Duplication Without spfile Creation

This version can be handy when the standby already exists and it's just being re-instantiated (i.e. if using a snapshot standby).

run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate auxiliary channel stby1 type disk;
allocate auxiliary channel stby2 type disk;
#
duplicate target database
for standby
from active database
dorecover
nofilenamecheck;
}

 

Copyright 1998-2013 AppsDBA Consulting. All Rights Reserved.