RMAN provides multiple methods of data repair.
Depending on the situations you anticipate, consider incorporating each of the options described in the following table into your strategy for responding to data loss, and then set up your database to make these options possible.
Table 14-1 RMAN Data Repair Techniques
Data Repair Technique | Description |
This Oracle Database infrastructure can diagnose failures, advise you on how to respond to them, and repair the failures automatically. | |
This subset of Oracle Flashback Technology features enables you to view or rewind individual database objects or transactions to a past time. These features do not require use of RMAN. | |
Flashback Database is a block-level recovery mechanism that is similar to media recovery, but is generally faster and does not require a backup to be restored. You can return your whole database to a previous state without restoring old copies of your data files from backup, if you have enabled flashback logging in advance. You must have a fast recovery area configured for logging for flashback database or guaranteed restore points. | |
This form of media recovery enables you to restore data file backups and apply archived redo logs or incremental backups to recover lost changes. You can either recover a whole database or a subset of the database. Data file media recovery is the most general-purpose form of recovery and can protect against both physical and logical failures. | |
This form of media recovery enables you to recover individual blocks within a data file rather than the whole data file. | |
This is a specialized form of point-in-time recovery in which you recover one or more tablespaces to a time earlier than the rest of the database. |
(一)RMAN Restore Operations
RMAN uses the records of available backup sets or image copies in the RMAN repository to select the best available backups for use in the restore operation.
RMAN会优先选择近的备份,image cope比backup set有更高优先权
The most recent backup available, or the most recent backup satisfying any UNTIL clause specified in the RESTORE command, is the preferred choice. If two backups are from the same point in time, then RMAN prefers 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 indicating that the file cannot be restored.
If you use only manually allocated channels, then a backup job may fail if there is no usable backup on the media for which you allocated channels. Configuring automatic channels makes it more likely that RMAN can find and restore a backup that satisfies the specified criteria.
RMAN automatically uses restore failover to skip corrupted or inaccessible backups and look for usable backups. When a backup is not found, or contains corrupt data, RMAN automatically looks for another backup from which to restore the desired files.
RMAN performs restore failover repeatedly until it has exhausted all possible backups. If all of the backups are unusable or no backups exists, then RMAN attempts to re-create the data file.
Restore failover is also used when there are errors restoring archived redo logs during RECOVER, RECOVER ... BLOCK, and FLASHBACK DATABASE commands.
When Automatic Storage Management (ASM) disk groups are used, an RMAN restore operation creates new copies of data files only if the full name of a data file, including the incarnation, does not match with the name of an existing data file.
A fully qualified ASM file name is of the form +diskgroup/dbname/filetype/filetypetag.file.incarnation. When you first restore the control file and then restore the other database files, the names of the data files in the control file may not match with the names of the existing data files and therefore the data files are recreated.
Use one of the following methods to ensure that existing data files are not recreated during a restore or duplicate operation:
- In the control file, use alias names for each data file. The alias must not include the ASM incarnation number.
- After restoring the control file and before restoring the other database files, use the CATALOG command to ensure that the existing data files are cataloged in the restored control file. Next, use the SWITCH command to make the restored control file point to the existing data files.
- Use SET NEWNAME to rename the data files before restoring the data files and after restoring the control file.
- RMAN Restore Optimization
默认RMAN不对已存在符合条件的数据文件进行RESTORE,使用FORCE改变默认行为
RMAN uses restore optimization to avoid restoring data files from backup when possible. If a data file is present in the correct location and its header contains the expected information, then RMAN does not restore the data file from backup.
Note: Restore optimization only checks the data file header. It does not the scan the data file body for corrupted blocks.
You can use the FORCE option of the RESTORE command to override this behavior and restore the requested files unconditionally.
Restore optimization is particularly useful when an operation that restores several data files is interrupted.
DUPLICATE命令同RESTORE但不支持FORCE选项
Restore optimization is also used when duplicating a database. If a data file at the duplicate is in the correct place with the correct header contents, then the data file is not duplicated. Unlike RESTORE, DUPLICATE does not support a FORCE option. To force RMAN to duplicate a data file that is skipped due to restore optimization, delete the data file from the duplicate before running the DUPLICATE command.
RMAN can perform either data file media recovery or block media recovery.
Data file media recovery is the application of redo logs or incremental backups to a restored data file to update it to the current time or some other specified time.
Selection of Incremental Backups and Archived Redo Logs
RMAN automates media recovery. RMAN automatically restores and applies both incremental backups and archived redo logs in whatever combination is most efficient.
If the RMAN repository indicates that no copies of a required log sequence number exist on disk, then it automatically restores the required log from backup. By default, RMAN restores the archived logs to the fast recovery area, if an archiving destinations is set to USE_DB_RECOVERY_FILE_DEST. Otherwise, RMAN restores the logs to the first local archiving destination specified in the initialization parameter file.