Restore RAC Database from RMAN Backup Set

Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
  • User AvatarKiran Dalvi
  • 18 Oct, 2022
  • 0 Comments
  • 4 Mins Read

Restore RAC Database from RMAN Backup Set

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/initprim.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 
ADD DATABASE TO CLUSTER and Add rac Instanses
srvctl add database -d prim -o $ORACLE_HOME
srvctl add instance -d prim -i prim1 -n node1
srvctl add instance -d prim -i prim2 -n node2
srvctl config database -d prim -a
srvctl modify database -d prim -spfile +DATA/PRIM/spfileprim.ora