Oracle RMAN 11g Backup and Recovery (97 page)

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

If you are running in NOARCHIVELOG mode, you would use the following method (in this example, we assume you are not using the FRA, so we set the DBID):

set oracle sid recover

rman target sys/robert

set DBID 2539725638;

startup nomount;

restore controlfile from autobackup;

alter database mount;

recover database noredo;

alter database open resetlogs;

If you are running in ARCHIVELOG mode, recovery is only slightly different (note in this example, we are assuming you are using the FRA, so we do not set the DBID): set oracle sid recover

rman target sys/robert

startup nomount;

restore controlfile from autobackup;

alter database mount;

recover database;

alter database open resetlogs;

Of course, loss of other database physical files can make this complex. Also, if you don’t have a recent control file backup, then things can get quite complicated, and you may end up having to manually re-create the control file with the
create control file
command. This is a horror we hope you never have to face, and you should not need to face it if your backup and recovery strategy is sound.

Restoring RMAN-Related Records to the Control File
Once you have restored the control file, you need to consider the distinct possibility that you have lost RMAN-related data. Since RMAN stores all of its data in the control file, there is a good possibility that you have at least lost some records that relate to archived redo logs (which Oracle needs for a full recovery).

RMAN makes this problem easier to deal with, because you can register various RMAN-related backup files after the restore of a control file just to ensure that you have everything you need for a recovery in the control file. To re-create RMAN-related archived redo log records, you can use the RMAN
catalog
command to register archived redo logs in your control file. The
catalog
command can be used to register a specific backup set piece, as shown in this example: RMAN>Catalog backuppiece 'c:\oracle\product\10.2.0\flash recovery area

\testoem\backupset\2005 12 09\O1 MF ANNNN TAG20051209T041150

1SLP386H .BKP';

278
Part II: Setup Principles and Practices

You can also catalog archived redo logs, as in this example:

RMAN>Catalog archivelog

'c:\oracle\product\10.2.0\flash recovery area\testoem\archivelog\

2005 12 15\O1 MF 1 2 1T3SVF05 .ARC';

Now, if you are thinking ahead, you might sigh and say to yourself, “Who wants to manually catalog the 1,000 archived redo logs that I have generated throughout the day?” Fortunately, the RMAN developers had the same thought! With RMAN, you can catalog a whole directory without having to list individual files. Simply use the
catalog
command again, but use one of the following keywords:


recovery area
or
db_recovery_file_dest


start with

The
recovery area
and
db_recovery_file_dest
keywords have the same function: they cause the entire FRA to be cataloged by RMAN. If RMAN finds files that are already cataloged, it simply skips over them and continues to catalog any remaining files that are not found in the control file.

Here is an example of cataloging all files in the FRA:

RMAN> catalog recovery area;

If you are not using the FRA, then you will want to use the
start with
syntax instead. The
start
with
syntax allows you to traverse a non-FRA backup directory and to catalog any RMAN-related files contained in that directory and any subdirectories under that directory. Here is an example of the use of the
catalog start with
command:

catalog start with 'c:\oracle\backups\testoem';

NOTE

RMAN in Oracle Database 10
g
R2 automatically catalogs the FRA for
you if you perform a restore operation with a backup control file.

Restoring a Control File Online

Extracting a copy of your control file from a database backup while the database is up is really easy regardless of whether you are using a control file or a recovery catalog.

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

RMAN> restore controlfile to 'd:\backup' 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 by default to find a control file autobackup piece. Use
maxseq
and
maxdays
to modify this default.

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:

RMAN> restore controlfile to 'd:\backup';

In this case, Oracle uses the control file of the database to locate the most current backup set to restore the control file from. Of course, you could use the manual restore process by using the
dbms_backup_restore
procedure, which we discussed earlier in this section.

Chapter 12: RMAN Restore and Recovery
279

RMAN Workshop:
Recover Your Control File

Workshop Notes

For this workshop, you need an installation of the Oracle software and an operational test Oracle database. We also assume that you have the FRA configured and that your backups are being done to that area.

NOTE

For this workshop, the database is in ARCHIVELOG mode.

Step 1.
Ensure that you have configured automated backups of your control files: configure controlfile autobackup on;

In this case, we are accepting that the control file backup set pieces will be created in the default location.

Step 2.
Complete a backup of your system (in this case, we assume this is a hot backup). In this workshop, we assume that the backup is to a configured default device:

set oracle sid recover

rman target rman backup/password

backup database plus archivelog;

Step 3.
Shut down your database by using the
shutdown immediate
command. Do not use the
shutdown abort
command in this workshop.

shutdown immediate;

Step 4.
Rename all copies of your database control file. Do not remove them, just in case your backups cannot be recovered.

Step 5.
Start your database. It should complain that the control file cannot be found and it will not open.

startup;

Step 6.
Recover your control file with RMAN by using your autobackup of the control file: restore controlfile from autobackup;

Step 7.
Mount the database and then simulate incomplete recovery to complete the recovery process:

Alter database mount;

recover database;

alter database open resetlogs;

280
Part II: Setup Principles and Practices

The restore and recover Commands

The basic process of recovering a database is a two-step process. The first step is to use the
restore
command to restore the database backups. The second step is to use the
recover
command to recover the database, including the application of archived redo logs. Let’s look at each of these commands in a bit more detail before we move on to the details of how to recover your database using them.

Other books

Time and Tide by Shirley McKay
Bloodfire (Empire of Fangs) by Domonkos, Andrew
The Bronze Mage by Laurel Mojica
Dear Mr. Knightley by Reay, Katherine
The Meridians by Michaelbrent Collings