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

Oracle 11g R2 manages redo log files

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

The redo log is also called the online redo log. The purpose of introducing redo logs is data recovery. During the operation of the database, the data changed by the user will be temporarily stored in the high-speed buffer of the database. In order to improve the speed of writing data, it is not necessary to write the changed data into the data file as soon as the data changes. Frequently reading and writing disk files will reduce the efficiency of the database system, so when the data in the database high-speed buffer reaches a certain amount or meets certain conditions, the DBWR process will write the changed data to the data file. In this case, if there is an outage before DBWR writes the changed changes to the data file, all data in the data cache will be lost. It is obviously not possible to recover this part of the user-changed data after the database is restarted.

The redo log is to save the changed data first, in which the LGWR process is responsible for writing the user-changed data to the redo log file, so that when the database starts, the database system reads the changed data from the redo log file, submits the user-changed data to the database, and writes to the data file.

To improve disk efficiency and prevent damage to redo log files, oracle uses a special redo log file structure, which consists of three redo log groups, each containing two redo log group members. When the first log group is full, it stops writing and writes to the second log group. When the second log group is full, it writes to the second log group. After the third log group is full, it writes to the first log group. Oracle uses this circular approach to use redo log groups.

Oracle stipulates that each database has at least two log groups, and each group contains at least one or more log members. The redo log group is used in the oracle loop. When a redo log group is full, the log is switched to other redo log groups that it can find. Before using the new redo log group, the DBWR process needs to write all data changes to the data file. If the database is in archive mode, when a log switch occurs, the archiving process (ARCH) copies the data from the currently full redo log file to the archive log.

The purpose of designing multiple log members is to provide backup in time after a log file in the log group is damaged, so the log members of the same group generally have the same content information, but the storage location is different.

Read redo log file information

The data dictionary view V$log records the log group sequence number of the current database, the log sequence number, the size of each log file, the number of members of each log group, and the current status of the log group.

Use V$LOG to view redo log information

The output has three log groups, each with a log file. Log group 2 is the redo log group currently in use, which is called the current log group. The current log file has not been archived, and other inactive redo log files have been archived.

The data dictionary V$LOGFILE records the current log group number, the status, type, and membership information of the log group.

Use V$LOGFILE to view redo log group information

Parameter status is defined as follows:

Blank: this file is in use.

Stale: the contents of this file are incomplete

Invalid: this file cannot be accessed, such as just created

Deleted: this file is no longer useful

As you can see from the above output, the database has three redo log groups, each with one redo log file.

Redo the log group and its member management

Create a redo log group:

An oracle database log group is too small, which may cause frequent log file switching and affect system performance, so it is sometimes necessary to add new log groups. If there is only one log member in the log group, you need to add a new log member to avoid corruption.

Use v$log to view redo log information

Use v$logfile to view redo log group information

How to create a redo log group:

Delete redo log group

Add delete redo log file

You will find that the newly added log file redo33.log is invalid, and the log members of the three log groups are not yet full, so redo33.log is invalid. As long as you do two forced log switches, you can find that it is ONLINE.

Delete redo log file

Go to the operating system log file storage directory to see if redo33.log still exists.

View redo log information. Group3 is the current log group.

Delete the log file redo33.log in log group 3, and you will find that there is no way to delete the log files in the current log group.

After you force the log switch, you can delete the newly added log files.

The restrictions for deleting redo log files are as follows

A member of the current group cannot be deleted. If you want to delete it, execute the command to forcibly switch the redo log: alter system switch logfile.

Activities log members cannot be deleted

Log members that are not archived cannot be deleted

Only one member of the current log group is and cannot be deleted

Log group switching and checkpoint events

Log switching is to stop writing the current log group and move to a new log group. The system can switch automatically or manually. When a log switch occurs, the system completes the checkpoint operation in the background to reduce the recovery time of the instance.

A checkpoint is an event that reduces the time it takes for an instance to recover. When the checkpoint occurs, it will start the DBWR process and write the changed data in the data high-speed buffer to the data file. At the same time, the checkpoint process updates the control file and the data file header to ensure the consistency of the data. A checkpoint is actually a background process that ensures that the data of all modified database buffers is written to the data file.

The more frequent checkpoint events, the less data in the redo logs that require data recovery in the event of a database failure (because at restore, you do not have to check the data in the redo logs prior to the recovery checkpoint), so the recovery time of the instance is reduced.

Force log switching and force checkpoint events to be generated.

Force log switching

Force checkpoint events

If you have any questions about this article, please add Wechat below to discuss it.

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

Database

Wechat

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

12
Report