Powered By Blogger

Saturday, March 28, 2009

Database Cloning

1.Backup the target database.
RMAN> run
2> {
3> allocate channel c1 device type disk format 'D:\test\db_%U';
4> backup database;
5> }

1.a. Create an Oracle Password File for the Auxiliary Instance
>orapwd file=e:\oracle\product\10.2.0\db_1\database\PWDDUP.ora password=oracle entries=2
Task 2: Establish Oracle Net Connectivity to the Auxiliary Instance
(listener and tnsname configuration)
-add database to the listener using netmanager.
-add servicename to tnsnames file.
Task 3: Create an Initialization Parameter File for the Auxiliary Instance
Task 4: create the service using oradim for auxilary database
>oradim -NEW -SID DPAX -PFILE e:\oracle\product\10.2.0\admin\DUPI\pfile\initdupi.ora -startmode a

Task 5: connect to the auxilary instance
c:\>sqlplus sys/*** as sysdba
connected to an idle instance
sql>startup nomount
.
.
.
Task 6: connect using rman to target and auxilary database.
c:\>set oracle_sid=orcl
c:\>rman target sys/***@orcl
RMAN> connect auxiliary sys/adminkurnia@dpax
connected to auxiliary database: DPAX (not mounted)

RMAN> run
2> {
3> allocate auxiliary channel c1 type disk;
4> set newname for datafile 1 to 'd:\dupdb\SYSTEM01.DBF';
5> set newname for datafile 2 to 'd:\dupdb\UNDOTBS01.DBF';
6> set newname for datafile 3 to 'd:\dupdb\SYSAUX01.DBF';
7> set newname for datafile 4 to 'd:\dupdb\USERS01.DBF';
8> set newname for tempfile 1 to 'd:\dupdb\TEMP01.DBF';
9> duplicate target database to dupdb
10> logfile group 1 ('d:\dupdb\log01.log') size 50m reuse,
11> group 2 ('d:\dupdb\log02.log') size 50m reuse,
12> group 3 ('d:\dupdb\log03.log') size 50m reuse;
13> }
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=156 devtype=DISK
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting Duplicate Db at 08-JAN-08
contents of Memory Script:
{
set until scn 340124246;
set newname for datafile 1 to
"D:\DUPDB\SYSTEM01.DBF";
set newname for datafile 2 to
"D:\DUPDB\UNDOTBS01.DBF";
set newname for datafile 3 to
"D:\DUPDB\SYSAUX01.DBF";
set newname for datafile 4 to
"D:\DUPDB\USERS01.DBF";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 08-JAN-08
channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to D:\DUPDB\SYSTEM01.DBF
restoring datafile 00002 to D:\DUPDB\UNDOTBS01.DBF
restoring datafile 00003 to D:\DUPDB\SYSAUX01.DBF
restoring datafile 00004 to D:\DUPDB\USERS01.DBF
channel c1: reading from backup piece E:\BACKUP\LEVEL_0\DEC07\DB_7FJ5IMMP_1_239
channel c1: restored backup piece 1
piece handle=E:\BACKUP\LEVEL_0\DEC07\DB_7FJ5IMMP_1_239 tag=TAG20080107T152928
channel c1: restore complete, elapsed time: 00:11:30
Finished restore at 08-JAN-08
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUPDB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( 'd:\dupdb\log01.log' ) SIZE 50 M REUSE,
GROUP 2 ( 'd:\dupdb\log02.log' ) SIZE 50 M REUSE,
GROUP 3 ( 'd:\dupdb\log03.log' ) SIZE 50 M REUSE
DATAFILE
'D:\DUPDB\SYSTEM01.DBF'
CHARACTER SET WE8MSWIN1252

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=643466915 filename=D:\DUPDB\UNDOTBS01.DBF
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=643466915 filename=D:\DUPDB\SYSAUX01.DBF
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=643466915 filename=D:\DUPDB\USERS01.DBF
contents of Memory Script:
{
set until scn 340124246;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 08-JAN-08
starting media recovery
archive log thread 1 sequence 168 is already on disk as file E:\ORACLE\PRODUCT\10.2.0\LOGARCHIVE\ARC00168_0639404466.001
channel c1: starting archive log restore to default destination
channel c1: restoring archive log
archive log thread=1 sequence=167
channel c1: reading from backup piece E:\BACKUP\ARCHIVEBACKUP\JAN07\ARC_7HJ5IN28_1_241
channel c1: restored backup piece 1
piece handle=E:\BACKUP\ARCHIVEBACKUP\JAN07\ARC_7HJ5IN28_1_241 tag=TAG20080107T153535
channel c1: restore complete, elapsed time: 00:00:16
archive log filename=E:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\DUPDB\ARCHIVELOG\2008_01_08\O1_MF_1_167_3R68YJ5C_.ARC thread=1 seq
uence=167
channel clone_default: deleting archive log(s)
archive log filename=E:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\DUPDB\ARCHIVELOG\2008_01_08\O1_MF_1_167_3R68YJ5C_.ARC recid=1 stam
p=643466927
archive log filename=E:\ORACLE\PRODUCT\10.2.0\LOGARCHIVE\ARC00168_0639404466.001 thread=1 sequence=168
media recovery complete, elapsed time: 00:00:09
Finished recover at 08-JAN-08
contents of Memory Script:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 289406976 bytes
Fixed Size 1248576 bytes
Variable Size 92275392 bytes
Database Buffers 188743680 bytes
Redo Buffers 7139328 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUPDB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( 'd:\dupdb\log01.log' ) SIZE 50 M REUSE,
GROUP 2 ( 'd:\dupdb\log02.log' ) SIZE 50 M REUSE,
GROUP 3 ( 'd:\dupdb\log03.log' ) SIZE 50 M REUSE
DATAFILE
'D:\DUPDB\SYSTEM01.DBF'
CHARACTER SET WE8MSWIN1252

contents of Memory Script:
{
set newname for tempfile 1 to
"d:\dupdb\TEMP01.DBF";
switch clone tempfile all;
catalog clone datafilecopy "D:\DUPDB\UNDOTBS01.DBF";
catalog clone datafilecopy "D:\DUPDB\SYSAUX01.DBF";
catalog clone datafilecopy "D:\DUPDB\USERS01.DBF";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to d:\dupdb\TEMP01.DBF in control file
cataloged datafile copy
datafile copy filename=D:\DUPDB\UNDOTBS01.DBF recid=1 stamp=643467074
cataloged datafile copy
datafile copy filename=D:\DUPDB\SYSAUX01.DBF recid=2 stamp=643467075
cataloged datafile copy
datafile copy filename=D:\DUPDB\USERS01.DBF recid=3 stamp=643467075
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=643467074 filename=D:\DUPDB\UNDOTBS01.DBF
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=643467075 filename=D:\DUPDB\SYSAUX01.DBF
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=643467075 filename=D:\DUPDB\USERS01.DBF
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 08-JAN-08
RMAN>
For manual cloning Refer this for step by step document:
***http://forums.oracle.com/forums/thread.jspa?threadID=245436

No comments:

Post a Comment