mysql-Redo Logs Redo Log-principle

Source: Internet
Author: User
Tags filegroup

"Redo Log Buffer" "Redo log File"-Principle directory: 1. Redo Log Write process Figure 2. Related Knowledge Points Summary Chart 3.redo_log_buffer principle 4.redo_log_file principle 1. Redo Log Write process: 2. Summary of relevant knowledge points: 3. Redo Log Buffer principleThe Redo log buffer (redo log buffer) is part of the memory area of the InnoDB storage engine. "Redo Log Information--(1)-->redo log buffer--(2)--and redo log File" in (2) involved knowledge: <1>. About innodb_log_buffer_size Size: (default 8M) MySQL > Show variables like ' innodb_log_buffer_size% '; +------------------------+---------+| Innodb_log_buffer_size | 8388608 |+------------------------+---------+ 8388608 (Byte)/1024/1024=8m redo log buffers do not need to be set too large, as long as the amount of transactions generated per second is within the buffer size range. Because buffering is flushed to the log file every second. 8M was enough. <2> In the following three cases, the contents of the redo log buffer are flushed to the redo log files of the external disk.
    1. The Master Thread flushes the redo log buffer to the redo log file every second;
    2. The redo log buffers are flushed to the redo log file when each transaction commits;
    3. When the redo log buffer pool has less than 1/2 remaining space, redo log buffers are flushed to the redo log file.
4. Redo log File Principle<1&gt. Redo Log Description Log file name: The 1.innodb_log_group_home_dir parameter specifies a directory with two files: Ib_logfile0,ib_logfile1 2. The file is called: Redo Log files (redo log file), Logging the transaction log for the InnoDB storage engine。          Crucial!!!     3. For example, if an unexpected server outage results in an instance failure, the InnoDB storage engine ensures the integrity of the data by recovering the redo log to its pre-outage state.          LOG filegroup: 1. There are at least 1 redo log filegroups per InnoDB storage engine, and each group contains at least 2 redo log files (ib_logfile0,ib_logfile1).          2. You can increase the high availability of redo logs by setting up multiple mirrored log groups (mirrored log groups) and placing different groups on different disks. 3. The file size in the log group is consistent and runs in a circular fashion.     When file 1 is full, switch to file 2, file 2 is full, and switch to file 1 again.          Log file parameter: 1.innodb_log_file_size the size of the redo log file. 2.innodb_log_files_in_group Specifies the number of files in the Redo log filegroup, the default 2 3.innodb_mirrored_log_groups specifies the number of log mirror filegroups, the default 1 4.innodb_ LOG_GROUP_HOME_DIR specifies the path where the log filegroup is located, by default./, in the data directory of the database. <2&gt. Redo log File size settings
    1. Too large: May take a long time to recover
    2. Too small: May cause a transaction to need to switch redo log files multiple times, causing the async checkpoint to cause performance jitter.
    3. Error log warning message:
InnoDB:ERROR:the age of the last checkpoint is 9433645,innodb:which exceeds the log group capacity 9433498. Parsing: Redo logs have a Capaci The Ty variable, which represents the final checkpoint, cannot exceed this threshold, and if it is exceeded, some dirty pages in the dirty page list (flush list) in the buffer pool must be written back to disk, which can cause the user thread to block. <3>. Comparison of binary and redo logs: 1. Category binary log: Record MySQL database-related log records, including logs from other storage engines such as Innodb,myisam. Redo log: Records only INNODB storage engine the transaction log itself。 2. Content binary log: Record the specific operation of the transaction content, is a logical log。 Redo log: Records changes for each page Physical Condition。 3. Time Binary log: Commit only before the transaction commits, write disk only once, no matter how large the transaction volume is. Redo log: As the transaction is in progress, There are always redo log strips(Redo Entry) writes the redo log file. <4> Redo log Entry 1. Entry basic Format
Redo_log_type (1 bytes) Space (may <4 bytes after compression) Page_no Redo_log_body
Reod_log_type: occupies 1 bytes, indicating the redo log type. Different operations have different redo log formats, but there are basic formats. Space: The ID of the tablespace, in a compressed manner, may occupy less than 4 bytes. Page_no: The offset of the page is also compressed redo_log_body: The data portion of each redo log, the corresponding function parsing needs to be called when recovering.     <5> Write procedure 1. Redo Log information write redo log buffers and then write redo log files in a certain condition order! 2.redo log buffer is written to redo log file, which is written in 512 bytes, which is the size of a sector. A sector is the smallest unit written and must be written successfully, so double write is not required in the process.

mysql-Redo Logs Redo Log-principle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.