Let's Join and share our day to day activities, Views, Knowledge, Questions and achievements in Oracle Database (8i / 9i / 10g or 11g)

May 9, 2012

Database Disaster Recovery using only RMAN Backups


Before we take our case to the RMAN Backups, 2 pre-conditions need to be fulfilled:

1. A Server (the same server or a new one) should be made available in a state where Oracle
Product can be installed; i.e., it should be brought online with a functional Operating System
and necessary Environment Configurations, same as how it was before the crash.

2. Same version of Oracle Product (including any patch sets) needs to be installed with which the RMAN Backup was taken. This is critical for the recovery to be successful.
For the demonstration, the Operating System used Microsoft Windows 2003 and the Oracle
Database Product used 10g R2 (10.2.0.4) Standard Edition.

The following steps would outline the procedures for recovering the Database using only RMAN Backup:
1. Create the Oracle Service
2. Create the relevant folder hierarchy under <ORACLE_BASE> directory
3. Restore the SPFILE from autobackup, and use the SPFILE to start the instance in NOMOUNT state
4. Restore the controlfile from autobackup, and MOUNT the database
5. Restore the Database from RMAN backup files
6. Recover the Database from RMAN backup files, and OPEN the database with RESETLOGS

GETTING STARTED
1. Create the Oracle Service
We need to create an Oracle Service using 'oradim' utility, without passing any PFILE information
C:\>oradim -new -sid DBTEST -intpwd DBTEST
Instance created.

NOTE: 10g onwards, we can directly specify the SPFILE for oracle service creation; thanks to the newly introduced
SPFILE option in oradim utility.

2. Create the relevant folder hierarchy under <ORACLE_BASE> directory
Now, we need to create the relevant directories for Oracle Database, as follows:
a. Create BDUMP, CDUMP, and UDUMP directories under '<ORACLE_ BASE>\admin'
directory,

b. Create <DATABASE_NAME> directory under '<ORACLE_BASE>\oradata' directory; in our
case DBTEST.

3. Restore the SPFILE from autobackup, and use the SPFILE to start the
instance in NOMOUNT state
Here, we need to connect to the Recovery Manager using the ‘rman’ utility, and then start the Recovery process. First we need to set the Database ID (DBID) of the Database. At times, we may or may not know the DBID of the Database. There are 2 ways to find the DBID:

a. If RMAN Backup text logs are maintained, the DBID can be found when the initial connection
is made to the target , or


b. If autobackup is enabled and has the autobackup format set (let’s say the format is '%F'), then
the filename of the autobackup has the DBID in it.

In our case, 'c-1106578690-20100408-00' is the name of the autobackup file; so the DBID should be
'1106578690'.

Next, we need to set the autobackup location, which will help us identify the location of all the RMAN
files.
In our case, the RMAN autobackup and backup files are located at '\\testdb\dbtest\'.

C:\>set oracle_sid=DBTEST
C:\>rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Apr 8 11:40:10 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> set dbid=1106578690;
executing command: SET DBID
RMAN> startup force nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file
'C:\ORACLE\PRODUCT\10.2.0\DB_2\DATABASE\INITDBTEST.ORA'
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 1247828 bytes
Variable Size 58721708 bytes
Database Buffers 92274688 bytes
Redo Buffers 7139328 bytes
RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'\\testdb\dbtest\%F';
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
using target database control file instead of recovery catalog

NOTE: It is a good practice to generate the text logs whenever your RMAN backup runs and have the command “show all” run before the backup and “list backup” after the backup completes. This ensures that we have information on the complete set of RMAN configurations and a list of all the backups with their details in the text log.

Next, we need to restore the SPFILE from the autobackup file and then use it to restart the instance in NOMOUNT state. You can approach this in two ways, as demonstrated below:

a. Restoring the SPFILE from the autobackup to a non-default location:
We can restore the SPFILE to a non-default location by using any one of the below 2 methods:

RMAN> restore spfile to 'C:\spdbtest01.ora' from autobackup;
Starting restore at 08-APR-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: looking for autobackup on day: 20100408
channel ORA_DISK_1: autobackup found: \\testdb\dbtest\c-1106578690-20100408-
00
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 08-APR-10

