You are on page 1of 7

CLONING DATABASE USING RMAN BACKUP

$ cd $ORACLE_HOME/network/admin
$ vi listener.ora
MY_LIS =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.55.219)(PORT = 6261))
)
)
)
SID_LIST_MY_LIS =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME =/u01/app/oracle/product/10.2.0.1.0)
(SID_NAME =galaxy)
)
)
$ cd $ORACLE_HOME/network/admin
$ vi tnsnames.ora

to_galaxy =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.55.219)(PORT = 6261))
)
(CONNECT_DATA =
(SERVICE_NAME =galaxy)
)
)
SQL> create tablespace rmants datafile '/u05/davedb/rmants.dbf' size 200m;
Tablespace created.
SQL>
SQL> create user rms identified by rms default tablespace rmants;
User created.
SQL>
SQL> grant connect,resource,recovery_catalog_owner to rms;
Grant succeeded.
SQL>
$ rman catalog rms/rms
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Aug 3 18:28:27 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to recovery catalog database
RMAN>
RMAN> create catalog;

recovery catalog created


RMAN> exit
$ rman catalog rms/rms target sys/admin@to_galaxy
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Aug 3 19:00:09 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: GALAXY (DBID=3423097528)
connected to recovery catalog database
RMAN>
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>
RMAN> show all;
starting full resync of recovery catalog
full resync complete
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rman/auto/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/u01/rman/backup_%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/u01/rman/backup_%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF;
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/rman/snap/snap.f';
RMAN>
RMAN>
2>
3>
4>
5>
6>

run {
backup database;
change archivelog all validate;
sql'alter system archive log current';
backup archivelog all;
}

Starting backup at 08-AUG-07


allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=22 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=21 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/product/davedb/system.dbf
input datafile fno=00005 name=/u01/product/davedb/dict.dbf
channel ORA_DISK_1: starting piece 1 at 08-AUG-07
channel ORA_DISK_2: starting full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
input datafile fno=00003 name=/u01/product/davedb/sysaux.dbf
input datafile fno=00002 name=/u01/product/davedb/undotbs.dbf

input datafile fno=00004 name=/u01/product/davedb/ts11.dbf


channel ORA_DISK_2: starting piece 1 at 08-AUG-07
channel ORA_DISK_1: finished piece 1 at 08-AUG-07
piece handle=/u01/rman/backup_0mios0bk_1_1 tag=TAG20070808T093756 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_2: finished piece 1 at 08-AUG-07
piece handle=/u01/rman/backup_0nios0bk_1_1 tag=TAG20070808T093756 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:07
Finished backup at 08-AUG-07
$ mkdir auxdb
$ cd auxdb
$ mkdir bdump cdump cdump
$ cd $ORACLE_HOME/dbs
$ cp initgalaxy.ora initauxdb.ora
$ vi initauxdb.ora
Compatible=10.2.0.1.0
Db_name=auxdb
Control_files=/u01/product/auxdb/control01.ctl
Db_block_size=2048
User_dump_dest=/u01/product/auxdb/udump
Core_dump_dest=/u01/product/auxdb/cdump
Background_dump_dest=/u01/product/auxdb/bdump
Shared_pool_size=67232153
Undo_management=auto
Undo_tablespace=undotbs
db_file_name_convert=(/u01/product/davedb,/u01/product/auxdb)
log_file_name_convert=(u01/product/davedb,/u01/product/auxdb)
remote_login_passwordfile=exclusive
~
~
~
~
"initauxdb.ora" 14L, 382C
$ orapwd file=orapw$ORACLE_SID password=admin entries=5
$
$ vi listener.ora
SID_LIST_MY_LIS =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME =/u01/app/oracle/product/10.2.0.1.0)
(SID_NAME =galaxy)
)
(SID_DESC =
(ORACLE_HOME =/u01/app/oracle/product/10.2.0.1.0)
(SID_NAME =auxdb)
)
)
$ vi tnsnames.ora
auxdb =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL=TCP) (HOST=172.16.55.219)(PORT=6261))
)
(CONNECT_DATA =
(SERVICE_NAME = auxdb)
)
)

