Resetlogs mechanism of oracle

Source: Internet
Author: User

Author: skate
Time: 2010/09/07
 
Resetlogs mechanism of oracle
 
I think everyone is familiar with the alter database open resetlogs command. Have you ever wondered why this resetlogs option should be used? When will it be used?
What is its mechanism? What are their roles?
 
We all know that data consistency is required at startup, and oracle performs two checks at the open stage.
 
1. Check whether the checkpoint cnt in the data file header is consistent with the checkpoint cnt in the control file. The purpose is to confirm the data file
Whether the data is from the same version rather than from the backup. If this check item passes, perform the second check.
 
2. Check whether the starting scn of the data file header is consistent with the ending scn recorded in the control file. If the start scn of the data file header and the end scn of the file in the control file
Equal, it indicates that this data file does not need to be restored; otherwise, the file must be restored.
 
If the preceding two steps are successful, you can open the database, lock the data file, and set the ending scn of each data file in the control file to infinity.
When we open data under certain conditions, we will prompt you to use the resetlogs option to open the database. Why should we use resetlogs? Why is it used? There are a lot of question marks,
The following is a detailed analysis.
 
 
Functions of resetlogs
 
Prevent old data from entering the database (ensure Database Consistency), which is why you must immediately perform full backup for the database when using resetlogs to open the database.
"Resetlogs data" is stored in the control file, data file header, and redo log header. When open resetlogs is executed, consistency can be checked through this content.
 
 
When to use resetlogs
 
1. Incomplete recovery
2. Restore with backup control files
3. Create a new control file to restore
 
 
Resetlogs principles and mechanisms
 
How does resetlogs ensure that the database is consistent?
 
1) In open resetlogs, oracle should compare and check the control file and data dictionary file $. If a data file exists in file $ but does not exist in the control file,
Create a file entry in the control file (MISSINGnnn 'nnn 'is the file_id in decimal format), and mark the file as offline and need to be restored. If
If the file actually exists, you can use the following SQL statement to change it to the correct file name.
 
SQL> alter database rename file 'missingnn' to '<filename> ';
 
Then the data file is restored, online.
 
2) if a data file exists in the control file instead of the data dictionary file $, delete the record entries in the control file directly (oracle considers file $
The parts are correct and shall prevail)
 
3) when the old backup control file is used for recovery, if a data file is not registered in the control file (an old error occurs when the control file is displayed), the data file must be rebuilt.
To register the data file to the control file. Then, the system automatically uses redo/archivelog to restore the data file.
 
After the control file and file $ file are consistent, oracle will perform the following checks to open resetlogs.
 
4) the data file version is smaller than the current database version (counter)
 
5) offline data files must be online or directly drop
 
6) fuzzy bit cannot be set for all data files. All data files must have the same checkpoint (checkpoint SCN)
 
So far, all the prerequisites for open resetlogs have been met. What exactly does resetlogs do? (Use redo log again)
 
 
1) all online logfile information is replaced in the control file. Select a logfile file for the valid thread as the current logfile.
 
2) log header is updated to log seq #
 
3) all online data file headers are updated by the new checkpoint and the new 'resetlogs data', and offline data files are marked as media recovery required.
 
Resetlogs data: the current scn and counter are called "resetlogs data"
 
If the oracle database consistency check fails, the database cannot be opened, that is, the open resetlogs fails. But it is not absolutely not open. You can bypass the oracle consistency check by implicit parameter "_ allow_resetlogs_curruption, however, this will cause Database Inconsistency (the file may have different scn or fuzzy bit settings). After opening, the database must be rebuilt (we recommend that you ANALYZE the TABLE... validate structure cascade; or imp/exp)
 
 
------- End ------
 

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.