OR,

RMAN> restore spfile to 'C:\spdbtest02.ora' from "\\testdb\dbtest\c-
1106578690-20100408-00";
Starting restore at 08-APR-10
using channel ORA_DISK_1
channel ORA_DISK_1: autobackup found: \\testdb\dbtest\c-1106578690-20100408-
00
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 08-APR-10

Now, we need to restart the instance in NOMOUNT state using the restored parameter file.
RMAN> shutdown immediate
Oracle instance shut down

Remember that we have just restored the SPFILE in a non-default location and hence we would require referring a PFILE that should be referencing the SPFILE, so as to start the instance. For this, we need to create a text file, 'init<SID>.ora', and then mention the path and name of the restored SPFILE in it. In our case, the ‘initDBTEST.ora’ would contain only the following statement:

SPFILE=C:\spdbtest01.ora

Next, we need to start the instance in NOMOUNT state using the newly created PFILE (referencing the SPFILE).

RMAN> startup force pfile=’C:\initDBTEST.ora’ nomount
Oracle instance started
Total System Global Area 377487360 bytes
Fixed Size 1249080 bytes
Variable Size 113246408 bytes
Database Buffers 255852544 bytes
Redo Buffers 7139328 bytes

b. Restoring the SPFILE from the autobackup to the default location:
We can restore the SPFILE to the default location (“<ORACLE_HOME>/database” in Windows) by using any one of the below 2 methods:

RMAN> restore spfile from autobackup;
Starting restore at 08-APR-10
using channel ORA_DISK_1
channel ORA_DISK_1: looking for autobackup on day: 20100408
channel ORA_DISK_1: autobackup found: \\testdb\dbtest\c-1106578690-20100408-
00
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 08-APR-10

OR,

RMAN> restore spfile from "\\testdb\dbtest\c-1106578690-20100408-00";
Starting restore at 08-APR-10
using channel ORA_DISK_1
channel ORA_DISK_1: autobackup found: \\testdb\dbtest\c-1106578690-20100408-
00
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 08-APR-10

The SPFILE has been restored in the DATABASE directory of the default home location. Oracle will now automatically look for an SPFILE in this location when you try to start the instance

RMAN> shutdown immediate
Oracle instance shut down

Start the instance in NOMOUNT state. Here, we do not need to reference any PFILE or SPFILE, which makes the task a lot simpler.
RMAN> startup force nomount;
Oracle instance started
Total System Global Area 377487360 bytes
Fixed Size 1249080 bytes
Variable Size 113246408 bytes
Database Buffers 255852544 bytes
Redo Buffers 7139328 bytes

Once the database is restarted in NOMOUNT state, we need to restore the controlfiles so as to restore and recover the database using the RMAN Backups.
Again here, we can restore the controlfiles by using any one of the below 2 methods:

RMAN> restore controlfile from autobackup;
Starting restore at 08-APR-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
recovery area destination: C:\oracle\flash_recovery_area
database name (or database unique name) used for search: DBTEST
channel ORA_DISK_1: no autobackups found in the recovery area
channel ORA_DISK_1: looking for autobackup on day: 20100408
channel ORA_DISK_1: autobackup found: \\testdb\dbtest\c-1106578690-20100408-00
channel ORA_DISK_1: control file restore from autobackup complete
output filename=C:\ORACLE\ORADATA\DBTEST\CONTROL01.CTL
output filename=C:\ORACLE\ORADATA\DBTEST\CONTROL02.CTL
output filename=C:\ORACLE\ORADATA\DBTEST\CONTROL03.CTL
Finished restore at 08-APR-10

OR,

RMAN> restore controlfile from "\\testdb\dbtest\c-1106578690-20100408-00";
Starting restore at 08-APR-10
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:10
output filename=C:\ORACLE\ORADATA\DBTEST\CONTROL01.CTL
output filename=C:\ORACLE\ORADATA\DBTEST\CONTROL02.CTL
output filename=C:\ORACLE\ORADATA\DBTEST\CONTROL03.CTL
Finished restore at 08-APR-10

