In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what is redo log". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what is redo log?"
1 what is redo log
To put it simply, redo log is a kind of log of mysql's underlying storage engine innodb. It is finally saved on the disk.
A redo log roughly records the offset in the log type, tablespace id, data page, data page, and specific modified data. That is to say, what type of operation is recorded, the data page of that tablespace is manipulated, and those values are specifically modified.
Simply draw a picture
2 what is the storage structure of redo log
Redo log in the hard disk really table space id+ data page id+ data page offset + modified a few bytes of data + actually modify the data stored? Definitely not.
The true storage structure of redo log is a block block in mysql. This block block is divided into three parts of header body trailer. Real data is stored in body, and some metadata is stored in the header (such as how many bytes of data are stored in body, how many id of current block, groups of redo log, we may have multiple redo log in a transaction, these redo log are in the same group)
3 what is the function of redo log
According to the data structure of redo log storage mentioned above, it can be guessed that it should be used for data recovery, backup and so on, but there are also records in binlog, how to record one more copy? Is the latest information stored in this line of data fault-tolerant? You're right. Redo log is used to redo transactions.
How to understand this. In fact, it is very simple. When mysql actually updates the data, it first updates the memory, and then when it flush to the disk, if the downmachine is down, before the data is flush to the disk, the data in memory will be lost.
This involves the overall flow when mysql executes a sql statement. We'll talk about it later. We'll just say redo log here. After mysql updates the in-memory data, the current transaction is recorded in binlog and archived by update xxxx. Then submit the task (which is actually writing redo log). Make a mark in the redo log to which binlog the current transaction is executed, what the offset is, and so on.
Only in this way can the whole transaction be completed. If the data in the memory of the down machine cannot be flush to disk at this time, mysql will scan the current redo log log to find the corresponding binlog based on the above record to re-execute the side process. Restores the data to memory and disk.
4 what is the write strategy for redo log
We mentioned above that redo log is written in a block, is it written directly to the hard disk? Definitely not, it will greatly reduce the performance of the update.
Mysql writes redo log to memory first, and when is the opportunity to flush the disk, but redo log buffer is not as big as a cache page by default 16MB. After all, a block is only 512 bytes.
So when is the time for flush redo log buffer? The flush operation is performed if the following points are met:
If a transaction involves more than one redo log, then all the redo log in the same group must be flushed to disk, because both succeed or fail in one transaction.
When mysql executes shutdown, it puts all the block flush to disk.
The asynchronous thread sends the block flush from buffer to disk every 1 second.
Flush operation will also be triggered when redo log buffer occupies half of its capacity.
At this point, I believe you have a deeper understanding of "what is redo log", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.