Got timeout reading communication packets解决方法
Got timeout reading communication packets解决方法
http://www.th7.cn/db/mysql/201702/225243.shtml
[Note] Aborted connection xxxx to db:
问题现象:在tail -f/data/logs/mysql/error.log日志中出现大量的如下信息(web用的是Zabbix,设置连接超时时间为100秒):
' host: 'localhost' (Got timeout reading communication packets)
2017-02-05T15:30:19.272811+08:00 28546 [Note] Aborted connection 28546 to db: 'zabbix' user: 'zabbix' host: 'localhost' (Got timeout reading communication packets)
2017-02-05T15:30:22.388624+08:00 28547 [Note] Aborted connection 28547 to db: 'zabbix' user: 'zabbix' host: 'localhost' (Got timeout reading communication packets)
2017-02-05T15:30:27.119216+08:00 28554 [Note] Aborted connection 28554 to db: 'zabbix' user: 'zabbix' host: 'localhost' (Got timeout reading communication packets)
解决办法:
修改[root@lovebuy114 ~]# grep timeout /etc/my.cnf
interactive_timeout = 120
wait_timeout = 120
log_warnings=1 //注意,我这里原来是2。修改成1后,问题现象果然但是已经不存在了。
在命令行中可以这样修改:
mysql>set global log_warning=1;
mysql>set global interactive_timeout = 120;
mysql>set global wait_timeout = 120;
参数简要说明:
1)interactive_timeout:
参数含义:服务器关闭交互式连接前等待活动的秒数。交互式客户端定义为在mysql_real_connect()中使用CLIENT_INTERACTIVE选项的客户端。
参数默认值:28800秒(8小时)
解决无Notice的办法:
grep timeout /etc/my.cnf innodb_lock_wait_timeout = 60
interactive_timeout = 28800
wait_timeout = 22
grep log_warnings /etc/my.cnflog_warnings=2
From:http://blog.csdn.net/jamesyao008/article/details/45098073
修改后,无效,原因是现在是变成了Notice,不是警告:
tail -f/data/logs/mysql/error.log
2017-02-05T15:38:19.678134+08:00 128 [Note] Aborted connection 128 to db: 'zabbix' user: 'zabbix' host: 'localhost' (Got timeout reading communication packets)
2017-02-05T15:38:22.452504+08:00 131 [Note] Aborted connection 131 to db: 'zabbix' user: 'zabbix' host: 'localhost' (Got timeout reading communication packets)
连接、网络类超时
http://www.cnblogs.com/xiaoboluo768/p/6222862.html
共有如下几个:
connect_timeout:默认为10S
wait_timeout:默认是8小时,即28800秒
interactive_timeout:默认是8小时,即28800秒
net_read_timeout:默认是30S
net_write_timeout:默认是60S
handshake流程
在TCP三次握手的基础之上,简历MySQL通讯协议的连接,这个连接建立过程受connect_timeout参数控制
--------------------TCP established--------------------
MySQL Server(10.10.20.96)------->Client(10.10.20.51)
Client(10.10.20.51)------->MySQL Server(10.10.20.96)
MySQL Server(10.10.20.96)------->Client(10.10.20.51)
--------------------established--------------------
在MySQL通讯协议建立连接之后,此时客户端连接的超时受wait_timeout和interactive_timeout参数控制
建立连接后无交互:MySQL server ---wait_timeout--- Client
建立连接交互后:MySQL server ---interactive_timeout--- Client
在如果客户端有数据包传输,那么这个数据包的传输超时由net_read_timeout和net_write_timeout参数控制
-------------------client与server端有数据传输时-------------------
client ----->MySQL Server(net_read_timeout)
client <-----MySQL Server(net_write_timeout)
从上面的结果中可以看到,第一个会话中修改global wait_timeout=5之后,新的连接上来,超过5秒没有发送新的数据包,连接就被断开。
net_write_timeout
mysql服务端向客户端写(发送)数据时,服务端等待客户端响应的超时时间,当服务端正在写数据到客户端时,net_write_timeout控制何时超时
net_read_timeout
mysql服务端从客户端读取(接收)数据时,服务端等待客户端响应的超时时间,当服务端正在从客户端读取数据时,net_read_timeout控制何时超时
MySQL · 答疑解惑 · MySQL 的那些网络超时错误
http://mysql.taobao.org/monthly/2017/05/04/
阿里云内核月报
前言
我们在使用/运维 MySQL 过程中,经常会遇到一些网络相关的错误,比如:
Aborted connection 134328328 to db: 'test' user: 'root' host: '127.0.0.1' (Got timeout reading communication packets)
MySQL 的网络超时相关参数有好几个,这个超时到底是对应哪个参数呢?
在之前的月报中,我们介绍过 MySQL 的 网络通信模块 ,包括各模块间的关系,数据网络包是如何发送接受的,以及结果集的数据格式,大家可以先回顾下。
这里我们对 mysqld 处理网络包时,遇到的超时异常情况进行分析,希望大家在遇到网络相关的报错时,能更好理解和排查问题。
问题分析
MySQL 是平等网络协议,就是说 client 和 server 之间的网络交互是一来一回的,client 发送完请求后,必须等待 server 响应包回来,才能发下一个请求。
对 mysqld 来说,就是接收网络请求,然后内部处理,将结果集返回给客户端,然后等待下一个请求:
先看下 mysqld server 和网络超时相关的参数有哪些:
interactive_timeout
wait_timeout
net_read_timeout
net_write_timeout
connect_timeout
在底层实现上,不管是读还是写操作,超时都是通过 poll(&pfd, 1, timeout) 做的,参数之间的区别是针对连接的不同状态。
读超时
wait_timeout 是给读请求用的,在 do_command 开始就做设置:
my_net_set_read_timeout(net, thd->variables.net_wait_timeout);
这个时候,连接是空闲的,等待用户的请求。
等读完用户的请求包后,连接就变成 active 的,在调用 dispatch_command 执行 SQL 前,通过
my_net_set_read_timeout(net, thd->variables.net_read_timeout);
把超时设置回 net_read_timeout,之后在执行 SQL 请求过程中,server 和 client 基本不会有网络交互,所以这个超时基本用不上。
有一个特殊的情况是 LOAD DATA LOCAL FILE 命令,server 在执行过程中,需要和 client 再做网络交互。
interactive_timeout 是给交互模式的客户端使用的,比如我们常用的 mysql client 工具,这个是在认证过程中设置的,逻辑如下:
static void
server_mpvio_update_thd(THD *thd, MPVIO_EXT *mpvio)
{
thd->client_capabilities= mpvio->client_capabilities;
thd->max_client_packet_length= mpvio->max_client_packet_length;
if (mpvio->client_capabilities & CLIENT_INTERACTIVE)
thd->variables.net_wait_timeout= thd->variables.net_interactive_timeout;
thd->security_ctx->user= mpvio->auth_info.user_name;
if (thd->client_capabilities & CLIENT_IGNORE_SPACE)
thd->variables.sql_mode|= MODE_IGNORE_SPACE;
}
如果客户端的能力位上设置了 CLIENT_INTERACTIVE,会用 interactive_timeout 的值覆盖 wait_timeout 的值。
而一般情况下,我们应用在建立连接时,是不会设置这个能力位的。
写超时
net_write_timeout 对应写超时,在连接认证完成后,server 和 client 交互过程中写超时一真是不变的。
认证超时
connect_timeout 是给连接认证过程用的,读和写都用这个值,认证完成后,读和写分别设置为 net_read_timeout 和 net_write_timeout。
总结
可以看到和读相关的超时参数是最多的,也比较容易搞混乱。
如果是认证过程中超时,不管是读还是,都是 connect_timeout;
对于读网络超时,一般是 wait_timeout/interactive_timeout,基本不会是 net_read_timeout(特例是业务用到 LOAD DATA LOCAL FILE);
对于写网络超时,都是 net_write_timeout。
在遇到超时情况下,可以根据这些原则判断对那个参数做调整。
比如下面这种情况:
2017-05-15 19:32:41 47930 [Warning] Aborted connection 6 to db: 'unconnected' user: 'root' host: 'localhost' (Got timeout reading communication packets)
很可能需要调整的 wait_timeout/interactive_timeout。
2017-05-15 20:06:27 5063 [Warning] Aborted connection 12 to db: 'test' user: 'root' host: 'localhost' (Got timeout writing communication packets)
需要调整 net_write_timeout
需要注意的是,MySQL 的关于网络的错误,除了超时以外都认为是 error,没有做进一步的细分,比如可能会看到下面这种日志,有可能是客户端异常退出了,也有可能是网络链路异常。
2017-05-15 19:34:57 47930 [Warning] Aborted connection 8 to db: 'unconnected' user: 'root' host: 'localhost' (Got an error reading communication packets)
2017-05-15 20:07:39 5063 [Warning] Aborted connection 13 to db: 'test' user: 'root' host: 'localhost' (Got an error writing communication packets)
f
Got timeout reading communication packets解决方法的更多相关文章
- Aborted connection 1055898 to db: 'xxx' user: 'yyy' host: 'xxx.xxx.xxx.xxx' (Got timeout reading communication packets)
mysql错误日志中,发现大量以下类似信息:(mysql 5.7.18) [Note] Aborted connection 1055898 to db: 'xxx' user: 'yyy' host ...
- 打开genesis时一直在等待,后出现Timeout in communication read解决方法
运行输入:netsh winsock reset 然后重启电脑
- 解决mysql日志显示时间和“Got an error reading communication packets” 问题
[root@calldb3 data]# tail -f mysql.error :.884160Z to db: 'calldb' user: 'call' host: '172.31.50.220 ...
- MySQL错误日志显示(Got an error reading communication packets)的问题
错误显示: 2019-05-28T12:54:08.267934+08:00 820396 [Note] Aborted connection 820396 to db: 'Databaseplatf ...
- mysql5.7日志时间戳(log_timestmaps)与系统时间不一致问题以及日志报Got an error reading communication packets情况分析
一.mysql安装后error_log日志时间戳默认为UTC(如下图),因此会造成与系统时间不一致,与北京时间相差8个小时. 解决errro_logs时间戳与linux系统时间不一致问题 step1: ...
- vss error reading from file 解决方法
vss error reading from file 解决方法 1 若服务器中存在 vss/data/backup目录,请将该目录删掉2 运行cmd cd.. cd C:\Program Files ...
- Sublime2编译Python程序EOFError:EOF when reading a line解决方法【转】
在Sublime2中编译运行Python文件时,如果代码中包含用户输入的函数时(eg. raw_input()),Ctrl+b编译运行之后会提示以下错误: 解决方法:安装SublimeREPL打开Su ...
- Error -27728: Step download timeout (120 seconds)的解决方法(转)
LR中超时问题解决方法 超时错误在LoadRunner录制Web协议脚本回放时超时经常出现. 现象1:Action.c(16): Error -27728: Step download timeout ...
- ORA-03113: end-of-file on communication channel 解决方法
今天在测试数据库中对一个表插入了大量的数据, 导致数据库卡死 hang 住, 重启数据库后报错如下: C:\Documents and Settings\davidd>sqlplus " ...
随机推荐
- Android高效加载大图、多图解决方案,有效避免程序OOM(转)
本篇文章主要内容来自于Android Doc,我翻译之后又做了些加工,英文好的朋友也可以直接去读原文. http://developer.android.com/training/displaying ...
- Java Annotation 应用 -- 导出Excel表格
相关知识链接: Introspector(内省) POI 1.声明注解 package com.ciic.component.excel; import java.lang.annotation.El ...
- 深入Java内存模型之阅读理解(2)
锁的释放-获取建立的happens before 关系 锁是java并发编程中最重要的同步机制.锁除了让临界区互斥执行外,还可以让释放锁的线程向获取同一个锁的线程发送消息. 下面是锁释放-获取的示例代 ...
- KSQL和Flink SQL的比较
Confluent公司于2017年11月宣布KSQL进化到1.0版本,标志着KSQL已经可以被正式用于生产环境.自那时起,整个Kafka发展的重心都偏向于KSQL——这一点可以从Confluent官方 ...
- invalid bound statement (not found)解决办法
最近搭建一个web项目后端SSM框架练手,使用Maven管理,遇到一个深坑invalid bound statement (not found),就是mapper文件扫描不到!!! 先上整合过程,解决 ...
- JS 使用html2canvas实现页面截图功能
html2canvas的官方文档地址:http://html2canvas.hertzen.com/ 实现原理:将需要截图的页面在canvas中进行重绘,这样将页面转换成图片的过程. 注意事项: 不支 ...
- 【CF566C】Logistical Questions 点分
[CF566C]Logistical Questions 题意:给你一棵n个点的树,点有点权,边有边权,两点间的距离为两点间的边权和的$3\over 2$次方.求这棵树的带权重心. $n\le 200 ...
- 7.13python多进程
所以引入了 多进程*(异步) 处理效率高 #!/usr/bin/env python #!--*--coding:utf-8 --*-- #!@Time :2018/7/13 19:26 #! ...
- js 去掉花括号
"asd {{name}} {{age}}".replace(/{{(.*?)}}/g,'$1'); // "asd name age" "asd { ...
- js的with语句,和debugger语句
减少操作,速度及慢, 严格模式无法使用 debugger 在程序中打断点 'use strict' var name = 'global'; var obj = { name: "ajanu ...