Creating Duplicate Database Using RMAN
Creating Duplicate Database Using RMAN
TARGET Server – The machine where you have the database to be cloned. This
machine has IP address as 10.8.169.94. ORACLE_SID=TGT
RMAN Server – The machine, which is running RMAN catalog. The IP address of this
machine is 10.8.169.99. ORACLE_SID=RMND
DUPLICATE Server – The machine, which is running RMAN catalog. The IP address
of this machine is 10.8.169.96. ORACLE_SID=AUX
Following is assumed: -
- All three databases are running in ARCHIVELOG Mode. Though it is
necessary only for the TARGET database to be in ARCHIVELOG mode.
- RMAN with CATALOG has been implemented on the RMAN server.
- The target database has been registered in the RMAN CATALOG.
- The connect string for the target database is TGT
- The connect string for the auxiliary database (where duplicate is to be created
is AUX)
- The connect string for the RMAN database is RMND
- The tnsnames.ora file for all the three servers have been updated and you can
connect to any server from any server using the appropriate connect string
For the purpose of this project it is proposed that the directory structure in all the three
databases be identical. It helps to follow the principle of “KISS” (Keep it simple,
Stupid!).
In our environment, we follow the following nomenclature :-
Under “/” directory (only directories having anything to with oracle have been shown):-
Preliminary Steps
On Target Server, run these commands to make its backup directory shared:-
The /etc/exports files is read by nfs deamon and the resources mentioned therein are
mounted with the stated options.
#/etc/rc.d/init.d/nfs stop
#/etc/rc.d/init.d/portmap stop
#/etc/rc.d/init.d/portmap start
#/etc/rc.d/init.d/nfs start
On Duplicate Server, run these commands as “root” user to mount the backed up files:-
#/etc/rc.d/init.d/nfs stop
#/etc/rc.d/init.d/portmap stop
#/etc/rc.d/init.d/portmap start
#/etc/rc.d/init.d/nfs start
# mount
#su – oracle
cd /
chmod –R 755 /oraback
$cd /oraback/Hotback
$ls –al
total 1116388
drwxr-xr-x 3 oracle oradba 4096 May 19 14:25 .
drwxr-xr-x 28 root root 4096 May 12 14:46 ..
-rw-r----- 1 oracle oradba 2097152 May 19 14:25 c-342784712-200405
-rw-r----- 1 oracle oradba 212478464 May 19 14:15 TGTf_10fm5na1_1
-rw-r----- 1 oracle oradba 209715200 May 19 14:15 TGTf_11fm5na1_1
-rw-r----- 1 oracle oradba 83073536 May 19 14:15 TGTf_12fm5na1_1_
-rw-r----- 1 oracle oradba 2185728 May 19 14:15 TGTf_13fm5nbh_1_
-rw-r----- 1 oracle oradba 586088448 May 19 14:19 TGTf_14fm5nd4_1
-rw-r----- 1 oracle oradba 15769600 May 19 14:25 TGTf_15fm5nd4_1_
-rw-r----- 1 oracle oradba 27869184 May 19 14:25 TGTf_16fm5nd4_1_
-rw-r----- 1 oracle oradba 643072 May 19 14:25 TGTf_17fm5nuf_1_
-rwxr-xr-x 1 oracle oradba 2056192 May 19 14:25 snapcf_V92321.f
This command should show you the same resource as on the /oraback of TARGET server.
$ vi /opt/oracle/product/9.2.0/dbs/initTGT.ora
db_name=AUX
db_files = 80
db_file_multiblock_read_count = 8
db_block_buffers = 100
db_block_size = 8192
shared_pool_size = 3500000
log_checkpoint_interval = 10000
processes = 50
parallel_max_servers = 5
log_buffer = 32768
max_dump_file_size = 10240
global_names = TRUE
control_files = (/oradata1/ora_control1, /oradata1/ora_control2)
compatible = 9.2.0.0
undo_management=AUTO
remote_login_passwordfile= EXCLUSIVE
Ensure that the DB_BLOCK_SIZE parameter should be same and undo_management set
to “AUTO” in both the databases.
$ vi /opt/oracle/product/9.2.0/dbs/initAUX.ora
db_name=AUX
db_files = 80
db_file_multiblock_read_count = 8
db_block_buffers = 100
db_block_size = 8192
shared_pool_size = 3500000
log_checkpoint_interval = 10000
processes = 50
parallel_max_servers = 5
log_buffer = 32768
max_dump_file_size = 10240
global_names = TRUE
control_files = (/oradata1/ora_control1, /oradata1/ora_control2)
compatible = 9.2.0.0
undo_management=AUTO
remote_login_passwordfile= EXCLUSIVE
RMAN>run {
allocate channel C1 device type disk;
allocate channel C2 device type disk;
allocate channel C3 device type disk;
backup format '/oraback/%df_%U' database plus archivelog delete input;
}
After you have taken the backup, your /oraback/Hotback directory will look something
like this:-
$ cd /oraback/Hotback
$ ls -al
total 1116388
drwxr-xr-x 3 oracle oradba 4096 May 19 14:25 .
drwxr-xr-x 28 root root 4096 May 12 14:46 ..
-rw-r----- 1 oracle oradba 2097152 May 19 14:25 c-342784712-200405
-rw-r----- 1 oracle oradba 212478464 May 19 14:15 TGTf_10fm5na1_1
-rw-r----- 1 oracle oradba 209715200 May 19 14:15 TGTf_11fm5na1_1
-rw-r----- 1 oracle oradba 83073536 May 19 14:15 TGTf_12fm5na1_1_
-rw-r----- 1 oracle oradba 2185728 May 19 14:15 TGTf_13fm5nbh_1_
-rw-r----- 1 oracle oradba 586088448 May 19 14:19 TGTf_14fm5nd4_1
-rw-r----- 1 oracle oradba 15769600 May 19 14:25 TGTf_15fm5nd4_1_
-rw-r----- 1 oracle oradba 27869184 May 19 14:25 TGTf_16fm5nd4_1_
-rw-r----- 1 oracle oradba 643072 May 19 14:25 TGTf_17fm5nuf_1_
-rwxr-xr-x 1 oracle oradba 2056192 May 19 14:25 snapcf_V92321.f
To create Duplicate database, run this command immediately after you have taken the
backup. It is better to put this command in a script and call the script:-
$vi DuplicateDB.sql
run{
SET UNTIL TIME "to_date('2004/05/19 14:25:00','YYYY/MM/DD HH24:MI:SS')";
SET NEWNAME FOR DATAFILE '/oraindex1/TGT_idx01.dbf' TO '/oraindex1/AUX/TGT_idx01.dbf';
SET NEWNAME FOR DATAFILE '/oradata1/TGT_data01.dbf' TO '/oradata1/AUX/TGT_data01.dbf';
SET NEWNAME FOR DATAFILE '/opt/oracle/oradata/TGT/xdb01.dbf' TO '/oradata1/AUX/xdb01.dbf';
SET NEWNAME FOR DATAFILE '/opt/oracle/oradata/TGT/users01.dbf' TO
'/oradata1/AUX/users01.dbf';
SET NEWNAME FOR DATAFILE '/opt/oracle/oradata/TGT/tools01.dbf' TO
'/oradata1/AUX/tools01.dbf';
SET NEWNAME FOR DATAFILE '/opt/oracle/oradata/TGT/odm01.dbf' TO '/oradata1/AUX/odm01.dbf';
SET NEWNAME FOR DATAFILE '/opt/oracle/oradata/TGT/indx01.dbf' TO
'/oraindex1/AUX/indx01.dbf';
SET NEWNAME FOR DATAFILE '/opt/oracle/oradata/TGT/example01.dbf' TO
'/oradata1/AUX/example01.dbf';
SET NEWNAME FOR DATAFILE '/opt/oracle/oradata/TGT/drsys01.dbf' TO
'/oradata1/AUX/drsys01.dbf';
SET NEWNAME FOR DATAFILE '/opt/oracle/oradata/TGT/cwmlite01.dbf' TO
'/oradata1/AUX/cwmlite01.dbf';
SET NEWNAME FOR DATAFILE '/opt/oracle/oradata/TGT/undotbs01.dbf' TO
'/oradata1/AUX/undotbs01.dbf';
SET NEWNAME FOR DATAFILE '/opt/oracle/oradata/TGT/system01.dbf' TO
'/oradata1/AUX/system01.dbf';
DUPLICATE TARGET DATABASE TO AUX
LOGFILE
GROUP 1 ('/oradata1/redo01a.log','/oradata1/redo01b.log') size 10M reuse,
GROUP 2 ('/oradata1/redo02a.log','/oradata1/redo02b.log') size 10M reuse;
}
The Process
For the purpose of understanding, it should be noted that following steps will happen
during this command :-
- Allocation of channels
- Restoration of files from their present location to the new location on the
duplicate database
- Creation of controlfile
- Switching of the datafiles’ names
- Recovery of datafiles
- Deletion of input logs
- Opening the database with “RESETLOGS” option
database dismounted
Oracle instance shut down
database opened
Finished Duplicate Db at 19-MAY-04
RMAN> **end-of-file**