Restore Controlfile and Spfile | Oracle RMAN ( Recovery Manager ) Restore Recover Tutorials -2

Hi,

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.

 

https://ittutorial.org/2019/03/27/oracle-rman-recovery-manager-backup-tutorials-8/

 

then read first article of this tutorial series with following link.

https://ittutorial.org/2019/03/28/oracle-rman-recovery-manager-restore-recover-tutorials-1/

 

 

 

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.

  1. Startup Oracle Instance in nomount mode with pfile or spfile.
  2. Restore controlfile in nomount mode and then mount database.
  3. Restore database in mount mode and then datafiles are restored.
  4. Restore archivelogs in mount mode and then archivelogs are restored.
  5. Recover database in mount mode and then transactions in the redo log files are applied to the database to roll it forward.
  6. Open database with resetlogs mode and database are opened from backup.

 

Now lets assume that database is dropped like following link.

https://ittutorial.org/2019/03/28/how-to-drop-database-in-oracle-19c/

 

 

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.

 

[oracle@MehmetSalih backup]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Tue Mar 26 07:21:14 2019
Version 19.2.0.0.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.

https://ittutorial.org/oracle-database-19c-tutorials-for-beginners/

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected].-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  [email protected] a mail atabilirsiniz.

One comment

  1. you’re in reality a excellent webmaster. The website loading pace is incredible. It sort of feels that you’re doing any unique trick. Also, The contents are masterwork. you have done a fantastic task in this subject!

Leave a Reply

Your email address will not be published. Required fields are marked *