Oracle RMAN 11g Backup and Recovery (95 page)

BOOK: Oracle RMAN 11g Backup and Recovery
13.09Mb size Format: txt, pdf, ePub

272
Part II: Setup Principles and Practices

Thus, to restore the SPFILE, start the database instance and identify the backup set piece that contains the SPFILE (or guess at it). Fire up RMAN. You need to set the DBID of the database also (as we have already discussed). Once you have set the DBID, you also need to allocate a channel to the device you are going to restore from. Having allocated the channel, you issue the
restore spfile
from
command, and pass the backup set piece name in at the end of the command. RMAN will then restore the SPFILE to the correct location. Here is an example of this type of restore in action: set oracle sid recover

rman target sys/robert

set DBID 2539725638;

startup nomount;

run

{

allocate channel c1 device type disk;

restore spfile

from 'd:\backup\recover\C-2539725638-20060629-00';

}

shutdown immediate;

You can now perform any additional recovery activities that might be required.

Recovering the SPFILE When Using a Recovery Catalog

If you are using a recovery catalog, restoring the most current SPFILE is as simple as issuing the
restore spfile
command after starting (nomount) the Oracle instance. RMAN will use the recovery catalog to locate the most current control file backup and will extract that backup for your use.

Here is an example:

set oracle sid recover

rman target sys/robert catalog rcat manager/password@robt

startup nomount;

restore spfile from autobackup;

shutdown immediate;

Note that we shut down the database after the restore. Again, this is to make sure that the database will be restarted using the correct parameter value settings.

Restoring the Backed Up SPFILE with an Operational Database Online

Extracting a copy of your SPFILE from a database backup with the database up is really easy regardless of whether you are using a control file or a recovery catalog. You should note that this operation will result in a text parameter file, and not an SPFILE, so you will need to convert it if you wish it to be an SPFILE.

If you are not using a recovery catalog and you have enabled automatic backups of control files, just issue the following command:

RMAN> restore spfile to pfile 'd:\backup\test.ora' from autobackup;

This command restores the SPFILE to a file called test.ora in a directory called d:\backup.

Again, with any autobackup restore, RMAN looks only for the past seven days to find a control file autobackup piece unless you supply
maxseq
and
maxdays
parameter values.

If you are not using a recovery catalog and are not using control file autobackups, or if you are using a recovery catalog, then this is the command you would use:

Chapter 12: RMAN Restore and Recovery
273

RMAN> restore spfile to pfile 'd:\backup\test.ora';

In this case, Oracle uses the control file of the database to locate the most current backup set to restore the SPFILE from. So, now that you have your SPFILE back, you are ready to go out and recover your control file.

Restoring the Control File

Restoring the control file is not much different from restoring your SPFILE. First, the database needs to be mounted; so to restore the control file, you should have already restored your SPFILE, or have created one, and mounted your database. Once that occurs, you are ready to proceed to recover the control file for your database.

Control file recoveries come in several flavors, including recoveries that do not use the FRA and those that do use the FRA. In the following sections, we deal with additional control file recovery situations.

Recovering the Control File from an Autobackup Using RMAN, No FRA

If you have lost your control file and you are not using the FRA, you will want to recover the file from the control file autobackup set (if you are using this feature, which we strongly recommend).

As we have already described, Oracle will by default back up the control file (along with the SPFILE) to the $ORACLE_HOME/dbs or $ORACLE_HOME/database directory (depending on the operating system). If you choose to use the default location (or if you back up to an alternate disk location), you will probably want to back up these backup sets to another backup medium such as tape (which RMAN can do for you).

When restoring the control file, it is assumed that the instance parameter file has been restored and that the instance can be started (for example, by using
startup nomount
). Once the instance is up and running, the general procedure to restore the control file when not using the FRA is to first set your ORACLE_SID and then log into RMAN (if you have not done so already).

As with SPFILE restores, you need to set the DBID so that RMAN will know which database control file it is looking for.

We are now ready to restore the control file. As with the SPFILE restore, if you are using the default location (not likely) to back up your control file autobackup to, you can simply issue the
restore control file from autobackup
command, and RMAN will look for the control file backup set that contains the most current control file backup. Once the control file is recovered, you need to shut down the instance and restart it to allow your new control file parameters to take effect. If you are using a nondefault location, then you need to use the
allocate channel
command to allocate a channel pointing to that location, and then you can restore the control file using the same method.

When you issue the
restore controlfile 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. See the previous section on SPFILE

recoveries for more information about the format of the naming convention that RMAN uses for control file autobackup backup sets. As with SPFILE recoveries, you can modify how far back RMAN looks for a control file autobackup by using the
maxseq
and
maxdays
parameters of the
restore
command.

274
Part II: Setup Principles and Practices

Let’s look at some 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 controlfile from autobackup;

shutdown immediate;

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

This time we assume that we are not backing up to a default location:

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 controlfile from autobackup maxseq 200 maxdays 100;

}

shutdown immediate;

Restoring a control file to a different location and filename is not terribly complex. In this example, we assume the database is up and running, so we don’t need to define the location of the control file autobackups:

set oracle sid recover

rman target sys/robert

set DBID 2539725638;

startup nomount;

run

{

restore controlfile to 'c:\oracle\control file.restore' from autobackup;

}

shutdown immediate;

Recovering the Control File from an Autobackup

Using RMAN and the FRA

As was the case with SPFILE recoveries, the process to recover the control file when using the FRA is very easy. First, ensure that the parameters defining the location of the FRA are set correctly.

Then, start the database instance; issue the
restore controlfile from autobackup
command, and the control file will be recovered. Here is an example:

set oracle sid recover

rman target sys/robert

startup nomount;

Other books

Traitor by McDonald, Murray
A Wizard of the White Council by Jonathan Moeller
Amok and Other Stories by Stefan Zweig