Oracle Recovery internal principles: Media recovery

Source: Internet
Author: User
Tags require requires backup

Media recovery is used in cases where a data file is lost or corrupted or a control file is lost. Media recovery restores the restored data file to the current data file. Also able to recover data files when the exception is offline there is no time to do a checkpoint operation lost changes. Media recovery uses archive logs and online logs. Unlike the instance recovery, media recovery must be explicitly invoked by the command.

6.1 When do media recovery

It is known from section 5.3 that if the data file is a restored backup, media recovery will be performed before it is opened, even if the online log is applied. Another scenario is that the data file is offline without a checkpoint. The media recovery database cannot be opened and data files that require media recovery cannot be brought online. Media recovery can only be recovered on an offline data file when the database is not opened by any instance. The Call Media Restore command is displayed in the open database even when there is a crash recovery. At this point, crash recovery may have nothing to do, but it will run automatically. Sometimes media recovery may find that there is no log to apply, the error "Do not require media recovery", that is, the file does not need to be restored.

If the current control file is lost and a backup control file is restored, media recovery must be done, which is an example of media recovery when all data files are online.

6.2 Thread Merge Redo Program

Media recovery uses the redo algorithm for the redo log, which is a threaded merge. That is, it applies the redo logs of all threads at the same time, merging redo logs in the order of SCN increments. The process of applying a media restore on a restored data file differs from the process of applying crash recovery on an online data file: Crash recovery at the same time only logs from one thread are applied because the block on the data file at the same time requires up to one thread redo log (only one instance at a time may modify the block). On a restored backup, you cannot guess the number of threads associated with the block. Typically, media recovery requires that all thread redo logs be read at the same time, and then the redo logs are merged in the order of the SCN increment. Note that this algorithm relies on changes in the block of data each thread is recorded in a SCN-incremented order (in a parallel server environment).

6.3 Restore Backup

You can restore a backup of the data file when the database is closed or the data file is offline. Note that you must never restore a data file when it is still in use. Each time the data file header verifies the checkpoint count of the data file head and the checkpoint count in the control file to detect this illegal operation.

6.4 Media Restore command

There are three of media restore commands:

RECOVER DATABASE

RECOVER tablespace

RECOVER datafile

The fundamental difference between these three commands is that the restored data file collection is different. All three commands use the same criteria to determine whether or not each data file is to be used for media recovery. Each data file has an exclusive lock, and the media recovery program will apply for the lock before it recovers. If not, an error is triggered. This prevents two recovery sessions from recovering the same data file at the same time and preventing media recovery for a data file that is in use.

6.4.1 RECOVER DATABASE

This command is used to recover all online data files. If all instances are shut down properly and no data files are restored, this command triggers a "No recovery required" error. This command also complains when an instance has already opened the data file because the instance already holds all the locks.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.