Friday, October 17, 2008

Steps to Recover DB via RMAN

Steps to Recover DB via RMAN::

Lets suppose my Original DB is PROD: and I want to duplicate this db to other system as TEST
I assume that oracle software is installed on following location. You can change according to situation.
c:\oracle\10g

1) backup target database PROD using RMAN.

2) Create password file for new db i.e. TEST

orapwd file= 'c:\oracle\10g\database\orapwTEST password=tuesday

3) Create directory structures for the clone database:

BDUMP (c:\oracle\admin\TEST\bdump)
UDUMP (c:\oracle\admin\TEST\udump)
CDUMP (c:\oracle\admin\TEST\cdump)
ADUMP (c:\oracle\admin\TEST\adump)
DATAFILES (c:\oracle\admin\TEST\PROD\datafile) (remember we have included PROD dir here)
ONLINELOG (c:\oracle\admin\TEST\PROD\onlinelog)
ARCHIVES (c:\oracle\admin\TEST\archives)
CONTROLFILE (c:\oracle\admin\TEST\paktest)

4) Copy pfile and edit it for the duplicate db.
*.db_file_name_convert=('c:\oracle\oradata\PROD',' c:\oracle\oradata\TEST ')
*.log_file_name_convert=('c:\oracle\oradata\PROD',' c:\oracle\oradata\TEST ')
*.control_files=' c:\oracle\oradata\TEST\control01.ctl',' c:\oracle\oradata\TEST\control02.ctl'
*.audit_file_dest=' c:\oracle\oradata\TEST\adump'
*.background_dump_dest=' c:\oracle\oradata\TEST\bdump'
*.core_dump_dest=' c:\oracle\oradata\TEST\cdump'
*.user_dump_dest=' c:\oracle\oradata\TEST\udump'
*.db_name='paktest'
*.instance_name='paktest'

5) Create oracle service and Startup the duplicate database in nomount stage

oradim -new -sid TEST -intpwd tuesday -startmode auto -pfile 'c:\oracle\10g\database\initTEST.ora'

set ORACLE_SID=paktest
sqlplus / as sysdba
startup nomount
exit;

6) Configure the listener and tnsnames.ora for the duplicate database. Try to connect to original database with sys user.
Also try to connect to auxiliary database with sys user.

7) We you are ok with connectivity test then connect to target and auxiliary database from command prompt as:


rman target sys/your_sys_password@PROD auxiliary sys/tuesday@TEST


8) list backupset and check all backups are available.
RMAN> list backupset of database;

9) Run the following command to duplicate the entire database. Use skip tablespace clause to exclude tablespaces.
run {
set until time "to_date('2007-08-27 18:00:00','YYYY-MM-DD HH24:MI:SS')";
allocate channel ch1 type disk;
allocate auxiliary channel ch2 type disk;
duplicate target database to paktest;
}

No comments: