Home » Oracle » RMAN DUPLICATE DATABASE CLONING

RMAN DUPLICATE DATABASE CLONING

We have already learned manual hot backup cloning.Now we will provide the cloning steps through RMAN DUPLICATE DATABASE. RMAN provides the DUPLICATE command, which uses the backups of the database to create the clone database. Files are restored to the target database, after which an incomplete recovery is performed and the clone database is opened using RESETLOGS option. All the preceding steps are performed automatically by RMAN without any intervention from the DBA.

high level steps for RMAN DUPLICATE DATABASE CLONING



(1) Take the RMAN backup of the database to be cloned
(2) Copy all the backup files to the destination server
(3) Create the tnsnames.ora and init.ora files
(4) Startup mount the database and run duplicate command to clone the database

Detailed Steps for RMAN DUPLICATE DATABASE CLONING

Let us take an example

Source Database Name: TEST
Source Database physical files path=/u001/oracle/TEST/oradata
Source Server Name: mygoeasy1

Cloned Database Name: TEST_NEW
Target Database physical files path=/u001/oracle/TEST_NEW/oradata
Source Server Name: mygoeasy1


Step 1

(a) Find out the path and names of datafiles.


SQL> select name from v$datafile;

(b) Backup the parameter file
If ‘TEST’ database is using spfile create pfile,
SQL> create pfile=’/tmp/initTEST.ora’ from spfile;
If database is using pfile, use OS command to copy the pfile to a new server location.

(c)

SQL> alter system switch logfile;
SQL> archive log list;
SQL> select SEQUENCE#,ARCHIVED,STATUS from v$log where STATUS = 'ACTIVE';

(d) Take the RMAN backup of the database

$ rman target=/
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN> BACKUP DATABASE PLUS ARCHIVELOG

The above command will take the backup of the database and archive log files . First It will take the archive log backup then datafile backup and then again final archive log backup. I am assuming here flash recovery area is set on the source database. All the backup pieces will stored there

See also  Workflow Notification Mailer Configuration in Oracle EBS

Step 2

Copy all backup pieces of ‘TEST’ database to a Destination location location.

$scp -r oracle@mygoeasy2:/u01/app/oracle/recovery_area/TEST/archivelog /u01/app/oracle/recovery_area/TEST
$ scp -r oracle@mygoeasy2:/u01/app/oracle/recovery_area/TEST/backupset /u01/app/oracle/recovery_area/TEST
$ scp -r oracle@mygoeasy2:/u01/app/oracle/recovery_area/TEST/autobackup /u01/app/oracle/recovery_area/TEST

We are keeping same location of backup on Source and destination server. Incase it is different, we need to specify the location in duplicate command
Step 3

On the Destination node

a) Copy the backup init.ora to the $ORACLE_HOME/dbs and then change the db_name,control file paths ,dump parameter and other things as neccessary

$ cd $ORACLE_HOME/dbs
$ vi initTEST_NEW.ora
db_name=TEST_NEW
control_files=/u001/oracle/TEST_NEW/oradata
….

We need to put the two below parameter extra for RMAN cloning

db_file_name_convert=(‘/u001/oracle/TEST/oradata’,’/u001/oracle/TEST_NEW/oradata’)
# This parameter specifies from where to where the datafiles should be cloned
log_file_name_convert=(‘/u001/oracle/TEST/oradata’,’/u001/oracle/TEST_NEW/oradata’)

NOTE: db_file_name_convert and log_file_name_convert parameters are required only if the source database directory structure and clone database directory structure differs.

Step 4

Configure the tnsnames.ora at the destination server


TEST_NEW =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =mygoeasy2)(PORT = 1529))
)
(CONNECT_DATA =
(SERVICE_NAME = TEST_NEW)
)
)
TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =mygoeasy1)(PORT = 1529))
)
(CONNECT_DATA =
(SERVICE_NAME = TEST)
)
)

Step 5.

Startup the database in NOMOUNT stage and start the duplicate

rman target sys/oracle@TEST auxiliary sys/oracle@TEST_NEW
RMAN> duplicate target database to ‘TEST_NEW’;


The preceding command restores all files from the backup of the target database to the clone database destination using all available archive log files and also RMAN opens the clone database with resetlogs option.

Also Reads
RMAN backup commands : Check out the RMAN Backup commands in this post. This is going to be very helpful for the person who is involved in backup and recovery
RMAN List backup commands : RMAN List backup commands are used to list the backup taken using RMAN ,Date and Time and many other details are included
Oracle RMAN interview questions : Oracle RMAN Interview Questions are must for Oracle DBA’s looking for change. Oracle Backup and recovery is one of the essential duties of Oracle DBA
RMAN Recovery Catalog : Learn how to create RMAN recovery catalog, how to register database in catalog, how to catalog archived log files on the filesystem,
RMAN-06059 : Check out how to resolve the RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
RMAN-20004 : RMAN-20004 happens when a Database has been cloned and a connection made from the clone to Catalog using rman with out changing the DBID of the clone
https://docs.oracle.com/cd/B10501_01/server.920/a96566/rcmintro.htm

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top