About SCN understanding

xiaoxiao2021-03-06  113

About SCN's Understanding System Checkpoint SCN (V $ DATABASE (CheckPoint_Change #)) Data File Checkpoint (V $ DataFile (CheckPoint_Change #) Data File Termination SCN (V $ DataFile (Last_Change #))

Checkpoints stored in data files Start SCN (V $ DataFile_Header (checkpoint_change #)

1. System Checkpoint SCN When a checkpoint action is completed, Oracle stores the SCN of the system checkpoint to the control file. Select Checkpoint_Change # from v $ database2, Data file checkpoint SCN When a checkpoint action is completed, Oracle puts SCN of each data file in the control file. SELECT NAME, CheckPoint_Change # from v $ datafile 3, Start SCNORACLE to store this checkpoint SCN in the file header of each data file, this value is called start SCN because it is used to check if needed at the database instance Perform database recovery. Select Name, CheckPoint_Change # from v $ datafile_header4, terminating SCN's termination SCN of each data file is stored in the control file. Select Name, Last_Change # from V $ datafile In the normal database operation, all the termination SCNs of the data files in online reading and write mode are NULL.5, and the SCN value during the database is running and running in the database. The system checkpoint in the control file, the data file checkpoint SCN in the control file and the startup SCN in each data file header is the same. The termination SCN of each data file in the control file is NULL.

In the process of safely shutting down the database, a checkpoint action is executed, and the termination SCN of all data files will be set to the value of the SCN in the data file header. When the database restarts, Oracle compares the one of the files in the file header and the database file checkpoint SCN. If the two values ​​match each other, Oracle is next to compare the startup SCN and control files in the data file header. The termination SCN of the data file. If these two values ​​are also consistent, it means that all data blocks have been submitted. All the modifications to the database are not lost during the shutdown database, so the process of starting the database does not require any recovery operation, at which time the database You can open it. When all databases are opened, the value stored in the control file is terminated again to NULL again, which means that the data file has been opened and can be used normally. ------------------------------------------ Clarify a few concepts 1) The system is currently SCN is not changed when any database operation occurs, and the SCN changes in transaction submission or rollback, 2) There are SCNs in control files, data file headers, data blocks, log file headers, log files Change Vector. However, its effects containing the checkpoint scn of the data file in the same data file, indicating that the SCN, NEXT SCN is included in the SCN, NEXT SCN, indicating that the log file is included in the log file, indicating that the log file is included in the LOW SCN. There is the Redo Record from the Low SCN to Next SCN. Control file contains CheckPoint SCN, STOP SCN, a Low SCN, NEXT SCN, and the checkpoint scn of each log file in the control file in the CHECKPOINT SCN. Similarly, unless the data file is replaced by manual. The Low SCN in the control file is the same as the LOW SCN and Next SCN in the database in the database, the STOP SCN of the corresponding data file in the control file is the largest. When the database is turned off, the checkpoint will be performed before turning off. When Oracle writes all the content on the data buffer back to the disk, then update the STOP SCN of the corresponding data file in the control file, so that it is equal to the Checkpoint SCN.

However, in the case of an exception, since the last checkpoint is not carried out or in progress, there is a control file, there is a portion of the data file STOP SCN to the maximum, and after the database is restarted, the control file is checked. Corresponding to the STOP SCN of each data file, if the STOP SCN does not equal the checkpoint scn corresponding to each data file in the control file, the log file Redo will start from the checkpoint SCN to the full database operation until the STOP SCN. It is used in the right position. When which redo log file is used, the Low SCN, Next SCN in the log file is used, that is, the Redo Log's LOW SCN, Next SCN must contain the Change Vector of the Data File Reduction. Determined After which data file must be REDO, Oracle compares the SCN and data file data block in the Change Vector. If the Change Vector's SCN is less than the SCN of the data block, skip this Change Vector, otherwise the REDO data block is still There is SCN, but its role is to generate a consistent reading snapshot

转载请注明原文地址:https://www.9cbs.com/read-99617.html

New Post(0)