Blog

Restore RAC Database from RMAN Backup Set

First of all, make sure the clusterware is Up and Running.

[grid@prim~]$ crsctl check crs
[grid@prim~]$ crsctl status resource -t
 

Restore Cluster Database
1. Make a Directory in Disk Group

[grid@prim~]$ asmcmd mkdir +DATA/PRIM
[grid@prim~]$ asmcmd ls -l +DATA

Make sure that we have a backup set of the database.

[oracle@prim~]$ ll /backup

2. Detach Database from Clusterware
Since we only use one node to do the entire recovery, so we have to detach the database from the clusterware in case we trigger automatic restart during maintenance time.

[oracle@prim~]$ srvctl disable database -d PRIM

.

3. Startup a Dummy Instance

We need a dummy instance to restore SPFILE from a backup piece.

[oracle@prim~]$ rman target /

RMAN> startup nomount force; 

4. Restore SPFILE to a Local Directory
We did not restore SPFILE directly to the disk group. Instead, we restore SPFILE to a local directory, say /tmp. We will use the restored SPFILE to create a PFILE.

RMAN> restore spfile to '/tmp/spfilePRIM.ora' from '/backup/PRIM_968055037_08u52b7j_1_1';
Then shutdown the instance.
RMAN> shutdown immediate;

Oracle instance shut down

5. Create a PFILE for Later Startups
We created PFILE from this SPFILE for later operations.

RMAN> create pfile='/tmp/initPRIM.ora' from spfile='/tmp/spfilePRIM.ora';

Statement processed 

6. Startup Database to Nomount by PFILE
Then startup the database to nomount state by the PFILE.

RMAN> startup nomount pfile='/tmp/initPRIM.ora'; 

7. Restore Controlfile

RMAN> restore controlfile from '/backup/PRIM_968055037_08u52b7j_1_1';
Then we shutdown the instance.
RMAN> shutdown immediate;

Oracle instance shut down 

8. Modify PFILE
Since restored controlfile name was different from the original one under OMF’s instruction, we had to modify PFILE to align with the current controlfile name.

[oracle@prim~]$ vi /tmp/initPRIMDB.ora
...
*.control_files='+DATA/PRIM/CONTROLFILE/current.276.1012058301' 

9. Startup Database to Mount by PFILE
For restoring SPFILE correctly, we have to mount the controlfile to let ASM know the database name of current instance.

RMAN> startup mount pfile='/tmp/initPRIM.ora'; 

10. Restore SPFILE to ASM Diskgroup
We have to know the location of SPFILE before we create it.

[oracle@prim~]$ cat $ORACLE_HOME/dbs/init$ORACLE_SID.ora
SPFILE='+DATA/PRIM/spfilePRIM.ora'

This is a pointer of SPFILE, the technique is adopted by RAC.
Now we can create SPFILE from the modified PFILE.

RMAN> create spfile='+DATA/PRIM/spfileprim.ora' from pfile='/tmp/initPRIM.ora';

Statement processed

We have created SPFILE from our modified PFILE. Of course, you can also restore SPFILE from the above backup piece, but subsequently, you have to change the location of control files by ALTER SYSTEM SET CONTROL_FILES under NOMOUNT.
Why should we do so many steps above before restoring SPFILE? Why don’t we just restore SPFILE in the first place when the dummy instance is up? This is because we don’t want SPFILE to be restore to +DATA/DB_UNKNOWN directory, even though it will be working find after instance restarted.
Check the physical location of SPFILE.

[grid@prim~]$ asmcmd ls -l +DATA/PRIM

11. Restart Database to Mount
We have both SPFILE and controlfiles restored, let’s see whether they can work together as usual.

RMAN> shutdown immediate;

database dismounted
Oracle instance shut down

RMAN> startup mount;

Check SPFILE of current instance.

SQL> show parameter spfile; 

12. Catalog the Backup Set
Before we can use the backup set to restore the database, controlfiles need to know their existence.

RMAN> catalog start with '/backup/';

13. Restore Data Files
Use the cataloged backup set to restore the database, specifically, data files.

RMAN> restore database; 

14. Recover Database

 RMAN> recover database; 

The error messages are just some notifications, you can ignore them.
15. Open Database
Since this is a point-in-time recovery and we don’t have any redo logs, so we have to open the database with reset redo logs. In this step, the log sequence will be reset and redo logs are created.

RMAN> alter database open resetlogs;

Statement processed

RMAN> select name, open_mode from v$database;

NAME OPEN_MODE
--------- --------------------
PRIM READ WRITE

Then we shutdown the instance.

RMAN> shutdown immediate; 

16. Create a New Password File
We created a new password file for the cluster database.

[oracle@prim~]$ orapwd file='+DATA' dbuniquename='PRIM' password=oracle 

The configuration of the cluster database reflected the new password file.

[oracle@prim~]$ srvctl config database -d PRIM

Check the physical location of the new password file.

[grid@prim~]$ asmcmd ls -l +DATA/PRIM/PASSWORD 

17. Reattach Database to Clusterware
We reattach it to the clusterware to be a cluster-managed database.

[oracle@prim~]$ srvctl enable database -d PRIM 

18. Startup Database by Clusterware
We have already restored the database back, let’s startup the cluster database by the clusterware.

[oracle@prim~]$ srvctl start database -d PRIM
[oracle@prim~]$ srvctl status database -d PRIM

19. Check Resource Status
One last thing, we should check everything is fine by grid.

[grid@prim~]$ crsctl status resource -t 

The database is Up and Running.

Follow me

Contact us for Training/ Job Support

Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.