Tuesday, May 15, 2007

Clone Database

Create a Duplicate database with NOCATALOG on same Node

Source : LLAP
Target : llad

Steps
1. Prerequisities
Source is at least mounted

2. Init.ora configuration in duplicate database to AVOID original file being OVERWRITTEN

remote_login_passwordfile=EXCLUSIVE
db_file_name_convert =('LLAP','llad')
log_file_name_convert=('LLAP','llad')
Modify Name and location of control file
database name
instance name

create password file
startup nomount

3. Setup sqlnet configuration
add clone database entry to tnsnames.ora and listener.ora

4. Backup of Source Database

5. Get SCN/Log sequence/Time for cloning

6. Duplicate database

7. Post Duplicate Steps

Example

-- setup duplicate database enviornment(llad), source is LLAP
# create directory structure
# create init.ora file - cp init.ora init.ora
# change all references to except log_archive_????
# add following lines to init.ora
remote_login_passwordfile=EXCLUSIVE
db_file_name_convert =('LLAP','llad')
log_file_name_convert=('LLAP','llad')
# add target to oratab
# create link for init file in $ORACLE_HOME/dbs for target
# create password file in $ORACLE_HOME/dbs
orapwd file=orapw password=
# add target database to tnsnames.ora
# add target database to listerner.ora
# reload the listener
# startup nomount <-- target database
select * from v$instance


# backup source database

bkup.sh
-------
date
echo LLAP |. oraenv
cd /ora01/oracle/admin/BACKUP/llad
rman nocatalog target / cmdfile=rman_backup_LLAP_special.cmd
status=$?
date
exit $status


bkup.cmd
--------
# host 'echo Starting rman_backup_LLAP_special.cmd on rs204, `date`.';
# backup to several channels to disk
run {
allocate channel LLAP_d1 type disk format '/psoft200/oracle/BACKUP/LLAP/%U';
allocate channel LLAP_d3 type disk format '/psoft200/oracle/BACKUP/LLAP/%U';
backup setsize = 62914560
(database)
(current controlfile);
}
# host 'echo Ending rman_backup_LLAP_special.cmd on rs204, `date`.';



# get SCN
Method 1) set numwidth 18; select max(CHECKPOINT_CHANGE#) from v$backup_datafile;
2) list backup from rman
3) list backupset for database from rman


dup.sh
------
date
echo LLAP |. oraenv
cd /ora01/oracle/admin/BACKUP/llad
rman target / auxiliary "sys/manager@llad" @dup.cmd
date
exit


dup.cmd
-------
run {
set until scn 607710483792; <-- from get SCN step
duplicate target database to llad;
}

# add temp file
# rename global_name
# remove parameter added to target database for cloning
# bounce target database

References:
Metalink Note : 245262.1
72912.1
73912.1
228257.1
259694.1