Oracle® Database Backup and Recovery Advanced User's Guide 10g Release 1 (10.1) Part Number B10734-01 |
|
|
View PDF |
This chapter describes the basic concepts involved in using RMAN to restore, recover, and duplicate databases.
This chapter contains these topics:
Use the RMAN RESTORE
command to restore the following types of files from disk or other media:
Because a backup set is in a proprietary format, you cannot simply copy it as you would a backup database file created with an operating system utility; you must use the RMAN RESTORE
command to extract its contents. In contrast, the database can use image copies created by the RMAN BACKUP
AS
COPY
command without additional processing.
See Also:
Oracle Database Recovery Manager Reference for |
RMAN automates the procedure for restoring files. You do not need to go into the operating system, locate the backup that you want to use, and manually copy files into the appropriate directories. When you issue a RESTORE
command, RMAN directs a server session to restore the correct backups to either:
SET NEWNAME
commandTo restore a datafile, either mount the database or keep it open and take the datafile to be restored offline. When RMAN performs a restore, it creates the restored files as datafile image copies and records them in the repository. The following table describes the behavior of the RESTORE
, SET
NEWNAME
, and SWITCH
commands.
For example, if you restore datafile ?/oradata/trgt/tools01.dbf
to its default location, then RMAN restores the file ?/oradata/trgt/tools01.dbf
and overwrites any file that it finds with the same filename. If you run a SET NEWNAME
command before you restore a file, then RMAN creates a datafile copy with the name that you specify. For example, assume that you run the following commands:
SET NEWNAME FOR DATAFILE '?/oradata/trgt/tools01.dbf' TO '/tmp/tools01.dbf'; RESTORE DATAFILE '?/oradata/trgt/tools01.dbf';
In this case, RMAN creates a datafile copy of ?/oradata/trgt/tools01.dbf
named /tmp/tools01.dbf
and records it in the repository. To change the name for datafile ?/oradata/trgt/tools01.dbf
to /tmp/tools01.dbf
in the control file, run a SWITCH
command so that RMAN considers the restored file as the current database file. For example:
SWITCH DATAFILE '/tmp/tools01.dbf' TO DATAFILECOPY '?/oradata/trgt/tools01.dbf';
The SWITCH
command is the RMAN equivalent of the SQL statement ALTER
DATABASE
RENAME
FILE
.
See Also:
Oracle Database Recovery Manager Reference for |
RMAN uses the repository to select the best available backups for use in the restore operation. The most recent backup available, or the most recent backup satisfying any UNTIL
clause specified in the RESTORE
command, is always the preferred choice. If two backups are from the same point in time, RMAN prefers to use image copies over backup sets because RMAN can restore more quickly from image copies than from backup sets (especially those stored on tape).
All specifications of the RESTORE
command must be satisfied before RMAN restores a backup. Unless limited by the DEVICE
TYPE
clause, the RESTORE
command searches for backups on all device types of configured channels.
If no available backup in the repository satisfies all the specified criteria, then RMAN returns an error during the compilation phase of the restore job. If you manually allocate channels, and if the file cannot be restored because no backups exist on the device types allocated in the job, then create a new job specifying channels for devices containing the existing backups. This problem does not occur when you configure automatic channels.
During a RESTORE
operation, if a backup piece, image copy or proxy copy is inaccessible (for instance, deleted from the device) or a block in the backup is corrupted, then RMAN automatically looks for a another usable copy of this backup piece or image copy, on the same device or another device, based on the information in the RMAN repository. If no usable copies are available, then RMAN searches for prior backups. RMAN searches all prior backups for the most recent available backup usable in the current operation until it has exhaused all possibilities.
Restore failover is also used when there are errors restoring archivelogs during RECOVER
, BLOCKRECOVER
, and FLASHBACK DATABASE
commands.
When RMAN performs restore failover to another backup of the same file, you will see a message similar to this one in the output of RMAN:
failover to piece handle=/u01/backup/db_1 tag=BACKUP_031009
Also, details about block corruptions will be printed in the alert log and trace files.
When restore failover cannot locate another copy of the same backup and searches for a prior backup, the message generated is similar to this example:
ORA-19624: operation failed, retry possible ORA-19505: failed to identify file "/u01/backup/db_1" ORA-27037: unable to obtain file status SVR4 Error: 2: No such file or directory Additional information: 3 failover to previous backup
By default, RMAN does not perform a restore if the file to be restored is in the correct place and its header contains the expected information. RMAN only restores a file if the header check does not succeed, although you can use the FORCE
option of the RESTORE
command to override this behavior and restore the requested files unconditionally.
Note: Restore optimization only checks the datafile header and does not the scan the datafile body for corrupted blocks. |
Restore optimization is particularly useful in cases where a restore only partially completes. For example, assume that a full database restore encounters a power failure after all except one of the datafiles has been restored. If you start the same restore again, then RMAN only restores the single datafile that was not restored during the previous attempt.
See Also:
Oracle Real Application Clusters Administrator's Guide for description of |
The concept of datafile media recovery is the application of online or archived redo logs or incremental backups to a restored datafile in order to update it to the current time or some other specified time. Use the RMAN RECOVER
command to perform media recovery and apply logs or incremental backups automatically.
If possible, make the recovery catalog available to perform the media recovery. If it is not available, or if you do not maintain a recovery catalog, then RMAN uses metadata from the target database control file. If both the control file and recovery catalog are lost, then you can still recover the database--assuming that you have backups of the datafiles and at least one autobackup of the control file.
The generic steps for media recovery using RMAN are as follows:
SET UNTIL
command to specify the time, SCN, or log sequence number at which recovery terminates. Alternatively, specify the UNTIL
clause on the RESTORE
and RECOVER
commands.RESTORE
command.RECOVER
command.Figure 3-1 illustrates an example of RMAN media recovery. The DBA runs the following commands:
RESTORE DATABASE; RECOVER DATABASE;
RMAN then queries the repository, which in this example is a recovery catalog. The recovery catalog obtains its metadata from the target database control file. RMAN then decides which backup sets to restore, and which incremental backups and archived logs to use for recovery. A server session on the target database instance performs the actual work of restore and recovery.
Text description of the illustration bradv035.gif
See Also:
|
If RMAN has a choice between applying an incremental backup or applying redo to the restored datafiles to meet a recovery objective, then it always chooses an incremental backup. If overlapping levels of incremental backup are available, then RMAN automatically chooses the one covering the longest period of time.
RMAN does not need to apply incremental backups to a restored level 0 incremental backup: it can also apply archived logs. RMAN restores the datafiles that it needs from available backups, applies incremental backups to the datafiles if they are available, and then applies archived logs.
If RMAN cannot find an incremental backup, then it looks in the repository for the names of archived redo logs to use for recovery. The database records an archived log in the control file whenever one of the following occurs:
BACKUP
AS
COPY
command copies a logCATALOG
command catalogs a user-managed backup of an archived logIf you use a recovery catalog, then RMAN propagates archived log data into the recovery catalog during resynchronization, classifying archived logs as image copies. You can view the log information through:
LIST ARCHIVELOG
commandV$BACKUP_FILES
control file viewV$ARCHIVED_LOG
control file viewDuring recovery, RMAN looks for the needed logs using the filenames specified in the V$ARCHIVED_LOG
view. If the logs were created in multiple destinations or were generated by the BACKUP
AS
COPY
, CATALOG
, or RESTORE
commands, then multiple, identical copies of each log sequence number exist on disk. RMAN does not have a preference for one copy over another during recovery: all copies of a log sequence number listed as AVAILABLE
are candidates. In a sense, RMAN is blind to the fact that the logs were generated in different destinations or in different ways.
If the RMAN repository indicates that a log has been deleted or uncataloged, then RMAN ceases to consider it as available for recovery. For example, assume that the database archives log 100 to directories /dest1
and /dest2
. The RMAN repository indicates that /dest1/log100.arc
and /dest2/log100.arc
exist. If you delete /dest1/log100.arc
with the DELETE
command, then the repository indicates that only /dest2/log100.arc
is available for recovery.
If the RMAN repository indicates that no copies of a needed log sequence number exist on disk, then RMAN looks in backups and restores archived redo logs as needed to perform the media recovery. By default, RMAN restores the archived redo logs to the first local archiving destination specified in the initialization parameter file. You can run the SET ARCHIVELOG DESTINATION
command to specify a different restore location. If you specify the DELETE
ARCHIVELOG
option on RECOVER
, then RMAN deletes the archived logs after restoring and applying them. If you also specify MAXSIZE
integer
on the RECOVER
command, then RMAN restores archived logs until the disk space allowed by MAXSIZE
is consumed, then applies redo from the logs and deletes the restored logs to free space, until there is room enough to restore another archived log. RMAN continues restoring, applying and deleting logs, within the MAXSIZE
limit, until recovery is complete.
If an archived log is deleted from disk and the repository does not reflect this fact, then RMAN does not perform automatic failover during recovery. For example, if the repository indicates that /dest1/log100.arc
is on disk when in fact this log was deleted using an operating system command, and if RMAN attempts to apply this log file during recovery, then recovery terminates with an error. RMAN does not automatically attempt to apply other copies of log 100 that are listed as available in the repository.
This situation can sometimes occur when you delete an archived log with an operating system utility and then fail to run CROSSCHECK
to synchronize the repository. If you run a CROSSCHECK
so that the repository is synchronized, then recovery can proceed by applying available copies of the log or restoring a backup of the log if no disk copies are available.
See Also:
Oracle Database Recovery Manager Reference for |
RMAN can perform either complete or incomplete recovery. You can specify a time, SCN, or log sequence number as a limit for incomplete recovery with the SET UNTIL
command or with an UNTIL
clause specified directory on the RESTORE
and RECOVER
commands. The easiest method is run the SET
UNTIL
command before issuing the RESTORE
and RECOVER
commands. After performing incomplete recovery, you must open the database with the RESETLOGS
option.
See Also:
Oracle Database Recovery Manager Reference for the |
Recovery Manager automated Tablespace Point-in-Time Recovery (TSPITR) enables you to recover one or more tablespaces to a point in time that is different from that of the rest of the database. RMAN TSPITR is most useful in these cases:
Similar to a table export, RMAN TSPITR enables you to recover a consistent data set; however, the data set is the entire tablespace rather than a single object.
See Also:
Chapter 10, "RMAN Tablespace Point-in-Time Recovery (TSPITR)" to learn how to perform TSPITR using RMAN |
Although datafile media recovery is the principal form of recovery, you can also use the RMAN BLOCKRECOVER
command to perform block media recovery. Block media recovery recovers an individual corrupt datablock or set of datablocks within a datafile. In cases when a small number of blocks require media recovery, you can selectively restore and recover damaged blocks rather than whole datafiles.
Block media recovery provides several advantages over datafile media recovery. For example, block media recovery
Note these restrictions of block media recovery:
V$DATABASE_BLOCK_CORRUPTION
view indicates which blocks in a file were marked corrupt since the most recent BACKUP
or BACKUP
...
VALIDATE
command was run against the file.RESETLOGS
.See Also:
"Performing Block Media Recovery with RMAN" and Oracle Database Recovery Manager Reference for |
Block media recovery is not intended for cases where the extent of data loss or corruption is unknown and the entire datafile requires recovery. In such cases, datafile media recovery is the best solution. Block media recovery is not a replacement for traditional datafile media recovery, but a supplement to it.
In most cases, the database marks a block as media corrupt, invalidates the block in the instances (or all enabled instances in a Real Application Clusters configuration), and then writes it to disk when the corruption is first encountered. No subsequent read of the block will be successful until the block is recovered. You can only perform block recovery on blocks that are marked corrupt. This corrupt status effectively takes the block offline in all database instances and prevents user access during recovery.
Block media recovery is most useful for data losses that affect specific blocks. Block-level data loss usually results from intermittent, random I/O errors that do not cause widespread data loss, as well as memory corruptions that get written to disk. Typically, these types of block corruption are reported in the following locations:
ANALYZE
TABLE
and ANALYZE
INDEX
For example, you may discover the following messages in a user trace file:
ORA-01578: ORACLE data block corrupted (file # 7, block # 3) ORA-01110: data file 7: '/oracle/oradata/trgt/tools01.dbf' ORA-01578: ORACLE data block corrupted (file # 2, block # 235) ORA-01110: data file 2: '/oracle/oradata/trgt/undotbs01.dbf'
You can then specify the corrupt blocks in the BLOCKRECOVER
command as follows:
BLOCKRECOVER DATAFILE 7 BLOCK 3 DATAFILE 2 BLOCK 235;
Like datafile media recovery, block media recovery cannot generally survive a missing or inaccessible archived log (although it will attempt restore failover when looking for usable copies of archived redo log files, as described in "Restore Failover"). Nevertheless, block media recovery can survive gaps in the redo stream if the missing or corrupt redo records do not affect the blocks being recovered. Whereas datafile recovery requires an unbroken series of redo changes from the beginning of recovery to the end, block media recovery only requires an unbroken set of redo changes for the blocks being recovered.
Note: Each block is recovered independently during block media recovery, so recovery may be successful for a subset of blocks. |
When RMAN first detects missing or corrupt redo records during block media recovery, it does not immediately signal an error because the block undergoing recovery may become a newed block later in the redo stream. When a block is newed all previous redo for that block becomes irrelevant because the redo applies to an old incarnation of the block. For example, the database can new a block when users delete all the rows recorded in the block or drop a table.
Assume that media recovery is performed on block 13 as depicted in Figure 3-2.
Text description of the illustration bradv007.gif
After block recovery begins, RMAN discovers that change 120 is missing. RMAN does not terminate recovery in the hope that block 13 will be newed later in the redo stream. Assume that in change 140 a user drops the table EMPLOYEE
stored in block 13. At this point, the database formats block 13 as a new block. Because the redo for block 13 in change 120 related to the EMPLOYEE
table, and the EMPLOYEE
table was dropped in change 140, RMAN can skip this missing change and apply the redo between changes 140 and 160.
Use the RMAN DUPLICATE
command to create a copy of the target database in another location. The command restores backups of the primary database files and creates a new database.
As part of the duplication, RMAN manages the following:
RESETLOGS
option after incomplete recovery to create the online redo logsNote the following features of RMAN duplication. You can:
SKIP
READONLY
clause (read-only tablespaces are included by default). You can also exclude any tablespace with the SKIP
TABLESPACE
clause so long as it is not the SYSTEM
or SYSAUX
tablespace and does not contain rollback or undo data. If you omit tablespaces, then you can add them later.NOFILENAMECHECK
option and reuse the target datafile filenames for the duplicate datafiles.SET
UNTIL
command or UNTIL
clause of the DUPLICATE
command to recover it to a past time. By default, the DUPLICATE
command creates the database using the most recent backups of the target database and then performs recovery to the most recent consistent point contained in the incremental and archived redo log backups.Figure 3-3 illustrates a case of database duplication. In this example, RMAN creates two duplicate database by using one set of datafile backups: one database on the local host and one database on a remote host.
Text description of the illustration bradv027.gif
The method you use to duplicate your database depends on whether you are creating your duplicate database on the same or a different host and whether the duplicate directory structure is the same as your target database directory structure. For example, in some cases you can keep the same directory structure and filenames in your duplicate database, while other times you must rename the files.
See Also:
Chapter 11, "Duplicating a Database with Recovery Manager" to learn how to make a duplicate database Oracle Database Recovery Manager Reference for Oracle Database Utilities to learn how to use the |
You can use the RMAN DUPLICATE
command to create a physical standby database. (Note that RMAN cannot be used to create a logical standby database, because it is not a block-for-block duplicate of the primary database.) RMAN automates the following steps of the creation procedure:
RMAN cannot fully automate creation of the standby database because you must manually create an initialization parameter file for the standby database, start the standby instance without mounting the control file, and perform any Oracle Net setup required before performing the creation of the standby. Also, you must have RMAN backups of all datafiles available as well as a control file backup that is usable as a standby control file.
RMAN can back up the standby datafiles, control file and archived redo logs of a physical standby database. Backups of datafiles and archived redo logs taken from a physical standby database are fully interchangeable with primary backups. In other words, you can restore a backup of a physical standby datafile to the primary database, and you can restore a backup of a primary datafile to the physical standby database. The standby control file backups can be used to restore the standby control file without needing to re-instantiate the standby in cases where the standby control file is lost.
See Also:
Oracle Data Guard Concepts and Administration to learn how to create and back up a physical standby database with RMAN |