I will tell you about the RMAN (Recovery Manager) tool that we use frequently Backup and Restore operations in Oracle Databases in this second article of my tutorial series.
Read my rman backup tutorial series before this article with following links. We will use these backups in this restore recover tutorial series.
then read first article of this tutorial series with following link.
When the database suddenly crashes, we need to restore the most recently taken Full backup then recover Database from archivelogs to open and return to before point of failure.
Restore and recover process are fully different from each other. These processes are simulated each other but they are not similar.
When we restore database, Datafiles are extracted from Full backup. But we cannot open database with restore database. Because only datafiles are restored from full backup and database needs recovery to open.
When we recover database then all transactions in the archivelog backups or redo log files are applied to the database to roll it forward.
To recover database from backup, we need to follow the steps below.
- Startup Oracle Instance in nomount mode with pfile or spfile.
- Restore controlfile in nomount mode and then mount database.
- Restore database in mount mode and then datafiles are restored.
- Restore archivelogs in mount mode and then archivelogs are restored.
- Recover database in mount mode and then transactions in the redo log files are applied to the database to roll it forward.
- Open database with resetlogs mode and database are opened from backup.
Now lets assume that database is dropped like following link.
let’s go to recover database from backup with above steps.
Firstly startup Oracle Instance in nomount mode with force option. Meanwhile you can use some sql commands in the rman command line. For example you can shutdown or startup in rman like following.
[[email protected] backup]$ rman target / Recovery Manager: Release 184.108.40.206.0 - Production on Tue Mar 26 07:21:14 2019 Version 220.127.116.11.0 Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved. connected to target database (not started) RMAN> startup force nomount startup failed: ORA-01078: failure in processing system parameters LRM-00109: could not open parameter file '/oradata/install/dbs/initDEVECI19C.ora' starting Oracle instance without parameter file for retrieval of spfile Oracle instance started Total System Global Area 1073737792 bytes Fixed Size 8904768 bytes Variable Size 281018368 bytes Database Buffers 780140544 bytes Redo Buffers 3674112 bytes
You need to set dbid to restore spfile or you can startup oracle instance with pfile.
RMAN> set dbid 4027228950 executing command: SET DBID
Restore spfile for Oracle Instance.
RMAN> RESTORE SPFILE FROM AUTOBACKUP; Starting restore at 26-MAR-19 using channel ORA_DISK_1 channel ORA_DISK_1: looking for AUTOBACKUP on day: 20190326 channel ORA_DISK_1: looking for AUTOBACKUP on day: 20190325 channel ORA_DISK_1: AUTOBACKUP found: c-4027228950-20190325-05 channel ORA_DISK_1: restoring spfile from AUTOBACKUP c-4027228950-20190325-05 channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete Finished restore at 26-MAR-19 RMAN>
Secondly You should restore controlfile from autobackup.
RMAN> restore controlfile from autobackup; Starting restore at 26-MAR-19 using channel ORA_DISK_1 channel ORA_DISK_1: looking for AUTOBACKUP on day: 20190326 channel ORA_DISK_1: looking for AUTOBACKUP on day: 20190325 channel ORA_DISK_1: AUTOBACKUP found: c-4027228950-20190325-05 channel ORA_DISK_1: restoring control file from AUTOBACKUP c-4027228950-20190325-05 channel ORA_DISK_1: control file restore from AUTOBACKUP complete output file name=/oradata/install/dbs/cntrlDEVECI19C.dbf Finished restore at 26-MAR-19 RMAN>
Or you can restore spesific controlfile with following.
RMAN> restore controlfile from '/u01/backup/ControlFilec-4027228950-20190326-02.rman'; Starting restore at 26-MAR-19 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=41 device type=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 output file name=/oradata/19c/DEVECI19C/control01.ctl output file name=/oradata/19c/DEVECI19C/control02.ctl Finished restore at 26-MAR-19
You should mount database after restore controlfile.
RMAN> alter database mount; released channel: ORA_DISK_1 Statement processed
Do you want to learn Oracle Database for Beginners, then read the following articles.
1,359 views last month, 2 views today