Tuesday, 17 December 2013

RMAN Cloning - only 4 steps


Database name: cts
Clone database name: clone

1. connect to cts database and take RMAN full backup(database must be open).

. oraenv
cts
rman
rman>connect target /

rman>backup database plus archivelog;

exit

2. Create directory structure for clone database.

2.1 cd /u01/app/oracle/admin
   
mkdir clone
cd clone

mkdir adump bdump cdump udump pfile


2.2.cd /u01/app/oracle/oradata

mkdir clone

2.3. pfile creation steps

 cd /u01/app/oracle/admin

ls -lrt

cd cts/pfile

ls -lrt

Note: if init.ora file name is different just rename the file(MV oldname init.ora)

cp init.ora /u01/app/oracle/admin/clone/pfile

cd /u01/app/oracle/admin/clone/pfile

ls -lrt

vi init.ora

press "i" to edit

change database name,audit/background/core/user dump locations, controlfile locations and dispatchers name

add below parameters:
=====================

DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/cts/','/u01/app/oracle/oradata/clone/'
LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/cts/','/u01/app/oracle/oradata/clone/'


esc+shift+:+wq  --> to save
or esc+shft+:%s/cts/clone


2.4. password file creation steps

cd /u01/app/oracle/product/10.2.0/db_1/dbs

pwd

orapwd file='/u01/app/oracle/product/10.2.0/db_1/dbs/orapwclone' password=sys entries=5

ls -lrt

Note: Make sure that CTS database also have password file.


2.5. edit the oratab entry

 vi /etc/oratab

Press "i" to edit

clone:/u01/app/oracle/product/10.2.0/db_1:N

esc+shift+:+wq  --> to save


2.6. . oraenv  --> Set the oracle environment

? clone

  (or)

export ORACLE_SID=clone
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

echo $ORACLE_SID   --> just to check the database name
echo $ORACLE_HOME  --> just to check the oracle home path

sqlplus "/as sysdba"

2.7.SQL> startup nomount pfile='/u01/app/oracle/admin/clone/pfile/init.ora';

SQL>create spfile from pfile='/u01/app/oracle/admin/clone/pfile/init.ora';

SQL>shut immediate

SQL>startup nomount

3. start listener and database entires

to check listnere status

ps -ef|grep tns

lsnrctl status LISTENER

if it is down start the listener

lsnrctl start 

to check TNS entries

tnsping cts
tnsping clone

if not pingable

cd /u01/app/oracle/product/10.2.0/db_1/network/admin/

ls -lrt
vi tnsnames.ora

put the entry for database cts and clone


4. create clone database.

. oraenv
clone

rman
rman>connet target sys/sys@cts
rman>connect auxiliary /
rman>duplicate target database to clone;

*********** end ***********