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's redo log

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

When the Oracle database is running, the data changed by the user will first be stored in the database cache. In order to improve disk read and write, the oracle mechanism will not write the buffer data to disk frequently, but will not write to the database file until the checkpoint or data cache reaches a certain number. If the system dies before the checkpoint or the amount of data is met, the data submitted by the user will be lost because the data is still in memory. In order to prevent data loss, oracle proposes a redo log.

The purpose of the redo log is for data recovery, and the LGWR process is responsible for giving priority to writing the data changed by the user to the redo log file.

Trigger conditions of LGWR:

At the time of transaction commit (COMMIT)

Redo Log Buffer 1/3 full

Records of changes in Redo Log Buffer of more than one trillion

Before DBWn writes to the data file

If archiving is enabled in the database (check whether the archive log list is archived), the redo log closes the current log file and moves the contents of the redo log file to the archive file, and polls the next set of available redo log groups after archiving.

View the system's current redo log file information

For example, the database above has 5 log groups, each with 2 log members; the visual database has the archive mode enabled, and the redo logs currently in use are the fourth group of redo logs.

View redo log file location

Each redo log file in a redo log group is called a member, and each member of a group has the same log serial number (log sequence number) and the same file size.

Give me a self-drawn schematic diagram.

In actual production, multiple redo log groups need to be added, and each log group has at least one redo log member, which is stored in a different disk partition.

Practice: add redo log groups and log members.

Alter database add logfile group 6 ('/ u01 Accord size size 5M)

Add a redo log group 6 above, and the redo log members have two redo0601.log and redo0602.log of 5m size.

Check the usage of the log group you just added. The newly added log group is not using Unused.

Practice: delete redo log group

Alter database drop logfile group 6mo-if the active status cannot be deleted

The redo log group has six states:

UNUSED: indicates that the file corresponding to this online redo log filegroup has never been written to data, usually the newly created or rebuilt online redo log file.

CURRENT: represents the log filegroup currently in use. The online redo log group is active.

ACTIVE: indicates that the group is active but not the current group. This set of logs is required for instance recovery. If you are in this state, it means that although it is not currently in use, all the data in the file is not written to the data file, and once you need to restore the instance, you must rely on the contents saved in the file. It can be archived or unarchived.

INACTIVE: indicates that this online redo log group is no longer needed for instance recovery, and all the data in the file is written to the data file. The group of online redo logs is currently idle. It can be archived or unarchived.

CLEARING: after the ALTER DATABASE CLEAR LOGFILE is executed, it indicates that the group redo log files are being rebuilt (this state will become UNUSED after reconstruction).

CLEARING_CURRENT: indicates that an error occurred while redoing log reconstruction in this group, such as io error.

Practice: add redo log members

Alter database add logfile member'/ u01 to group to group 6

Practice: delete redo log members

Alter database drop logfile member'/ u01qqappA'/ u01qqappr'oracle 'oradata 'redo0603.log'

Actual combat: switching logs

Execute: alter system switch logfile

Become available after switching

If you want to reset the redo log file size, you need to delete the log group, rebuild the redo log group and set the new redo member size

1.alter database drop logfile group 6

2.alter database add logfile group 6 ('/ u01max size size 100m)

If you cannot delete the redo log group, execute alter system switch logfile (you can switch multiple times) and check the log group status, or you can delete it if it is INACTIVE. The function of this checkpoint is that the LGWR process writes the redo log buffer data to the redo log file and informs the DBWR process to write the data submitted by the database high-speed buffer to the data file.

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