Tuesday, June 2, 2015

Database Cloning using RMAN

Database Cloning using RMAN:
=======================

rdbms versions should be same

1. taking the backup of the source database
2. copy the backup piecess to the target server
3. start an auxiliary instance on the target
4. create the control file
5. restore the database from backup pieces
6. open the database using reset logs

cloning is done by Manual or RMAN

RMAN
======
on primary:
. oraenv
primdb
sqlplus "/ as sysdba"

check wherther DB is in archive log mode / not

SQL> archive log list;

connect to rman and take backup

$rman
RMAN> connect target /
RMAN> backup database plus archivelog;

I have not mentioned the destination so backup will goes to FRA

on target server:
create the archive destination same as shown in rman output

on primary:
RMAN> backup current controlfile;

copy backup pieces and control file backup to insemination server.

create pfile='/tmp/initclonedb.ora' from spfile;

copy the initfile to target server
scp /tmp/initclonedb.ora oracle@server2:/$ORACLE_HOME/dbs/

on target:
cd $ORACLE_HOME/dbs
vi initclonedb.ora

chaneg primdb to clonedb

:1,$ s#primdb#clonedb#g

change the db_file_name_convert='primdb','clonedb'
change the log_file_name_convert='primdb','clonedb'

on primary:
SQL> select name from v$datafile;

on target:
create the directory structure as there in initclonedb.ora file

add entry in /etc/oratab
vi /etc/oratab

. oraenv
clonedb
sqlplus "/ as sysdba"

starting the auxiliary instance
starup nomount

show parameter service

tnsping primdb
cd /$ORACLE_HOME/network/admin
vi /tnsname.ora
primtns
{XXXXX
XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXX}

sqlplus  system/oracle@primtns

for RMAN cloning we need to connect to source as well as auxiliary instance at same time

rman
RMAN> connect auxiliary /
RMAN> connect target sys/oracle@primtns
RMAN> run
{
allocate auxiliary channel c1 device type disk;
allocate channel c2 divice type disk;
duplicate target database to 'clonedb';
}

select name, open_mode from v$database;

Regards,
Mallik

No comments:

Post a Comment

Automation Script | Archivelog Generation Hourly Monitoring

1. List out all the running databases and pic one database where we want to monitore the archive log generation from last 1 month. [oracle@o...