Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The working Mechanism of oracle background process LGWR,DBWR,SMON,CKPT

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Control file: records the name and path of the data file. Redo log name and location, log sequence number, checkpoint and log history information, and RMAN backup information. When an instance failure or media failure occurs on the oracle server, oracle can determine the log files needed to perform the recovery by controlling the log and checkpoint information recorded in the file.

Data file: a physical file used to store database data, which consists of several operating system files, in which user data (tables, indexes, etc.), data dictionaries and rollback segment data are stored. There is a close relationship between data files and tablespaces. Oracle database should contain at least one data file, and data files are physical elements of tablespaces. A tablespace can contain multiple data files, and each data file can only uniquely belong to a tablespace.

Online redo log files: redo log files are physical files that record changes to the database and are used to restore the oracle database in the event of an accident. Log files exist in the form of log filegroups. We know that the redo log buffer is recycled: when the redo items of the redo log buffer are written to the online redo log file, the contents of the redo log buffer are overwritten, but the loop is cycled in a group way.

LGWR log writing process: the LGWR log writing process is responsible for writing log entries from the redo log cache to the online log file on disk. When running DML or DDL statements, the server process must first record the changes of things in the redo log cache before writing to the data cache, and the contents of the redo log buffer will be written to the connection log file to avoid unexpected data loss caused by the system (if the operating system is powered off, the contents of the redo log buffer in memory will be lost. The online log files that exist on disk will not be lost), which is done by LGWR. The redo log cache is a circular structure. After LGWR writes the redo records in the redo log buffer to the online redo log file, the corresponding buffer contents will be cleared to ensure that orale has free redo log buffers to write to.

LGWR starts working when the following occurs:

Before the DBWR process writes the dirty buffer to the data file.

-- the redo log record reaches 1/3 of the buffer.

-more than 1m logs are recorded in the log buffer.

Every 3 seconds. / / the redo date buffer is recycled to make enough space for new records.

-- committing a transaction (performing commit) / / committing a transaction is equivalent to making sure that changes are saved, and it is possible to lose if you do not save the log file.

By the way. Oracle uses a fast commit mechanism. When performing a commit operation, instead of writing the 'dirty buffer' data to the data file, the contents of the redo log buffer are written to the redo log file to ensure database integrity. At this time, even if the system has an unexpected situation (power loss, system crash), because the committed transaction has been recorded in the online redo log file stored on disk, the instance will be automatically recovered when it is restarted in the future. and the data modified by the committed transaction is written to the data file to avoid data loss.

DBWn database write process: the database write process is responsible for writing the class capacity of the database cache buffer (dirty buffer) to the data file. Although there is one database write process (DBW0) for most systems, the database administrator can configure additional processes (DBW0-DBW9, up to 10 processes) to improve write performance by initializing the parameter DB_WRITER_PROCESSES. When the database cache is quickly modified, it is marked as a dirty buffer and added to the LRUW list in SCN order, in the same order as the redo log buffer. When something happens, the DBWn process starts to work-- the system issues checkpoint instructions. / / synchronize data. For more information, please see checkpoint process (CKPT)-the number of dirty buffers reaches the specified threshold. The service process cannot find the free buffer after searching for a certain number of data blocks. -- the timing of data writing is up. -- the tablespace is offline or in a read-only state. -- perform delete or truncate table operations-- execute the alter tablespace.begin backup command. / / data synchronization is required, and the principle is the same as checkpoint. .

The whole process of data modification to checkpoint 1 when the data is modified, it is necessary to read the data from the data file into the database high-speed buffer for the first time. (2) after the data is read into the database high-speed buffer. The entries of the modified data are first recorded in the redo log buffer; 3 then the new data is written to the database high-speed buffer. 4 submit, the LGWR process writes the entry from the redo log buffer to the online redo log file, 5 executes the checkpoint CKPT, synchronizes the database, finds that the online log file is up to date, updates the data file and controls the file synchronously, and triggers the DBWn process.

SMON system monitoring process SMON system monitoring process is mainly used to force the recovery of the database. When the instance starts, if the last database is shut down abnormally, and the SCN values of the redo log file and the control file are different, oracle will automatically synchronize all data files, control files and redo log files before reopening the database, ensuring the consistency of all database files before opening the database. If the system is powered off and crashes after the fourth step in the checkpoint process column, will the data be lost? Of course not. We know that the power outage of the system results in the loss of data in memory. Then naturally the fifth step in the above column cannot be completed (unable to tell the buffer to write the data file from the database), but because the online log file has been written at this time. Therefore, at this point, the data will be updated from the linked log file, and the amount of data updated is naturally determined by SCN. This process is called 'instance recovery'. This process does not require manual intervention of the database administrator and is completed automatically by the SMON process.

The work of the SMON process is summarized as follows:

-- instance recovery-- Free space for merging data files-- releasing temporary segments of data files.

CKPT checkpoint process

The role of the CKPT checkpoint process is to perform a checkpoint, synchronize all data files in the database, control files, and redo log files. When executing the inspection point, the system urges DBWn to write the changes of the data in the data cache into the data file, at the same time complete the update of the data file and control file, and record the structure and status of the current database. After performing a checkpoint, the database is in a complete state. After a database crash, you can restore the database to the previous checkpoint. When the oracle database executes a statement of data changes, it generates a sequentially incremented SCN value for any change, and records the SCN value in the redo log cache along with the change of things. In the data file. This value is recorded in both the control file header and the redo log file. By comparing the SCN values of various files, oracle determines whether the file is damaged and whether the system is abnormal, and finally determines whether the system needs instance recovery or media recovery. When a checkpoint is issued, the data file. The SCN values of the control file and the redo log are exactly the same.

Classification: global checkpoints (when the database is closed), local checkpoints (tablespaces), incremental checkpoints (cut log groups)

The process CKPT starts to work in the following situations

-- Log switching alter system switch logfile occurs

-- close the instance

-- manually perform checkpoint operation alter system checkpoint

-there are initialization parameters log_checkpoint_interval and log_checkpoint_timeout to issue forcefully.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report