Saturday 14 June 2014

rman duplicate command for rman cloning(Robustness of ORACLE Technology)



ROBUSTNESS OF ORACLE TECHNOLOGIES : PART1
* Cloning Oracle Database  using backup based duplication
----------------------------------------------------------------------------
I was wondering about the cloning of oracle database using rman which directly converts the database name from ‘X’ to ‘Y’.
For example If I have a production database named PROD, I want to clone it to a new server for testing and the database name I want to keep as TEST.  
Is it possible using rman? If Yes, how can we do ?
The answer is yes and in fact it is the simplest way of doing cloning using rman duplicate command.
There are various ways to use rman duplicate command for database cloning depending on your requirement and availability.
Here are the ways:
Broad classification:
·         Backup based Duplication (only requires backup piece full with archivelog. Source database connection does require)
·         Active duplication (connection to source is required, no backups required )
  In my scenario I had only database rman full backup with archivelog(backup database plus archivelog) was there.
So I did the following steps to clone :
Environment:
Source DB
Target DB
PROD
TEST
DB_FILE_NAME_CONVERT=/u01/PROD/oradata
DB_FILE_NAME_CONVERT=
/u02/TEST/oradata
LOG_FILE_NAME_CONVERT=/u01/PROD/oradata
LOG_FILE_NAME_CONVERT=
/u01/TEST/oradata

I created a initialization parameter file initTEST.ora set the parameter according to TEST database server filesystem.


Added the following parameters in the initTEST.ora
DB_NAME= ‘TEST’
DB_FILE_NAME_CONVERT==’/u01/PROD/oradata’,’/u02/TEST/oradata’
LOG_FILE_NAME_CONVERT=’/u01/PROD/oradata’,’/u02/TEST/oradata’
I have created password file for TEST DATABASE
$cd $ORACLE_HOME/dbs
$orapwd file=orapwTEST password=system$

Copied the backup pieces from PROD to TEST Database location
‘/backup/PROD’
Now we are ready for Backup based duplication
I have started the TEST database with startup nomount.
Then I connected auxiliary database
$rman AUXILIARY /

Rman>duplicate database PROD dbid=123455 to TEST
      BACKUP LOCATION=‘/backup/PROD’
      NOFILENAMECHECK;

At the end it has started with database with name TEST

WOW!!!! It is awesome. It has reduced many steps unlike my previous way of doing rman restore manually.

If I would have used active duplication I would have to use the below rman command
$rman TARGET sys/password@source AUXILIARY /
 
Before running the above command I would have to configure listener and 
tnsnames.ora file for connecting to PROD database.
 
Then, for cloning here would be the command
 
RMAN>DUPLICATE TARGET DATABASE TO TEST
  SPFILE 
  NOFILENAMECHECK;
 
Please feel free to ask at viewssharings.blogspot.in@gmail.com

No comments:

Post a Comment