Académique Documents
Professionnel Documents
Culture Documents
Dear friends,
As we all know, Cloning of a Database can be done using different backup methods i.e.
using cold backup/hot backup (ALTER TABLESPACE <tablespace_name> BEGING
BACKUP), and RMAN Backup with DUPLICATE TARGET DATABASE.
Recently I have performed the cloning for one of our University databases using the
RMAN backup and DUPLICATE TARGET DATABASE commands, on the same host
i.e. same server.
Important Note: It is recommended NOT to clone the production database on the same
server or host. But as a practice you can do it for any non-prod instances.
DB Name: PROD
DB Version: Oracle 10g Release 2 (10.2.0.1)
OS Version: Red Hat Enterprise Linux (RHEL) – 4
$ su – oracle
$ export ORACLE_HOME=/u01/app/oracle/product/10.2.0
$ export ORACLE_SID=prod
$ echo $ORACLE_HOME
Note: Oracle user has a profile (.bash_profile) in which all required environment
variables are set, whenever the oracle user logs in to the server the environment
variables are set automatically.
:q!
$ sqlplus / as sysdba
Here in our case the database is already configured for Archive log mode, and the archive log
destination is used by Flash Recovery Area.
If your DB is in no Archive log mode then change the mode to Archive log.
DB_RECOVERY_FILE_DEST=/u03/FRA
DB_RECOVERY_FILE_DEST_SIZE=4G
$ sqlplus / as sysdba
$ export ORACLE_SID=prod
$ rman target /
This command will take the backup of all database files and archived log files, and place them in
flash recovery area (/u03/FRA/PROD/backupsets/__
To check and list the backup taken previously using RMAN’s LIST commands.
Copy the target database init.ora file and rename it corresponding to you clone
instance.
$ cd $ORACLE_HOME/dbs
Note: If you do not find the init.ora file for your target instance under the directory
$ORACLE_HOME/dbs, may be you are using spfile or the init.ora file might have kept
somewhere in another location;
If the spfile is being used, then create the pfile from spfile
$ cp –p initPROD.ora initTEST.ora
Edit the initialization parameter file (initTEST.ora) and update the following
parameters accordingly to your clone instance.
USER_DUMP_DEST=
BACKGROUND_DUMP_DEST=
AUDIT_FILE_DEST=
CORE_DUMP_DEST=
USER_DUMP_DEST=
CONTROL_FILES=
DB_NAME=
INSTANCE_NAME=
SERVICE_NAMES=
DB_FILE_CONVERT_NAME=
LOG_FILE_CONVERT_NAME=
Note: In general, cloned instances are not kept in archive log mode, so you can remove or
comment both parameters related to FRA, DB_RECOVERY_FILE_DEST and
DB_RECOVERY_FILE_DEST_SIZE
$ export ORACLE_SID=test
$ cd $ORACLE_HOME/dbs
Note: Make sure that the Production (Target) password and Test (Clone) password for
orapwd file must be same.
Prepare the listener and tnanemes.ora entries for clone (TEST) instance.
$ cd $ORACLE_HOME/network/admin
Open listener.ora file and add the TEST instance entry as below.
(SID_DESC =
(SID_NAME = test)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0)
)
Open tnsnames.ora file and add the TEST instance entry as below.
test =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = unicorn.kware) (PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME =test)
)
)
$ tnsping test
$ export ORACLE_SID=test
$ sqlplus / as sysdba
INSTANCE_NAME
-------------------------
test
$ export ORACLE_SID=prod
$ rman target / auxiliary sys/sys@test
RMAN> RUN
2> {
3> ALLOCATE AUXILIARY CHANNEL AUX1 DEVICE TYPE DISK;
4> DUPLICATE TARGET DATABASE TO 'test';
5> }
Above command output will be a self explanatory, please go through the output
generated.
RMAN> exit;
Execute the below steps in Test (Clone) instance, and cross check the result with the
Production (Target) instance.
$ export ORACLE_SID=test
$ sqlplus / as sysdba
SQL> SELECT OPEN_MODE,NAME FROM V$DATABASE;
If you find invalid objects then you can compile them using
$ORACLE_HOME/rdbms/admin/utlrp.sql