Home >Database >Mysql Tutorial >Completely master the process of writing Binary Log in MySql
This article brings you relevant knowledge about the process of writing Binary Log in mysql, including issues related to "sync_binlog", "binlog_cache_size" and "max_binlog_cache_size". I hope it will be helpful to everyone.
Let’s first take a look at the official document’s description of sync_binlog configuration.
--sync-binlog= | |
sync_binlog | |
Global | |
Yes | |
No | |
Integer | ##Default value |
Minimum value | |
Maximum value | |
sync_binlog=1.
The sync_binlog setting type is unsigned Integer. Generally it is not set to 0. 0 depends on system operation and irregular fsync. It is more dangerous when a power failure or system crash occurs - the transaction is submitted but the Binary Log is missing.Many operating systems and some disk hardware cheats Flush to disk operation. They may tell mysqld that a refresh has occurred even though it hasn't happened yet. In this case, transaction durability is not guaranteed even with the recommended settings, and in the worst case, a power outage may corrupt the InnoDB data. Using a battery-backed disk cache in the SCSI disk controller or the disk itself speeds up file refreshes and makes operations more secure. You can also try disabling caching of disk writes in the hardware cache.
Summary
binlog_cache_size
#System variable | binlog_cache_size | |||||||||||||||||||||
Scope | Golbal | |||||||||||||||||||||
Dynamic | Yes | |||||||||||||||||||||
SET_VAR prompt applies | No | |||||||||||||||||||||
##Type | Integer | |||||||||||||||||||||
Default value | 32768 | |||||||||||||||||||||
Minimum value | 4096 | |||||||||||||||||||||
Maximum value (64-bit platform) | 2^64=18446744073709547520 | |||||||||||||||||||||
Maximum value (32-bit platform) | 2^32=4294967295 | |||||||||||||||||||||
Block size | 4096 | |||||||||||||||||||||
The size of the memory buffer to hold binary log changes during a transaction. The value must be a multiple of 4096. When binary logging is enabled on a server (the log_bin system variable is set to ON), each client is assigned a binary log cache if the server supports any transaction storage engine. If a transaction's data exceeds the space in the memory buffer, the excess data is stored in a temporary file. When binary log encryption is active on the server, the memory buffer is not encrypted, but (starting with MySQL 8.0.17) any temporary files used to hold the binary log cache are encrypted. After each transaction is committed, the binary log cache is reset by clearing the memory buffer and truncating the temporary file (if used). If you frequently use large transactions, you can increase this cache size for better performance by reducing or eliminating the need to write temporary files. Binlog_cache_use (service status variable - the number of transactions using the Binary Log cache) and Binlog_cache_disk_use (service status variable - the number of transactions using the temporary binary log cache but exceeding the binlog_cache_size value and using temporary files to store transaction statements.) status variables can be used to adjust this variable size. See Section 5.4.4, “Binary Logs”.
Summary
max_binlog_cache_size
|
The above is the detailed content of Completely master the process of writing Binary Log in MySql. For more information, please follow other related articles on the PHP Chinese website!