ERROR 1160 (08S01) : Got an error writing communication packets

?

应用程序端碰到错误提示,MySQLNonTransientConnectionException:Got an error writing communication packets。与packet有关,之前一直都没有碰到过这个问题。数据库error日志也未见半点异常,到底是怎么一回事呢?

1、故障现象
故障环境:
$ cat /etc/issue
CentOS release 5.9 (Final)
Kernel \r on an \m

[[email protected] ~]$ mysql --version
mysql  Ver 14.14 Distrib 5.6.12, for Linux (x86_64) using  EditLine wrapper

客户端抛出的异常:MySQLNonTransientConnectionException:Got an error writing communication packets
数据库服务器端异常:
mysql> flush tables;
ERROR 1160 (08S01): Got an error writing communication packets

--由于使用了federated引擎,客户端查询的表为federated,以为是bug呢
--而直接查询federated是ok的,有可能是返回的数据量没有达到设置值的缘故,因为我们只是简单的count
mysql> select count(*) from tadv_gold;
+----------+
| count(*) |
+----------+
|    31525 |
+----------+
1 row in set (0.46 sec)

mysql> select count(*) from tadv_invest_record;
+----------+
| count(*) |
+----------+
|     6761 |
+----------+
1 row in set (0.08 sec)

二、分析与解决
MySQL监控看到了Slave has max_allowed_packet size less than master的提示,下面是这个问题的描述:
Each slave in a replication topology should have a max_allowed_packet size at least as large as its master‘s. The max_allowed_packet variable sets an upper limit on the size of any single message between the MySQL server and clients, including replication slaves. If you are replicating large column values (such as might be found in TEXT or BLOB columns) and max_allowed_packet is too small on the master, the master fails with an error, and the slave shuts down the I/O thread. If max_allowed_packet is too small on the slave, this also causes the slave to stop the I/O thread.

建议:
Investigate why slave SZ-DB-SRV01:3307 has a max_allowed_packet size of 4 MiB, which is less than master SZ-DB-SRV01:3306s max_allowed_packet size of 16 MiB.

Links and Further Reading
MySQL Manual: Replication and max-allowed-packet
MySQL Manual: System Variable Index - M
MySQL Manual: Server System Variables
set global max_allowed_packet=16777216

--上面的描述是主从之间的参数max_allowed_packet不一致,似乎与本文的问题无关
--因为我们从该库调用的federated引擎目标表并不位于这个packet值过小的从库,而是另外一个实例。
--即使从库设置的过小,理论上应该不影响当前库federated到另一实例的message大小值。
--还是尝试进行了修改,因为调整到16MB,对当前的硬件影响不会太大。

mysql> show variables like ‘%packet%‘;
+--------------------------+------------+
| Variable_name            | Value      |
+--------------------------+------------+
| max_allowed_packet       | 4194304    |
| slave_max_allowed_packet | 1073741824 |
+--------------------------+------------+
2 rows in set (0.00 sec)

mysql> set global max_allowed_packet=16777216;
Query OK, 0 rows affected (0.00 sec)

mysql> show global variables like ‘%packet%‘;
+--------------------------+------------+
| Variable_name            | Value      |
+--------------------------+------------+
| max_allowed_packet       | 16777216   |
| slave_max_allowed_packet | 1073741824 |
+--------------------------+------------+
2 rows in set (0.00 sec)

--再次flush tables,成功鸟。
mysql> flush tables;                   --Author: Leshami
Query OK, 0 rows affected (0.03 sec)   --Blog  : http://blog.csdn.net/leshami

3、关于参数max_allowed_packet
The maximum size of one packet or any generated/intermediate string, or any parameter sent by the mysql_stmt_send_long_data() C API function. The default is 4MB as of MySQL 5.6.6, 1MB before that.

