The duplicating of the database has gotten lot more easier with RMAN.
Assume we have copied the backup sets / backup control file / spfile into "C:\FlashRecoveryArea" in the target server Or access to the backup sets / backup control file / spfile in the network share , the process is straight forward.
Of course , there is little bit of leg work to be done before we issue RMAN's duplicate database .
Let us look at the steps below.
Step1 : Create a PFILE
In the pfile , we just the db name to "DUP2" ( this is going to be the name of the duplicated database".
C:>echo db_name='DUP2' > C:\app\mohideen\product\11.2.0\dbhome_1\database\INITDUP2.ORA
Step2: Create Oracle Instance using ORADIM
Being the duplication is done in Windows environment , we would need to create the service using oradim utility.
C:>oradim -new -sid dup2 -intpwd Orapwd$dup2
Instance created.
Step3: Create the directories to hold the datafiles , logfiles , archived redo logs , ....
C:>mkdir C:\app\mohideen\oradata\dup2\CONTROLFILE\
C:>mkdir C:\app\mohideen\oradata\DUP2\DATAFILE\
C:>mkdir C:\app\mohideen\oradata\DUP2\LOGFILE\
C:>mkdir C:\app\mohideen\oradata\dup2\ARCHIVELOG1\
C:>mkdir C:\app\mohideen\oradata\dup2\ARCHIVELOG2\
C:>mkdir C:\app\mohideen\FRA\dup2
Step4 : Set the SID to the destination database.
C:\>set ORACLE_SID=dup2
Step 5: Connect to the instance .
As there is no database associated with this instance . it should say " Connected to an idle instance" as below.
C:\>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 25 10:36:03 201
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
Step 6: Start the database in nomount state
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 313196544 bytes
Fixed Size 2254704 bytes
Variable Size 255854736 bytes
Database Buffers 50331648 bytes
Redo Buffers 4755456 bytes
SQL>
Step 7: Determine the location of the data files / log files from the source database.
SQL> select name FROM v$datafile;
NAME
----------------------------------------
E:\DATA\DBPRD\SYSTEM01.DBF
E:\DATA\DBPRD\SYSAUX01.DBF
E:\DATA\DBPRD\UNDOTBS01.DBF
E:\DATA\DBPRD\USERS01.DBF
E:\DATA\DBPRD\SYSAUX02.DBF
E:\DATA\DBPRD\TBSDW.DBF
6 rows selected.
Get the log file's location .
SQL> select MEMBER FROM v$logfile;
MEMBER
------------------------------------------------
E:\DATA\DBPRD\REDO03.LOG
E:\DATA\DBPRD\REDO02.LOG
E:\DATA\DBPRD\REDO01.LOG
These locations ( e:\data\dbprd) need to be mentioned in the RCV File created in the next step.
Step 8: Prepare the RCV file for RMAN to duplicate.
Prepare the RCV that contains the location for the Control files , flash recovery area , listener name , ADR location . Also , the file should contain the new locations for the data files / log files .
Finally , we need to provide the location where backups are stored ( c:\fastrecoveryarea ) in this case.
C:\dup_db>type dup.rcv
run
{
duplicate database to dup2
spfile
set control_files='c:\app\mohideen\oradata\dup2\CONTROLFILE\CONTROL1.CTL','c:\app\mohideen\oradata\dup2\CONTROLFILE\CONTROL2.CTL'
set db_file_name_convert='E:\DATA\DBPRD','c:\app\mohideen\oradata\DUP2\DATAFILE'
set log_file_name_convert='E:\DATA\DBPRD','c:\app\mohideen\oradata\DUP2\LOGFILE'
set db_recovery_file_dest='c:\app\mohideen\FRA\dup2\'
set LOG_ARCHIVE_DEST_2='location=c:\app\mohideen\oradata\dup2\ARCHIVELOG1\'
set LOG_ARCHIVE_DEST_3='location=c:\app\mohideen\oradata\dup2\ARCHIVELOG2\'
set diagnostic_dest='C:\app\mohideen'
set local_listener=''
backup location 'c:\FastRecoveryArea';
Step 9 : Issue RMAN Duplicate Database
Here is where the rubber meets the road ; all of your leg work pays off . RMAN duplicates the database based on the RCV file .
C:\dup_db>rman auxiliary / cmdfile dup.rcv log dup.log
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15>
C:\dup_db>
Look for any errors in the log file ( dup.log ) . You may want to look at the dup.log to see what are the steps RMAN did to perform the duplication process.
Now you have duplicated the database .
Hope this was clear .
Please email me for your feedback.
No comments:
Post a Comment