Oracle RMAN 11g Backup and Recovery (94 page)

will look for the control file backup set that contains the most current SPFILE backup. Once the SPFILE is recovered, you need to shut down the instance and restart it to allow your new SPFILE

parameters to take effect. If you are using a nondefault location, then you will need to allocate a channel pointing to that location, and then you can restore the SPFILE using the same method.

When you issue the
restore spfile from autobackup
command, Oracle looks in the default location for automated control file backup sets (or in the location you defined with the
allocate
channel
command). Since you used the
set dbid
command, RMAN knows your database’s DBID.

It uses the DBID to search through the defined directory to look specifically for the most current control file backup sets for your database. When RMAN creates the control file autobackup pieces, it uses a default naming convention. The following graphic shows an example of an

270
Part II: Setup Principles and Practices

automated control file backup set piece and how the naming convention is used. Note that this naming convention does not apply to the FRA.

Keep in mind that if we are not using a recovery catalog (and if we are not using a control file, which is likely), Oracle doesn’t know for sure what the name of the most current control file backup piece is. Thus, Oracle constructs the name of the control file backup piece based on the default naming standard that is used for those backup sets (which we will document later in this chapter). Oracle will traverse the directory, looking backward in time for a control file backup set for your database. By default, Oracle looks for one created within the last ten days. If it cannot find a backup set created within that period, it generates an error. If Oracle finds a valid backup set, it proceeds to restore the SPFILE for you.

You can modify how far back RMAN looks for a control file autobackup by using the
maxseq
and
maxdays
parameters of the
restore
command. Here are a couple of examples of recovering control files. First, we use the default settings of the
restore
command: set oracle sid recover

rman target sys/robert

set DBID 2539725638;

startup nomount;

restore spfile from autobackup;

shutdown immediate;

We are not that likely to be using the defaults, of course, so let’s assume we need to define a specific location for the autobackups in the
restore
command. Here is an example of this type of operation:

set oracle sid recover

rman target sys/robert

set DBID 206232339;

startup nomount;

run

{

set controlfile autobackup format for device type disk

to 'c:\oracle\backup\%F';

allocate channel c1 device type disk;

restore spfile from autobackup;

}

shutdown immediate;

Next, we use the
maxseq
and
maxdays
parameters to look back beyond the default ten days:

Chapter 12: RMAN Restore and Recovery
271

set oracle sid recover

rman target sys/robert

set DBID 2539725638;

startup nomount;

run

{

set controlfile autobackup format for device type disk

to 'c:\oracle\backup\%F';

allocate channel c1 device type disk;

restore spfile from autobackup maxseq 200 maxdays 100;

}

shutdown immediate;

Restoring an SPFILE to a different location and filename is not terribly complex. In this example, we assume that the database is up and running, so we don’t need to indicate the location of the autobackup file sets:

set oracle sid recover

rman target sys/robert

set DBID 2539725638;

startup nomount;

restore spfile to 'c:\oracle\spfile.restore' from autobackup;

shutdown immediate;

Recovering the SPFILE from an Autobackup Using RMAN and the FRA

The process to recover the SPFILE when using the FRA is actually much easier than the process if you don’t use the FRA. First, you don’t need to worry about all the DBID nonsense or allocating channels, which saves time and headaches. All you need to do to recover the SPFILE is to configure your temporary parameter file correctly (make sure the FRA destination directory is properly set), start the Oracle instance, and issue the
restore spfile
command. Here is an example: set oracle sid recover

rman target sys/robert

startup nomount;

restore spfile from autobackup;

shutdown immediate;

You can still recover the SPFILE by using the
maxseq
and
maxdays
parameters, as shown in this snippet:

restore spfile from autobackup maxseq 200 maxdays 100;

Recovering the SPFILE from a Specific Backup Set

If you used RMAN before Oracle Database 10
g,
you know that recovery of the SPFILE could be difficult if you did not have autobackups configured. In such cases, you needed to write a nasty bit of PL/SQL in order to restore the SPFILE from the RMAN backups.

Oracle Database 10
g
makes this process much easier. Now the
restore
command includes a
from backup
clause that allows you to simply indicate the backup set piece that contains the SPFILE backup in it. Thus, all you need to know is the backup set piece name and where it is, and you can restore your SPFILE. In some cases, it might take a bit of trial and error to find the backup set piece with the SPFILE backup in it, but once you do, the restore should be a snap (of course, it would be best to restore the most current control file backup!).

Other books

Name Games by Michael Craft
The Malignant Entity by Otis Adelbert Kline
Everything He Desires by Thalia Frost
Thorn by Sarah Rayne
Moonbase Crisis: Star Challengers Book 1 by Rebecca Moesta, Kevin J. Anderson, June Scobee Rodgers
Mortal Kombat by Jeff Rovin
Ha'ven's Song by Smith, S. E.
Rude Awakening by Susan Rogers Cooper