Wednesday, May 1, 2013

11GR2: DUPLICATE DATABASE USING RMAN WITHOUT CONNECTING TO TARGET (PRODUCTION)


11GR2: DUPLICATE DATABASE USING RMAN WITHOUT CONNECTING TO TARGET (PRODUCTION)
11gR2 has excellent feature to duplicate production database without connecting to Production database. This reduces risk touching production accidently as well as eliminates impacting production. Prior to 11gR2, we had to take backup of production, mount backups on Auxillary server (where prod will be duplicated) and run duplicate database rman command connecting to target (production) database. 11gR2 makes this task very easy by duplicating database without connecting to production database.
Step 1 – Backup production database.

RMAN> Configure controlfile autobackup on;
RMAN> backup database plus archivelog;

Step 2 – Copy backups to Auxillary server
This step can be done by
(a)    mounting production backup filesystem to Auxillary server OR
(b)   scp backupsets from production to Auxillary instance
We will be using our backup location as /rman_backup

Step 3 – Prepare Auxillary server instance
Create init.ora for Auxillary instance with just 1 parameter db_name as below.
db_name=CLONEDB1

Step 4 – Start Auxillary instance
$ export ORACLE_SID=CLONEDB1
$ sqlplus "/ as sysdba"
SQL> startup nomount;


Step 5 – Using RMAN connect to Auxillary instance and duplicate database
$ export ORACLE_SID=CLONEDB1
RMAN> rman Auxillary /
RMAN>
Duplicate database to CLONEDB1
spfile
set control_files=’+DGCLONEDB’
set db_file_name_convert=’+DGPRODDB’,’+DGCLONEDB′
set LOG_FILE_NAME_CONVERT=’+DGPRODDB’,’+DGCLONEDB′

set db_create_online_log_dest_1=’+DGCLONEDB′
set db_create_online_log_dest_2=’+DGCLONEDB′ 
set db_recovery_file_dest=’+DGCLONEDB_FRA’
set diagnostic_dest=’
/ora/app/oracle’
backup location ’/rman_backup/’
NOFILENAMECHECK;