
Time for action – running an RMAN duplicate
Perform the following steps to create a standby database with the RMAN duplicate method:
- Check the primary database status; it must be either
open
ormount
.SQL> select db_unique_name,database_role,open_mode from v$database; DB_UNIQUE_ DATABASE_ROLE OPEN_MODE ---------- ---------------- -------------------- turkey_un PRIMARY READ WRITE
- Run the RMAN command from the standby system. Connect the primary and standby instances using Oracle Net Service names.
[oracle@oracle-stbydbs]$ rman target sys/free2go@turkey auxiliary sys/free2go@india Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jul 26 18:41:06 2012 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: ORCL (DBID=1316772835) connected to auxiliary database: ORCL (not mounted)
RMAN will show the connected sessions as shown previously, which provided the primary status—either
open
ormounted
. Also, standby is in theNOMOUNT
status. - Now execute the
DUPLICATE
command.RMAN> duplicate target database for standby from active database;
The output will be similar to the one as shown in the following screenshot:
The tail of the output logfile will be as follows:
Starting Duplicate Db at 26-JUL-12 using target database control file instead of recovery catalog allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=19 device type=DISK ... contents of Memory Script: { backup as copy current controlfile for standby auxiliary format '/u02/app/oracle/oradata/orcl/control01.ctl'; restore clone controlfile to '/u02/app/oracle/flash_recovery_area/orcl/control02.ctl' from '/u02/app/oracle/oradata/orcl/control01.ctl'; } executing Memory Script .... sql statement: alter database mount standby database ... Starting backup at 26-JUL-12 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf output file name=/u02/app/oracle/oradata/orcl/system01.dbf tag=TAG20120726T160751 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:04 channel ORA_DISK_1: starting datafile copy ... sql statement: alter system archive log current contents of Memory Script: { switch clone datafile all; } executing Memory Script datafile 1 switched to datafile copy input datafile copy RECID=2 STAMP=789667774 file name=/u02/app/oracle/oradata/orcl/system01.dbf ... Finished Duplicate Db at 26-JUL-12
Tip
When a restore is in progress, you can monitor how much is complete and how much is still pending using the
v$session_longops
view from the primary database. - Configure the primary database initialization parameters required for Data Guard.
SQL> alter system set log_archive_dest_2='SERVICE=INDIA LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=INDIA_UN' scope=both sid='*'; SQL> alter system set log_archive_config= 'DG_CONFIG=(turkey_un,india_un)' scope=both sid='*'; SQL> alter system set log_archive_max_processes=8 scope=both sid='*';
Configure the following parameters in order to make the Data Guard configuration ready for a role-change operation:
SQL> alter system set fal_server='INDIA' scope=both sid='*'; SQL> alter system set standby_file_management='AUTO' scope=both sid='*'; SQL> alter system set db_file_name_convert= '/u02/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl' scope=spfile sid='*'; SQL> alter system set log_file_name_convert= '/u02/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl' scope=spfile sid='*';
Note that the last two settings are made on
SPFILE
; therefore, a database restart is required to make the changes valid.
What just happened?
We've successfully restored the standby database with the standby role using Oracle 11g RMAN duplicate of the active database method. We've also discussed different methods used to create a standby database from primary.