You are on page 1of 7

Duplicate Database - RMAN Source Server - linux1 - AIA (SID) Target Server - rac1 - CLON (Duplicate database SID)

1> Take the AIA (source) backup using RMAN

rman

connect target

run { allocate channel d1 type disk maxpiecesize 2047M; backup format '/u01/oracle/rman_backup/AIA/df_t%t_s%s_p%p' database; sql 'alter system archive log current'; backup format '/u01/oracle/rman_backup/AIA/al_t%t_s%s_p%p' archivelog all; backup format '/u01/oracle/rman_backup/AIA/control%U' current controlfile; delete noprompt archivelog all backed up 2 times to device type disk; release channel d1; }

2> Create an Initialization Parameter for the Auxiliary Database

-- connect to source server

sqlplus "/ as sysdba" create pfile='/d02/oracle/AIA/ORACLE10g/dbs/initCLON.ora' from spfile;

3> Create / Start the Auxiliary Instance

Copy oracle home from source server to target server

cd /u01/rmantest/ORACLE10g scp -pr oracle@linux1:/d02/oracle/AIA/ .

mkdir -p /u01/oracle/rman_backup/AIA

cd /u01/oracle/rman_backup/AIA scp -pr oracle@linux1:/u01/oracle/rman_backup/AIA/* .

4> Create Password File for Auxiliary Database cd $ORACLE_HOME/dbs orapwd file=orapwCLON password=oracle entries=5

5> Create all needed directories for the duplicate database:

export ORACLE_SID=CLON

sqlplus "/ as sysdba"

startup nomount

6> Ensure Oracle Net Connectivity to Auxiliary Database

-- listener.ora

CLON = (ADDRESS_LIST = (ADDRESS= (PROTOCOL= IPC)(KEY= EXTPROCmanprod)) (ADDRESS= (PROTOCOL= TCP)(Host= rac1.com )(Port= 1521)) )

SID_LIST_BEST = (SID_LIST = (SID_DESC = (ORACLE_HOME= /u01/rmantest/ORACLE10g) (SID_NAME = CLON) ) (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/rmantest/ORACLE10g) (PROGRAM = extproc) )

-- tnsnames.ora CLON = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = CLON) ) ) AIA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = linux1)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = AIA) ) )

8> Mount or Open the Target Database export ORACLE_SID=AIA

$ sqlplus "/ as sysdba" SQL> select status from v$instance;

9> Ensure You Have the Necessary Backups and Archived Redo Log Files

-- To know the time from the rman backup

rem Filename: rmanstat.sql rem Purpose: List completed RMAN backups for the last 24-hours rem (use info from Dictionary - Control File Views) rem Date: 12-Feb-2000 rem Author: Frank Naude, Oracle FAQ rem -----------------------------------------------------------------------

tti "RMAN Backups for last 24-hours"

col type format a4 col handle format a35 trunc col file# format 9999 col duration format a9

select decode(BACKUP_TYPE, 'L', 'ARCH', 'D', 'DB', 'I', 'INC', 'Unknown type='||BACKUP_TYPE) TYPE, to_char(a.start_time, 'DDMON HH24:MI') start_time,

to_char(a.elapsed_seconds/60, '99.9')||' Min' DURATION, substr(handle, -35) handle, nvl(d.file#, l.sequence#) file#, nvl(d.blocks, l.blocks) blocks from SYS.V_$BACKUP_SET a, SYS.V_$BACKUP_PIECE b, SYS.V_$BACKUP_DATAFILE d, SYS.V_$BACKUP_REDOLOG l where a.start_time between sysdate-1 and sysdate and a.SET_STAMP = b.SET_STAMP and a.SET_STAMP = d.SET_STAMP(+) and a.SET_STAMP = l.SET_STAMP(+) order by start_time, file# /

10> Duplicate CLON from AIA instance

set -a LOG_FILE=CLON.log set +a ( rman < < EOF CONNECT TARGET sys/oracle@AIA

CONNECT AUXILIARY sys/oracle

RUN { set until time "to_date('OCT 31 2009 02:30:00','Mon DD YYYY HH24:MI:SS')"; SET NEWNAME FOR DATAFILE 1 TO '/u01/rmantest/CLON/data/system01.dbf'; SET NEWNAME FOR DATAFILE 2 TO '/u01/rmantest/CLON/data/undotbs01.dbf'; SET NEWNAME FOR DATAFILE 3 TO '/u01/rmantest/CLON/data/sysaux01.dbf'; SET NEWNAME FOR DATAFILE 4 TO '/u01/rmantest/CLON/data/users01.dbf'; SET NEWNAME FOR DATAFILE 5 TO '/u01/rmantest/CLON/data/example01.dbf'; set newname for tempfile 1 to '/u01/rmantest/CLON/data/temp.dbf'; DUPLICATE TARGET DATABASE TO CLON LOGFILE GROUP 1 ('/u01/rmantest/CLON/data/redo1a.log') SIZE 50M reuse, GROUP 2 ('/u01/rmantest/CLON/data/redo1b.log') SIZE 50M reuse, GROUP 3 ('/u01/rmantest/CLON/data/redo2a.log') SIZE 50M reuse, GROUP 4 ('/u01/rmantest/CLON/data/redo2b.log') SIZE 50M reuse; } EOF ) > $LOG_FILE 2>&1

You might also like