Tuesday, October 13, 2009

Rman cloning

Introduction

Duplicate Database/Cloning Database using RMAN

You can use the RMAN DUPLICATE command create a duplicate database from target database backups while still retaining the original target database. A duplicate database is a copy of the target database that you can run independently for a variety of purposes. For example, you can use it to:
Test backup and recovery procedures
Export data such as a table that was inadvertently dropped from the production database, and then importing it back into the production database.
A duplicate database is distinct from a standby database, although both types of databases are created with the DUPLICATE command. A standby database is a copy of the primary database that you can update continually or periodically by using archived logs from the primary database. If the primary database is damaged or destroyed, then you can perform failover to the standby database and effectively transform it into the new primary database. A duplicate database, on the other hand, cannot be used in this way: it is not intended for failover scenarios and does not support the various standby recovery and failover options.

Note: Configuration and Backup must be understood prior to starting duplication using RMAN.



Steps for duplicating database using RMAN.
01. From the command prompt create a password file for the AUX database.
orapwd file=d:\oracle\ora92\database\PWDaux.ora password=oracle entries=5

2. In SQL*Plus connect as SYS create a parameter file from the spfile of the target database for the AUX database.
connect sys/oracle@orcl.world as sysdba

create pfile='d:\oracle\ora92\database\INITaux.ORA' from spfile;


3. Edit the file INITaux.ORA, found in the D:\ORALCE\ORA92\DATABASE;
change all occurrences of \orcl\ to \auxorcl\.
Next change db_name and instance_name to aux. Then add the following two lines to the parameter file:
db_file_name_convert=('D:\ORACLE\ORADATA\ORCL','D:\ORACLE\ORADATA\AUXORCL')

log_file_name_convert=('D:\ORACLE\ORADATA\ORCL','D:\ORACLE\ORADATA\AUXORCL'






4. Run script cre_dir from the command prompt to create the subdirectories for the duplicate database.
cre_dir

or create directories (bdump,cdump,udump,archive,adump) manually as path specified in the pfile.



5. Add an entry in the tnsnames.ora and listener.ora for the AUX database. Use Net Manager.
Start > Programs > Oracle - OraHome92 > Configuration and Migration Tools > Net Manager
TNSNAMES.ORA
Select Oracle Net Configuration > Local > Service Name. Then from the menu select Edit > Create. Use the following values to create the entry.
Net Service Name: aux.world

Protocol: TCP/IP (Internet Protocol)

Host:

Port: 1521

Service Name: aux.world
Since the database has not been created you can not successfully test the configuration.



LISTENER.ORA
Select Oracle Net Configuration > Local > Listeners > LISTENER. From the drop down menu on the right and side change Listener Location to Database Services. Click Add Database at the bottom. Use the following values:
Global Database Name: aux.net

Oracle Home: D:\oracle\ora92

SID: aux
Select from the top menu: File > Save Network Configuration followed by File > Exit.


6. Shutdown and startup the listener.ora. From the command prompt type the follow:
lsnrctl stop

lsnrctl start



7. Create a service for the database. From the command prompt type:
oradim -new -sid AUX -startmode m –pfile d:\oracle\ora92\database\INITaux.ORA
8. From RMAN, type the following commands.
RMAN
CONNECT AUXILIARY SYS/ORACLE@AUX.WORLD
CONNECT TARGET SYS/ORACLE@ORCL.WORLD
STARTUP CLONE NOMOUNT FORCE;
DUPLICATE TARGET DATABASE TO AUX;


9.Connect to the new database
connect hr/hr@aux.world
SELECT first_name
FROM employees;

No comments: