Media restoration is used when data files are lost or damaged, or control files are lost. Media restoration restores the restored data file to the current data file. Data File recovery
Media restoration is used when data files are lost or damaged, or control files are lost. Media restoration restores the restored data file to the current data file. Data File recovery
Media restoration is used when data files are lost or damaged, or control files are lost. Media restoration restores the restored data file to the current data file. It can also restore the abnormal offline data files without having time to make changes to the checkpoint operation loss. Media recovery uses archived and online logs. Unlike instance restoration, media restoration must be explicitly called by a command.
Series of articles: Oracle internal recovery principles? Where = nkey & keyword = 19824
6.1 When to restore Media
As mentioned in section 5.3, if the data file is a restored backup, the media must be restored before it is opened, even if the online logs of the application can be recovered. In another case, the data file is abnormal and no checkpoint is performed offline. You cannot open the database without restoring the media, and the data files that need to be recovered by the media cannot be online. When the database is not opened by any instance, the media can only be recovered from offline data files. Even if there is a crash recovery, you must call the media recovery command when opening the database display. At this time, the crash recovery may be useless, but it will still run automatically. Sometimes the media recovery may find that no logs need to be applied, and an error "no media recovery required" will be reported, that is, the file does not need to be restored.
If the current control file is lost and a backup control file is restored, the media must be restored. This is an example of media recovery when all data files are online.
6.2 merge and redo programs
The media recovery application redo log uses the thread merge redo algorithm. That is, it needs to apply the redo logs of all threads at the same time, and merge the redo logs in the sequence of increasing SCN. The restoration process of application media on restored data files differs from the process of application crash recovery on online data files: crash recovery only applies logs from one thread at the same time, because at the same time, the data file blocks only need the redo logs of up to one thread (only one instance may modify the blocks at the same time ). On the restored backup, you cannot guess the number of threads related to the block. Generally, when the media is restored, it is necessary to read the redo logs of all threads at the same time, and then merge the redo logs in the ascending order of SCN. Note that this algorithm depends on the change of data blocks. Each thread is recorded in the sequence of increasing SCN (in the parallel server environment ).
6.3 restore backup
When the database is closed or the data file is offline, you can back up and restore the data file. Note that data files cannot be restored when they are still in use. Each time a data file header is written, the checkpoint count of the data file header and the checkpoint count of the data file in the control file are checked to check whether such illegal operation is performed.
6.4 media recovery command
There are three media recovery commands:
RECOVER DATABASE
RECOVER TABLESPACE
RECOVER DATAFILE
The fundamental difference between these three commands is that the recovered data file set is different. The three commands use the same standards to determine whether to restore the media for each data file. Each data file has an exclusive lock, which will be applied for first before the media recovery program starts to recover. If not, an error is triggered. This prevents two recovery sessions from recovering the same data file at the same time, and prevents medium recovery for a data file in use.
6.4.1 RECOVER DATABASE
This command is used to restore all online data files. If all instances are shut down normally and no data files are restored, this command triggers a "no recovery required" error. When an instance has opened the data file, this command also reports an error because the instance already holds all the locks.
6.4.2 RECOVER TABLESPACE
This command is used to restore all data files in a specified tablespace. To convert a tablespace name to a specific data file name, the database must open it first. This means that the tablespace and all its data files must be offline before the database can be restored. If all data files in the tablespace do not require media recovery, an error is triggered, saying that no files need to be restored.
6.4.3 RECOVER DATAFILE
This command is used to restore a specified data file. No matter whether the database is opened or not, you only need to obtain the media recovery lock on the data file. When an instance has opened a database, it can only restore the media in offline data files.
6.5 start media recovery
When the media is restored, the start SCN of the media recovery is searched. For example, the lowest checkpoint SCN in the file header of all data files to be restored. Note: If the checkpoint SCN of a data file falls within its offline SCN range (see 2.18), an exception is thrown. At this point, the offline completion of the data file SCN will replace the file header checkpoint SCN to participate in the computing media recovery start SCN.
Then, each enabled thread (that is, the thread that is enabled at the moment when the media Recovery starts SCN, see 2.10) will allocate a buffer to read the redo log. The checkpoint SCN of each file header is saved to ensure that the redo logs before this SCN do not need to be applied. The ending SCN (recorded in the control file) is also saved. If it is an infinite number, the maximum ending SCN is used to tell the media where the restoration is stopped. The redo log exceeding this SCN does not need to be applied (see 6.10 ). When the restoration ends, a checkpoint operation (instead of the Restoration end point) is performed on the data file whose SCN is infinite before the restoration ends ). This allows a clean offline or read-only data file to perform the checkpoint operation at the ending SCN of its tablespace.