Wednesday 16 March 2016

RECOVERY SCENARIO: Complete loss of all database files including SPFILE using RMAN

Database Details
------------------

Database Name=RMAN

DBID=1792754794

//How to find DBid  ?
select dbid from v$database


Overview


  • Restore the spfile from the autobackup
  • Restore the controlfile from the autobackup
  • Restore the data files
  • Recover by applying archived redo log files
  • Open the database with resetlogs



Make sure u have taken a Full Database Backup using following command
RMAN> backup database plus archivelog;

  SIMULATING CRASH------------------------


[oracle@oracleasm1 rman]$ ls –l                                                 *LIST FILES
total 2173800
-rw-r-----. 1 oracle asmadmin  10076160 Mar 16 12:23 control01.ctl
-rw-r-----. 1 oracle asmadmin  52429312 Mar 16 12:16 redo01.log
-rw-r-----. 1 oracle asmadmin  52429312 Mar 16 12:20 redo02.log
-rw-r-----. 1 oracle asmadmin  52429312 Mar 16 12:23 redo03.log
-rw-r-----. 1 oracle asmadmin 545267712 Mar 16 12:21 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 734011392 Mar 16 12:21 system01.dbf
-rw-r-----. 1 oracle oinstall 702554112 Mar 12 23:54 system_bkp.dbf
-rw-r-----. 1 oracle asmadmin  20979712 Mar 16 11:39 temp01.dbf
-rw-r-----. 1 oracle asmadmin  57679872 Mar 16 12:21 undotbs01.dbf
-rw-r-----. 1 oracle asmadmin   5251072 Mar 16 12:21 users01.dbf

[oracle@oracleasm1 rman]$ rm *

[oracle@oracleasm1 rman]$ ls -l
total 0                                                                                      *FILES REMOVED


[oracle@oracleasm1 dbs]$ ls -l spfile*                       *MY ALL SPFILE
-rw-r-----. 1 oracle asmadmin 1536 Mar  7 15:33 spfileasmdb.ora
-rw-r-----. 1 oracle oinstall 2560 Mar 12 21:30 spfiledemodb.ora
-rw-r-----. 1 oracle oinstall 2560 Mar  7 00:01 spfilemydb.ora
-rw-r-----. 1 oracle asmadmin 2560 Mar 13 18:26 spfilenewdb.ora
-rw-r-----. 1 oracle asmadmin 2560 Mar 11 23:13 spfileorcl.ora
-rw-r-----. 1 oracle asmadmin 4608 Mar 15 17:45 spfileprim1.ora
-rw-r-----. 1 oracle asmadmin 2560 Mar 16 12:15 spfilerman.ora
-rw-r-----. 1 oracle asmadmin 4608 Mar 14 22:21 spfilestan1.ora

[oracle@oracleasm1 dbs]$ mv spfilerman.ora spfilerman_del.ora
                                                                                    *SPFILE REMOVED


ALERT LOG will start showing ERROR messages


ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/rman/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL> shutdown abort



SQL> !rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Mar 16 12:29:55 2016
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database (not started)

Step 1:           SET DBid and OPEN DATABASE in NOMOUNT mode

RMAN> SET DBID=1792754794

RMAN> run {
2> startup nomount force;
3> }

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initrman.ora'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area     159019008 bytes

Fixed Size                     1335192 bytes
Variable Size                 75497576 bytes
Database Buffers              79691776 bytes
Redo Buffers                   2494464 bytes


Step 2:           RESTORE SPFILE  &  CONTROL-FILE

RMAN> run {
 restore spfile from '/u01/app/oracle/flash_recovery_area/RMAN/autobackup/2016_03_16/o1_mf_s_906639844_cgl0rg16_.bkp';
 }

Starting restore at 16-MAR-16
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/flash_recovery_area/RMAN/autobackup/2016_03_16/o1_mf_s_906639844_cgl0rg16_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 16-MAR-16

RMAN> run {
 restore controlfile from '/u01/app/oracle/flash_recovery_area/RMAN/autobackup/2016_03_16/o1_mf_s_906639844_cgl0rg16_.bkp';
 }

Starting restore at 16-MAR-16
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/cntrlrman.dbf
Finished restore at 16-MAR-16

Step 3:           MOUNT THE DATABSE & RESTORE OF DATABASE

Since you have the controlfiles now mount the database

RMAN> alter database mount ;

database mounted
released channel: ORA_DISK_1

RMAN> restore database ;

RMAN> recover database ;



Step 4:           OPEN THE DATABASE WITH RESETLOGS;


RMAN> exit


SQL> alter database open resetlogs ;


Dont Forget to take a Whole DB backup after issuing ResetLogs : )



See Also

No comments:

Post a Comment