$lsnrctl
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 08-AUG-2007 08:50:53
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> stop MY_LIS
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.55.219)(PORT=6261)))
The command completed successfully
LSNRCTL> start MY_LIS
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.55.219)(PORT=6261)))
Services Summary...
Service "auxdb" has 1 instance(s).
Instance "auxdb", status UNKNOWN, has 1 handler(s) for this service...
Service "galaxy" has 1 instance(s).
Instance "galaxy", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL>
$ export ORACLE_SID=auxdb
$ sqlplus /as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 8 08:59:59 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile=$ORACLE_HOME/dbs/initauxdb.ora
ORACLE instance started.
Total System Global Area 155189248 bytes
Fixed Size
1218220 bytes
Variable Size
96471380 bytes
Database Buffers
50331648 bytes
Redo Buffers
7168000 bytes
SQL>
$ rman catalog rms/rms target sys/admin@to_galaxy auxiliary sys/admin@auxdb
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Aug 7 18:09:32 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: GALAXY (DBID=3423097528)
connected to recovery catalog database
connected to auxiliary database: AUXDB (not mounted)
RMAN>duplicate target database to auxdb pfile=$ORACLE_HOME/dbs/initauxdb.ora;
Starting Duplicate Db at 07-AUG-07
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=35 devtype=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: sid=34 devtype=DISK
contents of Memory Script:
{
set until scn 313251;
set newname for datafile 1 to
"/u01/product/auxdb/system.dbf";

set newname for datafile 2 to


"/u01/product/auxdb/undotbs.dbf";
set newname for datafile 3 to
"/u01/product/auxdb/sysaux.dbf";
set newname for datafile 4 to
"/u01/product/auxdb/ts11.dbf";
set newname for datafile 5 to
"/u01/product/auxdb/dict.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
executing command: SET NEWNAME
Starting restore at 07-AUG-07
using channel ORA_AUX_DISK_1
using channel ORA_AUX_DISK_2
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/product/auxdb/system.dbf
restoring datafile 00005 to /u01/product/auxdb/dict.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman/backup_0fioq9kk_1_1
channel ORA_AUX_DISK_2: starting datafile backupset restore
channel ORA_AUX_DISK_2: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /u01/product/auxdb/undotbs.dbf
restoring datafile 00003 to /u01/product/auxdb/sysaux.dbf
restoring datafile 00004 to /u01/product/auxdb/ts11.dbf
channel ORA_AUX_DISK_2: reading from backup piece /u01/rman/backup_0gioq9kk_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/rman/backup_0fioq9kk_1_1 tag=TAG20070807T180403
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_AUX_DISK_2: restored backup piece 1
piece handle=/u01/rman/backup_0gioq9kk_1_1 tag=TAG20070807T180403
channel ORA_AUX_DISK_2: restore complete, elapsed time: 00:00:07
Finished restore at 07-AUG-07
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUXDB" RESETLOGS ARCHIVELOG
MAXLOGFILES
5
MAXLOGMEMBERS
5
MAXDATAFILES
100
MAXINSTANCES
1
MAXLOGHISTORY
292
LOGFILE
GROUP 1 ( '/u01/product/auxdb/redolog1a.dbf' ) SIZE 10 M REUSE,
GROUP 2 ( '/u01/product/auxdb/redolog2b.dbf' ) SIZE 10 M REUSE
DATAFILE
'/u01/product/auxdb/system.dbf'
CHARACTER SET US7ASCII
contents of Memory Script:
{

switch clone datafile all;


}
executing Memory Script
released channel: ORA_AUX_DISK_1
released channel: ORA_AUX_DISK_2
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=630007813
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=630007813
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=630007813
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=630007813

filename=/u01/product/auxdb/undotbs.dbf
filename=/u01/product/auxdb/sysaux.dbf
filename=/u01/product/auxdb/ts11.dbf
filename=/u01/product/auxdb/dict.dbf

contents of Memory Script:


{
set until scn 313251;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 07-AUG-07
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=35 devtype=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: sid=37 devtype=DISK
starting media recovery
archive log thread 1 sequence 77 is already on disk as file
/u01/product/davedb/arch/1_77_629394680.dbf
archive log thread 1 sequence 78 is already on disk as file
/u01/product/davedb/arch/1_78_629394680.dbf
archive log filename=/u01/product/davedb/arch/1_77_629394680.dbf thread=1 sequence=77
archive log filename=/u01/product/davedb/arch/1_78_629394680.dbf thread=1 sequence=78
media recovery complete, elapsed time: 00:00:02
Finished recover at 07-AUG-07
contents of Memory Script:
{
shutdown clone;
startup clone nomount pfile= '$ORACLE_HOME/dbs/initauxdb.ora';
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
sql statement: CREATE
MAXLOGFILES
5
MAXLOGMEMBERS

155189248 bytes

1218220 bytes
96471380 bytes
50331648 bytes
7168000 bytes
CONTROLFILE REUSE SET DATABASE "AUXDB" RESETLOGS ARCHIVELOG
5

MAXDATAFILES
100
MAXINSTANCES
1
MAXLOGHISTORY
292
LOGFILE
GROUP 1 ( '/u01/product/auxdb/redolog1a.dbf' ) SIZE 10 M REUSE,
GROUP 2 ( '/u01/product/auxdb/redolog2b.dbf' ) SIZE 10 M REUSE
DATAFILE
'/u01/product/auxdb/system.dbf'
CHARACTER SET US7ASCII
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/product/auxdb/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/product/auxdb/undotbs.dbf";
catalog clone datafilecopy "/u01/product/auxdb/sysaux.dbf";
catalog clone datafilecopy "/u01/product/auxdb/ts11.dbf";
catalog clone datafilecopy "/u01/product/auxdb/dict.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u01/product/auxdb/temp01.dbf in control file
cataloged datafile copy
datafile copy filename=/u01/product/auxdb/undotbs.dbf recid=1 stamp=630007823
cataloged datafile copy
datafile copy filename=/u01/product/auxdb/sysaux.dbf recid=2 stamp=630007823
cataloged datafile copy
datafile copy filename=/u01/product/auxdb/ts11.dbf recid=3 stamp=630007823
cataloged datafile copy
datafile copy filename=/u01/product/auxdb/dict.dbf recid=4 stamp=630007823
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=630007823
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=630007823
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=630007823
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=630007823
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 07-AUG-07
RMAN>

filename=/u01/product/auxdb/undotbs.dbf
filename=/u01/product/auxdb/sysaux.dbf
filename=/u01/product/auxdb/ts11.dbf
filename=/u01/product/auxdb/dict.dbf

You might also like