Kiran 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.
1 2 | [grid@prim~]$ crsctl check crs [grid@prim~]$ crsctl status resource -t |
Restore Cluster Database
1. Make a Directory in Disk Group
Make sure that we have a backup set of the database.
1 2 | [grid@prim~]$ asmcmd mkdir +DATA/PRIM [grid@prim~]$ asmcmd ls -l +DATA |
1 | [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.
1 | [oracle@prim~]$ srvctl disable database -d prim |
3. Startup a Dummy Instance
We need a dummy instance to restore SPFILE from a backup piece.
1 2 3 | [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.
1 2 3 4 5 | 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.
1 2 3 | 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.
1 | RMAN> startup nomount pfile= '/tmp/initprim.ora' ; |
7. Restore Controlfile
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.
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.
10. Restore SPFILE to ASM Diskgroup
We have to know the location of SPFILE before we create it.
This is a pointer of SPFILE, the technique is adopted by RAC.
Now we can create SPFILE from the modified PFILE.
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.
1 2 3 4 5 | RMAN> restore controlfile from '/backup/PRIM_968055037_08u52b7j_1_1' ; Then we shutdown the instance. RMAN> shutdown immediate; Oracle instance shut down |
1 2 3 | [oracle@prim~]$ vi /tmp/initprim.ora ... *.control_files= '+DATA/PRIM/CONTROLFILE/current.276.1012058301' |
1 | RMAN> startup mount pfile= '/tmp/initprim.ora' ; |
1 2 | [oracle@prim~]$ cat $ORACLE_HOME /dbs/init $ORACLE_SID .ora SPFILE= '+DATA/PRIM/spfilePRIM.ora' |
1 2 3 | RMAN> create spfile= '+DATA/PRIM/spfileprim.ora' from pfile= '/tmp/initprim.ora' ; Statement processed |
1 | [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.
Check SPFILE of current instance.
12. Catalog the Backup Set
Before we can use the backup set to restore the database, controlfiles need to know their existence.
13. Restore Data Files
Use the cataloged backup set to restore the database, specifically, data files.
14. 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.
Then we shutdown the instance.
1 2 3 4 5 6 | RMAN> shutdown immediate; database dismounted Oracle instance shut down RMAN> startup mount; |
1 | SQL> show parameter spfile; |
1 | RMAN> catalog start with '/backup/' ; |
1 | RMAN> restore database; |
1 | RMAN> recover database; |
1 2 3 4 5 6 7 8 9 | RMAN> alter database open resetlogs; Statement processed RMAN> select name, open_mode from v $database ; NAME OPEN_MODE --------- -------------------- PRIM READ WRITE |
1 | RMAN> shutdown immediate; |
16. Create a New Password File
We created a new password file for the cluster database.
The configuration of the cluster database reflected the new password file.
Check the physical location of the new password file.
1 | [oracle@prim~]$ orapwd file= '+DATA' dbuniquename= 'prim' password=oracle |
1 | [oracle@prim~]$ srvctl config database -d PRIM |
1 | [grid@prim~]$ asmcmd ls -l +DATA/PRIM/PASSWORD |
ADD DATABASE TO CLUSTER and Add rac Instanses
1 2 3 4 5 | 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 |