The packet message buffer is initialized to net_buffer_length bytes, but can grow up to max_allowed_packet. You must increase this value if you are using large BLOB columns or long strings. It should be as big as the largest BLOB you want to use. The protocol limit for max_allowed_packet is 1GB. The value should be a multiple of 1024; nonmultiples are rounded down to the nearest multiple. When you change the message buffer size by changing the value of the max_allowed_packet variable, you should also change the buffer size on the client side if your client program permits it. The default max_allowed_packet value built in to the client library is 1GB, but individual client programs might override this. For example, mysql and mysqldump have defaults of 16MB and 24MB, respectively. They also enable you to change the client-side value by setting max_allowed_packet on the command line or in an option file.The session value of this variable is read only.

时间: 2024-12-14 18:45:15

ERROR 1160 (08S01) : Got an error writing communication packets的相关文章

open数据库报错ERROR at line 1: ORA-03113: end-of-file on communication channel Process ID: 3880 Session ID: 125 Serial number: 3

1.今天打开数据时,失败,报错 ERROR at line 1:ORA-03113: end-of-file on communication channelProcess ID: 3880Session ID: 125 Serial number: 3 2.想看下数据库的状态,发现提示:not connected to ORACLE[email protected]> select status,instance_name from v$instance;ERROR:ORA-03114: no

git推送到github报错:error: The requested URL returned error: 403 Forbidden while accessing https://github.com

最近使用git命令从github克隆仓库到版本,然后进行提交到github时报错如下: [[email protected] git_test]# git push origin mastererror: The requested URL returned error: 403 Forbidden while accessing https://github.com/jsonhc/git_test.git/info/refs fatal: HTTP request failed 解决办法:参考

解决git提交问题error: The requested URL returned error: 403 Forbidden while accessing

git提交代码时,出现这个错误"error: The requested URL returned error: 403 Forbidden while accessing https" 解决方法: 编辑.git文件夹下的config文件就可以. vim .git/config #改动对于的配置 #原来的url = https://github.com/elitecodegroovy/PhoenixC.git url = https://[email protected]/elitec

Error page: /dede/login.php Error infos: No database

登陆dede后台这样提示Error page: /dede/login.php Error infos: No database selected Error sql: Select admin.*,atype.purviews From `dede_admin` admin left join `dede_admintype` atype on atype.rank=admin.usertype where admin.userid like 'admin' limit 0,1登陆dede后台

java.lang.Error: Unresolved compilation problems: Syntax error on token "return", delete this token Type mismatch: cannot convert from Init to String

java.lang.Error: Unresolved compilation problems:   Syntax error on token "return", delete this token  Type mismatch: cannot convert from Init to String Dubbo 在调用服务时候报的错误! 那么问题来了.这什么错? ? 英语不好.     Type mismatch: cannot convert from Init to Strin

Internal error: (org.jdom.input.JDOMParseException) Error on line 1: 文件提前结束。

环境: maven idea tomcat 异常描述: maven clean ,install都没问题,就是点击启动tomcat,时就报错,错误信息如下: Internal error: (org.jdom.input.JDOMParseException) Error on line 1: 文件提前结束.org.jdom.input.JDOMParseException: Error on line 1: 文件提前结束. at org.jdom.input.SAXBuilder.build(

BIP Requests Are Failing With Error "OPP Error Oracle.apps.xdo.XDOException: Error Creating Lock Fil

In this Document   Symptoms   Cause   Solution   References Applies to: BI Publisher (formerly XML Publisher) - Version 12.1 to 12.2 [Release 12.1 to 12.2] Information in this document applies to any platform. Symptoms BiP Requests are failing: ERROR

怎样处理“error C2220: warning treated as error - no object file generated”错误

最近用VS2010 编译ceflib开源库是出现"怎样处理"error C2220: warning treated as error - no object file generated"错误" 产生原因为:有些Project编译选项中,Treat Warnings As Errors(把警告看作错误来处理)选项开启了. 只要把此选项关闭,就可以正常编译了. 在Solution中,选择libMXF工程,右键菜单中选择"Properties".弹

error: Setup script exited with error: command 'gcc' failed with exit status 1

安装python模块时出现:error: Setup script exited with error: command 'gcc' failed with exit status 1 解决方法: yum -y install python-devel error: Setup script exited with error: command 'gcc' failed with exit status 1