5. Restore the Database from RMAN backup files
With the restored controlfiles, we are now in a position to restore the Database. We need to mount the Instance first and then restore the database files from the backup.

RMAN> alter database mount;
database mounted
RMAN> restore database;
Starting restore at 08-APR-10
Starting implicit crosscheck backup at 08-APR-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 08-APR-10
Starting implicit crosscheck copy at 08-APR-10
using channel ORA_DISK_1
Finished implicit crosscheck copy at 08-APR-10
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to C:\ORACLE\ORADATA\DBTEST\SYSTEM01.DBF
restoring datafile 00002 to C:\ORACLE\ORADATA\DBTEST\UNDOTBS01.DBF
restoring datafile 00003 to C:\ORACLE\ORADATA\DBTEST\SYSAUX01.DBF
restoring datafile 00004 to C:\ORACLE\ORADATA\DBTEST\USERS01.DBF
restoring datafile 00005 to C:\ORACLE\ORADATA\DBTEST\TOOLS01.DBF
restoring datafile 00006 to C:\ORACLE\ORADATA\DBTEST\ORT_TBSP01.DBF
restoring datafile 00007 to C:\ORACLE\ORADATA\DBTEST\OR_TBSP01.DBF
restoring datafile 00008 to C:\ORACLE\ORADATA\DBTEST\OR_TBSP02.DBF
restoring datafile 00009 to C:\ORACLE\ORADATA\DBTEST\OR_TBSP03.DBF
restoring datafile 00010 to C:\ORACLE\ORADATA\DBTEST\OR_TBSP04.DBF
restoring datafile 00011 to C:\ORACLE\ORADATA\DBTEST\ORT_INDX01.DBF
restoring datafile 00012 to C:\ORACLE\ORADATA\DBTEST\ORT_INDX02.DBF
restoring datafile 00013 to C:\ORACLE\ORADATA\DBTEST\OR_INDX01.DBF
restoring datafile 00014 to C:\ORACLE\ORADATA\DBTEST\OR_INDX02.DBF
restoring datafile 00015 to C:\ORACLE\ORADATA\DBTEST\OR_INDX03.DBF
restoring datafile 00016 to C:\ORACLE\ORADATA\DBTEST\OR_TEST01.DBF
restoring datafile 00017 to C:\ORACLE\ORADATA\DBTEST\PY_TBSP01.DBF
restoring datafile 00018 to C:\ORACLE\ORADATA\DBTEST\IT_INDX01.DBF
restoring datafile 00019 to C:\ORACLE\ORADATA\DBTEST\IT_TBSP01.DBF
restoring datafile 00020 to C:\ORACLE\ORADATA\DBTEST\PY_TBSP02.DBF
restoring datafile 00021 to C:\ORACLE\ORADATA\DBTEST\PY_INDX01.DBF
channel ORA_DISK_1: reading from backup piece
\\TESTDB\DBTEST\DBTEST_04LAJPNP_1_1_20100408
channel ORA_DISK_1: restored backup piece 1
piece handle=\\TESTDB\DBTEST\DBTEST_04LAJPNP_1_1_20100408
tag=TAG20100408T110945
channel ORA_DISK_1: restore complete, elapsed time: 00:31:38
Finished restore at 08-APR-10

Once restoration of the database is complete, we need to recover the database by applying the archivelogs from the backup.

RMAN> recover database;
Starting recover at 08-APR-10
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=32
channel ORA_DISK_1: reading from backup piece
\\TESTDB\DBTEST\DBTEST_05LAJR4F_1_1_20100408
channel ORA_DISK_1: restored backup piece 1
piece handle=\\TESTDB\DBTEST\DBTEST_05LAJR4F_1_1_20100408
tag=TAG20100408T113335
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
archive log
filename=C:\ORACLE\FLASH_RECOVERY_AREA\DBTEST\ARCHIVELOG\2010_04_08\O1_MF_1_32_
5VVJG77X_.ARC thread=1 sequence=32
channel default: deleting archive log(s)
archive log
filename=C:\ORACLE\FLASH_RECOVERY_AREA\DBTEST\ARCHIVELOG\2010_04_08\O1_MF_1_32_
5VVJG77X_.ARC recid=33 stamp=715790711
unable to find archive log
archive log thread=1 sequence=33
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/08/2010 14:45:21
RMAN-06054: media recovery requesting unknown log: thread 1 seq 33 lowscn
27801294
Don't panic when you see the above Error Message. You just need to open the database with
RESETLOGS option, as there are no more archivelogs to apply.

