##################################################
现象如下:
mysql>show slave status\G root@xxxx ((none)) > show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 10.10.10.10 Master_User: mysqlsync Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.001340 Read_Master_Log_Pos: 547580150 Relay_Log_File: relay-bin.000136 Relay_Log_Pos: 533706455 Relay_Master_Log_File: mysql-bin.001340 Slave_IO_Running: Yes Slave_SQL_Running: No Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 1197 Last_Error: Error 'Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again' on query. Default database: 'anno_prod'. Query: 'DELETE FROM `anno_data` WHERE (`anno_data`.`product` = 1 AND `anno_data`.`status` = 1 AND NOT (`anno_data`.`create_time` > '2021-08-13 16:00:05.118436' AND `anno_data`.`create_time` IS NOT NULL))' Skip_Counter: 0 Exec_Master_Log_Pos: 533706242 Relay_Log_Space: 547580651 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: NULL Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 1197 Last_SQL_Error: Error 'Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again' on query. Default database: 'anno_prod'. Query: 'DELETE FROM `anno_data` WHERE (`anno_data`.`product` = 1 AND `anno_data`.`status` = 1 AND NOT (`anno_data`.`create_time` > '2021-08-13 16:00:05.118436' AND `anno_data`.`create_time` IS NOT NULL))' Replicate_Ignore_Server_Ids: Master_Server_Id: 134078452 Master_UUID: 817f44b6-8b55-11e9-aed0-246e96d0a218 Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: 210827 00:00:17 Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 817f33b6-8b55-11e9-aed0-246e96d0a218:1462489829-1499884936 Executed_Gtid_Set: 817f33b6-8b55-11e9-aed0-246e96d0a218:1-1499878645 Auto_Position: 1 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 1 row in set (0.00 sec) Fri Aug 27 00:14:46 2021
解决办法:
mysql> set global max_binlog_cache_size=8589934592; 更改mysql的配置文件my.cnf为: [mysqld] max_binlog_cache_size=8G
第一:max_binlog_cache_size
如果一个事务需要超过这么多字节的内存,服务器会生成一个多语句事务需要超过 'max_binlog_cache_size' 个字节的存储错误。最小值为 4096。可能的最大值为 16EiB(exbibytes)。最大推荐值为 4GB;这是因为 MySQL 当前无法处理大于 4GB 的二进制日志位置。该值必须是 4096 的倍数。
max_binlog_cache_size
仅设置事务缓存的大小;语句缓存的上限由 max_binlog_stmt_cache_size
系统变量控制。
会话的可见性max_binlog_cache_size
与binlog_cache_size
系统变量的 匹配 ;换句话说,更改其值仅影响更改该值后启动的新会话。
第二:max_binlog_size
如果对二进制日志的写入导致当前日志文件大小超过此变量的值,则服务器会轮换二进制日志(关闭当前文件并打开下一个文件)。最小值为 4096 字节。最大值和默认值为 1GB。加密的二进制日志文件有一个额外的 512 字节标头,包含在 max_binlog_size
.
事务以一个块写入二进制日志,因此它永远不会在多个二进制日志之间拆分。因此,如果您有大事务,您可能会看到大于 max_binlog_size
.
如果max_relay_log_size
为 0,则 的值也 max_binlog_size
适用于中继日志。
在服务器上使用 GTID 时,当 max_binlog_size
到达时,如果mysql.gtid_executed
无法访问系统表以从当前二进制日志文件中写入 GTID,则无***换二进制日志。在这种情况下,服务器会根据其binlog_error_action
设置进行响应 。如果IGNORE_ERROR
设置,则服务器上会记录错误并停止二进制日志记录;如果 ABORT_SERVER
设置,则服务器关闭。
第三:max_binlog_stmt_cache_size
如果事务中的非事务性语句需要超过这么多字节的内存,则服务器会生成错误。最小值为 4096。最大值和默认值在 32 位平台上为 4GB,在 64 位平台上为 16EB(艾字节)。该值必须是 4096 的倍数。
max_binlog_stmt_cache_size
仅设置语句缓存的大小;事务缓存的上限完全由 max_binlog_cache_size
系统变量控制。
#########
###########################