RMAN has the ability to duplicate, or clone, a database from a backup or from an active database. It is possible to create a duplicate database on a remote server with the same file structure, a remote server will a different file structure or the local server with a different file structure.
Active database duplication requires that the auxiliary instance have a password file. This is because the source database will be connecting directly to the auxiliary database, requiring a password file. One other key is that you want to use the same SYSDBA password as the source database . Also the destination server requires static listener configuration in a "listener.ora" file.
Active Database Duplication
Oracle 11g introduced the ability to create duplicate databases directly without the need for a backup. This is known as active database duplication. The process is similar to the backup-based duplication, with a few exceptions.First, and most obviously, you don't need a backup of the source system, but it does have to be in ARCHIVELOG mode.
Here i done my experiments in the same machine .
C:\Users\Admin>rman target sys/sys@db11g catalog rman/rman@catdb auxiliary sys/sys@clonedb
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Jan 17 11:25:30 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: DB11G (DBID=305973962)
connected to recovery catalog database
connected to auxiliary database: CLONE11G (not mounted)
RMAN> DUPLICATE TARGET DATABASE TO CLONE11G from active database;
Starting Duplicate Db at 17-JAN-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=189 device type=DISK
contents of Memory Script:
{
sql clone "alter system set db_name =
''DB11G'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''CLONE11G'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format 'D:\DATA\CLONE11G\CONTROL01.CTL';
restore clone controlfile to 'D:\DATA\CLONE11G\CONTROL02.CTL' from
'D:\DATA\CLONE11G\CONTROL01.CTL';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''DB11G'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''CLONE11G'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 534462464 bytes
Fixed Size 2177456 bytes
Variable Size 348128848 bytes
Database Buffers 176160768 bytes
Redo Buffers 7995392 bytes
Starting backup at 17-JAN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=160 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=C:\APP\ADMIN\PRODUCT\11.2.0\DBHOME_1\DATABASE\SNCFDB11G.ORA tag=TAG20140117T112848 RECID=1 STAMP=837084529
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 17-JAN-14
Starting restore at 17-JAN-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=156 device type=DISK
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 17-JAN-14
database mounted
contents of Memory Script:
{
set newname for datafile 1 to
"D:\DATA\CLONE11G\SYSTEM01.DBF";
set newname for datafile 2 to
"D:\DATA\CLONE11G\SYSAUX01.DBF";
set newname for datafile 3 to
"D:\DATA\CLONE11G\UNDOTBS01.DBF";
set newname for datafile 4 to
"D:\DATA\CLONE11G\USERS01.DBF";
backup as copy reuse
datafile 1 auxiliary format
"D:\DATA\CLONE11G\SYSTEM01.DBF" datafile
2 auxiliary format
"D:\DATA\CLONE11G\SYSAUX01.DBF" datafile
3 auxiliary format
"D:\DATA\CLONE11G\UNDOTBS01.DBF" datafile
4 auxiliary format
"D:\DATA\CLONE11G\USERS01.DBF" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 17-JAN-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=D:\DATA\DB11G\SYSTEM01.DBF
output file name=D:\DATA\CLONE11G\SYSTEM01.DBF tag=TAG20140117T112857
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=D:\DATA\DB11G\SYSAUX01.DBF
output file name=D:\DATA\CLONE11G\SYSAUX01.DBF tag=TAG20140117T112857
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=D:\DATA\DB11G\UNDOTBS01.DBF
output file name=D:\DATA\CLONE11G\UNDOTBS01.DBF tag=TAG20140117T112857
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=D:\DATA\DB11G\USERS01.DBF
output file name=D:\DATA\CLONE11G\USERS01.DBF tag=TAG20140117T112857
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 17-JAN-14
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "D:\ARCHIVE2\ARC0000000022_0836304397.0001" auxiliary format
"D:\CLONE_ARCHIVE\ARC0000000022_0836304397.0001" ;
catalog clone archivelog "D:\CLONE_ARCHIVE\ARC0000000022_0836304397.0001";
switch clone datafile all;
}
executing Memory Script
Starting backup at 17-JAN-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=22 RECID=21 STAMP=837084582
output file name=D:\CLONE_ARCHIVE\ARC0000000022_0836304397.0001 RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 17-JAN-14
cataloged archived log
archived log file name=D:\CLONE_ARCHIVE\ARC0000000022_0836304397.0001 RECID=21 STAMP=837084585
datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=837084585 file name=D:\DATA\CLONE11G\SYSTEM01.DBF
datafile 2 switched to datafile copy
input datafile copy RECID=2 STAMP=837084585 file name=D:\DATA\CLONE11G\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=3 STAMP=837084585 file name=D:\DATA\CLONE11G\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=4 STAMP=837084585 file name=D:\DATA\CLONE11G\USERS01.DBF
contents of Memory Script:
{
set until scn 1453391;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 17-JAN-14
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 22 is already on disk as file D:\CLONE_ARCHIVE\ARC0000000022_0836304397.0001
archived log file name=D:\CLONE_ARCHIVE\ARC0000000022_0836304397.0001 thread=1 sequence=22
media recovery complete, elapsed time: 00:00:00
Finished recover at 17-JAN-14
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''CLONE11G'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
shutdown clone immediate;
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 534462464 bytes
Fixed Size 2177456 bytes
Variable Size 348128848 bytes
Database Buffers 176160768 bytes
Redo Buffers 7995392 bytes
sql statement: alter system set db_name = ''CLONE11G'' comment= ''Reset to original value by RMAN'' scope=spfile
sql statement: alter system reset db_unique_name scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 534462464 bytes
Fixed Size 2177456 bytes
Variable Size 348128848 bytes
Database Buffers 176160768 bytes
Redo Buffers 7995392 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONE11G" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( 'D:\DATA\CLONE11G\REDO01.LOG' ) SIZE 50 M REUSE,
GROUP 2 ( 'D:\DATA\CLONE11G\REDO02.LOG' ) SIZE 50 M REUSE,
GROUP 3 ( 'D:\DATA\CLONE11G\REDO03.LOG' ) SIZE 50 M REUSE
DATAFILE
'D:\DATA\CLONE11G\SYSTEM01.DBF'
CHARACTER SET WE8MSWIN1252
contents of Memory Script:
{
set newname for tempfile 1 to
"D:\DATA\CLONE11G\TEMP01.DBF";
switch clone tempfile all;
catalog clone datafilecopy "D:\DATA\CLONE11G\SYSAUX01.DBF",
"D:\DATA\CLONE11G\UNDOTBS01.DBF",
"D:\DATA\CLONE11G\USERS01.DBF";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to D:\DATA\CLONE11G\TEMP01.DBF in control file
cataloged datafile copy
datafile copy file name=D:\DATA\CLONE11G\SYSAUX01.DBF RECID=1 STAMP=837084606
cataloged datafile copy
datafile copy file name=D:\DATA\CLONE11G\UNDOTBS01.DBF RECID=2 STAMP=837084606
cataloged datafile copy
datafile copy file name=D:\DATA\CLONE11G\USERS01.DBF RECID=3 STAMP=837084606
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=837084606 file name=D:\DATA\CLONE11G\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=837084606 file name=D:\DATA\CLONE11G\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=837084606 file name=D:\DATA\CLONE11G\USERS01.DBF
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 17-JAN-14
RMAN> exit
Note:-
- Auxiliary instance must be available through Oracle Net if you are duplicating from an ACTIVE database.
- Rman automatically creates a default server parameter file for the auxiliary instance if the auxiliary instance was not started with a server parameter file.