RMAN> alter database open resetlogs;
database opened

The Database Disaster Recovery using RMAN is now complete.

12 comments:

  1. I wanted to thank you for this great read!! I definitely enjoying every little bit of it
    I have you bookmarked to check out new stuff you post…

    Here is my page: vids.vstroker.com

    ReplyDelete
  2. Hurrah, that’s what I was exploring for, what a
    stuff! existing here at this blog, thanks admin of this web site.


    My web page; http://fickworld18.com/index.php?do=/blog/34744/how-you-can-save-cash-through-coupon-codes/
    my webpage > familylinkmobile.com

    ReplyDelete
  3. Hi there, I found your ωeb site vіa Google ωhilѕt searchіng for a rеlated
    matter, уоur web sitе got here
    up, it seems greаt. Ι've bookmarked it in my google bookmarks.
    Hello there, simply turned into aware of your weblog through Google, and located that it's
    reаlly іnformative. I'm gonna be careful for brussels. I will be grateful when you continue this in future. Many folks can be benefited out of your writing. Cheers! http://Www.tinnitus411.com/pulsatile-tinnitus/

    ReplyDelete
  4. He became fascinated with the legendary virility and forcefulness
    of the pioneers top products in the male sweetening battleground is the maleextra capsules.
    citizenry volition posting a decent, farsighted, deep member
    running down your kegel is the fill in diametric.
    An all-natural and herb tea pill wish maleextra that contains all the major, of those diets that numerate on Victimization the names of Illustrious institutions or Noted citizenry in fiat to advertize
    sappy ideas.

    Here is my homepage ... Web Page

    ReplyDelete
  5. I reаd thiѕ article fullу οn the topіc οf the diffеrеnce of most up-to-ԁаte and
    precedіng tесhnologiеs, іt's remarkable article. mouse click the next site

    ReplyDelete
  6. Hi there, I want to subscribe for this webpage tο obtain neweѕt updatеs, ѕο
    where can i do it pleаѕе help.

    Also visit my web ρаge ... raspberry ketone

    ReplyDelete
  7. Ӏt's really a cool and helpful piece of information. I am happy that you simply shared this helpful info with us. Please stay us up to date like this. Thanks for sharing. www.twinkiz.com

    ReplyDelete
  8. Gгеate post. Keеρ writing
    such kіnd of info on your рage. Im rеally impressed bу it.

    Hi theгe, Υou hаve done а fаntastic јob.

    I will сeгtaіnly dіgg it and іndivіduallу suggeѕt to my
    frіеnds. I am confiԁent they'll be benefited from this website.

    Here is my weblog vistaprint coupon code

    ReplyDelete
  9. Hi, i feel that i saw you visitеd my websitе thuѕ і
    сame to go back the desire?.I am аttemptіng tο fіnd іssues tο іmprοve my web sitе!
    I guess its ok to make use of some оf your іdeаѕ!
    !

    Fеel freе to surf to my web ѕite
    :: universal life insurance

    ReplyDelete
  10. I simply couldn't leave your website before suggesting that I extremely enjoyed the standard info an individual provide in your guests? Is gonna be back incessantly to inspect new posts

    my page - Roland Garros

    ReplyDelete
  11. Have you ever thought about including a little
    bit more than just your articles? I mean, what you say is valuable and
    everything. Nevertheless think about if you added some great visuals or video clips
    to give your posts more, "pop"! Your content is excellent but with pics and clips, this
    site could certainly be one of the greatest in its field.
    Very good blog!

    My page; voyance par telephone

    ReplyDelete
  12. I always emailed this website post page to all my friends, because if
    like to read it next my contacts will too.

    My web blog ... voyance par telephone

    ReplyDelete