• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Techgoeasy

Techgoeasy

Learn Oracle, PHP, HTML,CSS,Perl,UNIX shell scripts

  • Home
  • Oracle
    • Oracle database
    • Oracle Ebusiness Suite
    • Oracle weblogic
    • Oracle Performance Tuning
    • Oracle Hyperion
    • Oracle Cloud Tutorials
  • SQL
  • interview questions
  • Linux
  • PHP and HTML
  • Downloads
  • General
Home » Oracle » RMAN DUPLICATE DATABASE CLONING

RMAN DUPLICATE DATABASE CLONING

January 26, 2016 by techgoeasy Leave a Comment

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

Step 2

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

$scp -r [email protected]:/u01/app/oracle/recovery_area/TEST/archivelog /u01/app/oracle/recovery_area/TEST
$ scp -r [email protected]:/u01/app/oracle/recovery_area/TEST/backupset /u01/app/oracle/recovery_area/TEST
$ scp -r [email protected]:/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/[email protected] auxiliary sys/[email protected]_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

Filed Under: Oracle, Oracle Database Tagged With: RMAN DUPLICATE DATABASE CLONING

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar



Subscribe to our mailing list

Enter your email address to subscribe to this blog and receive notifications of new posts by email

Recent Posts

  • How to generate sql monitor report in Oracle
  • How to find the long running (longops session) in Oracle
  • How to find concurrent request id from Sid or spid
  • how to check recycle bin in oracle: Purge, enable/disable
  • how to check fra size in oracle: Location, usage, change size

Copyright © 2023 : TechGoEasy

  • Hire me
  • Privacy Policy
  • Contact Us
  • New? Start Here
  • About Us