I am demonstrating a scenarion where I am using ASM and have lost spfile, controlfile and datafiles. Now my job is to restore the database from RMAN backup.
This is little tricky but not impossible. Let me explain you how this will be done:
Get the DBID of the database from recovery catalog.
Restore spfile
Update init<SID>.ora with spfile location
This is little tricky but not impossible. Let me explain you how this will be done:
- Get the DBID of the database from recovery catalog.
- Create init<SID>.ora file
- Connect to RMAN and set the DBID
- Startup nomount
- Restore spfile
- Shutdown immediate
- Update init<SID>.ora with spfile location
- Startup nomount
- Restore controlfile
- startup mount
- restore database
- recover database
- alter database open resetlogs;
Get the DBID of the database from recovery catalog.
SQL> select distinct DBID, NAME from RC_DATABASE_INCARNATION;Create init<SID>.ora file
DBID NAME
---------- --------
2410645064 RAC
1372201017 ORCL
$ cat initRAC1.ora
*.db_name=RAC
Connect to RMAN and set the DBID
[oracle@rac1 dbs]$ rman target / catalog catowner/******@rcat
Recovery Manager: Release 11.2.0
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
connected to recovery catalog database
RMAN> set dbid 2410645064;
executing command: SET DBID
database name is "RAC" and DBID is 2410645064
RMAN> list db_unique_name all;
List of Databases
DB Key DB Name DB ID Database Role Db_unique_name
------- ------- ----------------- --------------- ------------------
1861 ORCL 1372201017 PRIMARY ORCL
1 RAC 2410645064 PRIMARY RAC
1 RAC 2410645064 STANDBY RAC_STBY
RMAN>
startup nomount
RMAN> startup nomount
Oracle instance started
Total System Global Area 238034944 bytes
Fixed Size 2227136 bytes
Variable Size 180356160 bytes
Database Buffers 50331648 bytes
Redo Buffers 5120000 bytes
RMAN>
RMAN> restore spfile to '+DATA/RAC/spfileRAC.ora' from tag='TAG20140626T161003';
Starting restore at 30-JUN-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring SPFILE
output file name=+DATA/RAC/spfileRAC.ora
channel ORA_DISK_1: reading from backup piece +FRA/rac/autobackup/2014_06_26/s_851271003.263.851271009
channel ORA_DISK_1: piece handle=+FRA/rac/autobackup/2014_06_26/s_851271003.263.851271009 tag=TAG20140626T161003
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 30-JUN-14
RMAN>
Shutdown immediate
RMAN> shutdown immediate
Oracle instance shut down
RMAN>
$cat initRAC1.ora
SPFILE='+DATA/RAC/spfileRAC.ora'
Startup nomount
RMAN> startup nomountRestore controlfile
connected to target database (not started)
Oracle instance started
Total System Global Area 793350144 bytes
Fixed Size 2232552 bytes
Variable Size 394268440 bytes
Database Buffers 394264576 bytes
Redo Buffers 2584576 bytes
RMAN>
RMAN> restore controlfile;startup mount
Starting restore at 30-JUN-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: reading from backup piece +FRA/rac/autobackup/2014_06_27/s_851356825.376.851356835
channel ORA_DISK_1: piece handle=+FRA/rac/autobackup/2014_06_27/s_851356825.376.851356835 tag=TAG20140627T160025
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
output file name=+DATA/rac/controlfile/current.262.851600129
Finished restore at 30-JUN-14
RMAN>
RMAN> startup mount;restore database
database is already started
database mounted
released channel: ORA_DISK_1
RMAN>
RMAN> restore database ;recover database
Starting restore at 30-JUN-14
Starting implicit crosscheck backup at 30-JUN-14
allocated channel: ORA_DISK_1
Crosschecked 11 objects
Finished implicit crosscheck backup at 30-JUN-14
Starting implicit crosscheck copy at 30-JUN-14
using channel ORA_DISK_1
Crosschecked 2 objects
Finished implicit crosscheck copy at 30-JUN-14
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: +fra/RAC/AUTOBACKUP/2014_06_27/n_851344744.494.851344751
File Name: +fra/RAC/AUTOBACKUP/2014_06_27/s_851356825.376.851356835
File Name: +fra/RAC/AUTOBACKUP/2014_06_26/s_851271003.263.851271009
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to +DATA/rac/datafile/system.263.851343649
channel ORA_DISK_1: restoring datafile 00002 to +DATA/rac/datafile/sysaux.268.851343643
channel ORA_DISK_1: restoring datafile 00003 to +DATA/rac/datafile/undotbs1.277.851343653
channel ORA_DISK_1: restoring datafile 00004 to +DATA/rac/datafile/users.273.851343655
channel ORA_DISK_1: restoring datafile 00005 to +DATA/rac/datafile/example.278.851343653
channel ORA_DISK_1: restoring datafile 00006 to +DATA/rac/datafile/undotbs2.274.851343653
channel ORA_DISK_1: restoring datafile 00007 to +DATA/rac/datafile/hdts.279.851343653
channel ORA_DISK_1: reading from backup piece +FRA/rac/backupset/2014_06_26/nnndf0_full_db_rac_0.500.851259117
channel ORA_DISK_1: piece handle=+FRA/rac/backupset/2014_06_26/nnndf0_full_db_rac_0.500.851259117 tag=FULL_DB_RAC
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:04:05
Finished restore at 30-JUN-14
RMAN>
RMAN> recover database;alter database open resetlogs;
RMAN> alter database open resetlogs;
database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>