binlog_cache_size的大小必须为4096的倍数,不然会有一个warning, “Warning | 1292 | Truncated incorrect binlog_cache_size value: '33792'”,然后向下取最接近n个4096的值。
官方文档上关于binlog_cache_size的描述如下:
binlog_cache_size
The size of the cache to hold changes to the binary log
during a transaction. A binary log cache is allocated for
each client if the server supports any transactional storage
engines and if the server has the binary log enabled
(--log-bin option). If you
often use large transactions, you can increase this cache
size to get better performance. The Binlog_cache_use and Binlog_cache_disk_use status variables can be useful for tuning the size of this
variable. See Section 6.4.4, “The Binary Log”.
binlog_cache_size sets the size for the
transaction cache only; the size of the statement cache is
governed by the binlog_stmt_cache_size system variable.
实验:
mysql> select 4096/1024
-> ;
+-----------+
| 4096/1024 |
+-----------+
| 4.0000 |
+-----------+
1 row in set (0.00 sec)
mysql> set global binlog_cache_size=1024*4;
Query OK, 0 rows affected (0.00 sec)
mysql> set global binlog_cache_size=1024*8;
Query OK, 0 rows affected (0.00 sec)
mysql> set global binlog_cache_size=1024*4*2;
Query OK, 0 rows affected (0.00 sec)
mysql> set global binlog_cache_size=1024*4*3;
Query OK, 0 rows affected (0.00 sec)
mysql> set global binlog_cache_size=1024*5;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+-----------------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------------+
| Warning | 1292 | Truncated incorrect binlog_cache_size value: '5120' |
+---------+------+-----------------------------------------------------+
1 row in set (0.00 sec)
mysql> set global binlog_cache_size=1024*6;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> set global binlog_cache_size=1024*7;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> set global binlog_cache_size=1024*9;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> set global binlog_cache_size=1024*10;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> show variables like 'binlog_cache_size';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| binlog_cache_size | 8192 |
+-------------------+-------+
1 row in set (0.00 sec)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26735168/viewspace-2112732/
,如需转载,请注明出处,否则将追究法律责任。