Restore a Cluster database from Backup using RMAN

 
Database restore from backup is one of the most important DBA skills but also one of the most rarely practiced.

Here are the steps I use to restore a RAC database (full database restore) from an RMAN backup.

1. Shutdown database cluster (using srvctl command)

srvctl stop database -d {database_name}
i.e.
srvctl stop database -d james_db

2. Clean up datafiles (full database restore). Identify datafiles by querying dba_data_files. Cleanup all datafiles including system datafile.

asmcmd
rm +JAMES_ORADATA1_DG/james_db/datafile/system.305.740844505
...
...

3. Startup database using rman and set DBID (connect to catalog if using rman catalog)

. oraenv
james_db
rman target / catalog=rmanJAMESDB/superpogi@RMANCATALOG
SET DBID 1347525542
STARTUP NOMOUNT

*DBID can be found on rman backup log.

4. Restore SPFILE (make sure you are connect to rman catalog if you are using it)

run {
set until time "to_date('13-FEB-2014','DD-MON-YYYY')";
ALLOCATE CHANNEL t1 DEVICE TYPE sbt PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
restore spfile TO '+JAMES_ORADATA1_DG' FROM 'DB_JAMES_DB_s19391_p1_t839435591' ;
release channel t1;
}

*PARMS and SBT_LIBRARY and other additional parameters ca be found on the RMAN backup log, these are specific parameters which link to third party libraries (i.e. netbackup)
*FROM ‘DB_JAMES_DB_s19391_p1_t839435591′ is the specific backupset you want your spfile to be restore from.

5. Relink the newly restored SPFILE and restart the database using step #3 earlier.

6. Restore controlfile make sure you are connect to rman catalog if you are using it)

run {
set until time "to_date('13-FEB-2014','DD-MON-YYYY')";
ALLOCATE CHANNEL t1 DEVICE TYPE sbt PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
restore controlfile FROM 'DB_CCWFMST_s19391_p1_t839435591' ;
release channel t1;
}

7.) Shutdown database via rman.

RMAN> shutdown

8.) startup mount via rman

RMAN> STARTUP MOUNT

9.) Restore database files via rman.

*Need to run this as nohup because it will take a while. Create a command file (restore_datafile.rcv) with the following contents:

run {
ALLOCATE CHANNEL t1 DEVICE TYPE sbt PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
ALLOCATE CHANNEL t2 DEVICE TYPE sbt PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
ALLOCATE CHANNEL t3 DEVICE TYPE sbt PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
ALLOCATE CHANNEL t4 DEVICE TYPE sbt PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
SEND 'NB_ORA_CLIENT=ln98202.ent.agt.ab.ca,NB_ORA_POLICY=toll8-RMAN-ln98202-ST-CCWFMST,NB_ORA_SCHED=Default-Policy-Weekly';
set until time "to_date('13-FEB-2014','DD-MON-YYYY')";
RESTORE DATABASE;
RELEASE CHANNEL t1;
RELEASE CHANNEL t2;
RELEASE CHANNEL t3;
RELEASE CHANNEL t4;
}

Execute the command file via the following command:

nohup rman target / catalog=rmanJAMESDB/superpogi@RMANCATALOG cmdfile=restore_datafile.rcv &

10.) Recover database via rman.

*Need to run this as nohup because it will take a while. Create a command file (restore_archivelogs_recover_db.rcv) with the following contents:

run {
ALLOCATE CHANNEL t1 DEVICE TYPE sbt PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
ALLOCATE CHANNEL t2 DEVICE TYPE sbt PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
ALLOCATE CHANNEL t3 DEVICE TYPE sbt PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
ALLOCATE CHANNEL t4 DEVICE TYPE sbt PARMS='BLKSIZE=1048576,SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
SEND 'NB_ORA_CLIENT=ln98202.ent.agt.ab.ca,NB_ORA_POLICY=toll8-RMAN-ln98202-ST-CCWFMST,NB_ORA_SCHED=Default-Policy-Weekly';
set until time "to_date('13-FEB-2014','DD-MON-YYYY')";
RECOVER DATABASE;
RELEASE CHANNEL t1;
RELEASE CHANNEL t2;
RELEASE CHANNEL t3;
RELEASE CHANNEL t4;
}

Execute the command file via the following command:

nohup rman target / catalog=rmanJAMESDB/superpogi@RMANCATALOG cmdfile=restore_archivelogs_recover_db.rcv &

11.) Open database:

ALTER DATABASE OPEN RESETLOGS;

If you need more help with database issues, feel free to send me an email (jimmycdo@yahoo.com) and I'll gladly help.

About Jimbart