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: 'xxx.xxx.xxx.xxx' (Got timeout reading communication packets)
这种Aborted connection情况下,mysql会增加aborted_clients状态计数器的值。这也意味着以下几个问题:
(1)客户端正常连接,但是被异常结束(可能是程序没有正常关闭连接)
(2)客户端sleep的时间超过了wait_timeout、或interactive_timeout的值(这会导致连接被mysql强制关闭)
(3)客户端异常终端,或者查询超出max_allowed_packet的值
mysql> show variables like '%max_allowed_packet%';
+--------------------------+------------+
| Variable_name | Value |
+--------------------------+------------+
| max_allowed_packet | 16777216 |
| slave_max_allowed_packet | 1073741824 |
+--------------------------+------------+
当然,也可能是其它原因导致的。坦白讲,异常终端是很难诊断的,也有可能是和网络、防火墙有关。可以从以下几个方面考虑:
1.如果有大量的连接进程处于sleep状态时间较长,也就意味着应用没有正确、及时关闭数据库连接。强烈建议在应用中能恰当地关闭数据库连接,否则就需要依赖mysql的wait_timeout的设置来关闭连接了。
2.建议检查max_allowed_packet的值,确保该值设置的合理,这样客户端就不会接收到"packet too large"消息提示。如果设置不合理,会异常中断连接。
3.建议关注进程的time_wait数量。如果netstat发现有大量的连接处于time_wait状态,表示该建议应用端调整连接关闭问题了。
# netstat -ano|grep TIME_WAIT
tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55586 TIME_WAIT timewait (32.97/0/0)
tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55367 TIME_WAIT timewait (27.82/0/0)
tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55776 TIME_WAIT timewait (37.09/0/0)
tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:56505 TIME_WAIT timewait (54.61/0/0)
tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55553 TIME_WAIT timewait (31.94/0/0)
tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:56643 TIME_WAIT timewait (57.73/0/0)
tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55221 TIME_WAIT timewait (23.70/0/0)
tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55920 TIME_WAIT timewait (41.18/0/0)
4.确保事务被正确、及时地提交了。
5.确保应用端没有异常中断连接,比如php如果设置了max_execution_time=5,即使你增加connect_timeout的值也不会有效果。其它编程语言也会有类似的问题。
6.检查DNS配置是否有延迟问题。检查是否同时配置了skip_name_resolve,且使用IP验证主机而不是使用主机名。设置该参数后,使用ip验证主机,而不是使用主机名。使用该参数后,mysql授权表中的host列必须是IP地址或者localhost。
7.如果是percona,可以开启审计日志。
8.增加net_read_timeout、net_write_timeout的值,并观察是否还有该错误发生。net_read_timeout很少会导致出错,除非网络环境非常差。
连接异常终端是因为连接没有被正常。server端不会导致连接abort,除非客户端/服务器端发生了网络问题。但这也是网络导致的,而不是server端的问题。网络问题可以借助工具来查看,比如:tcpdump,netstat -s
回到问题的本身,先看看mysql的参数设置:
mysql> show variables like '%timeout%';
+-----------------------------+----------+
| Variable_name | Value |
+-----------------------------+----------+
| connect_timeout | 10 |
| interactive_timeout | 1800 |
| lock_wait_timeout | 31536000 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| wait_timeout | 1800 |
+-----------------------------+----------+
mysql> show global variables like '%log_warning%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_warnings | 2 |
+---------------+-------+
1 row in set (0.00 sec) mysql>
如果log_warnings的值大于1,mysql会将类似信息写入错误日志:
[Warning] Aborted connection 305628 to db: 'db' user: 'dbuser' host: 'hostname' (Got an error reading communication packets)
[Warning] Aborted connection 305627 to db: 'db' user: 'dbuser' host: 'hostname' (Got an error reading communication packets)
如果不想在日志中记录这些信息,可以修改一下log_waring的值:
mysql>set global log_warnings=1;
Aborted connection 1055898 to db: 'xxx' user: 'yyy' host: 'xxx.xxx.xxx.xxx' (Got timeout reading communication packets)的更多相关文章
- [Warning] Aborted connection 11203 to db: 'ide' user: 'nuc' host: 'prd01.mb.com' (Got an error writi
PS:一台物理机扯分了3个虚拟机,一个主db,一个主备,一个从备. 切换到0301的时候 Sep 6 09:16:16 prddb0301 mysqld: 130906 9:16:16 [Warn ...
- 关于Aborted connection告警日志的分析
前言: 有时候,连接MySQL的会话经常会异常退出,错误日志里会看到"Got an error reading communication packets"类型的告警.本篇文章我们 ...
- 【C++竞赛 E】xxx和yyy的旅行
时间限制:1s 内存限制:32MB 问题描述 有n个城市和m条双向铁路.对于任意两个不同的城市x和城市y,两个城市之间有双向铁路,否则有双向公路,通过任意一条直达公(铁)路花费一小时.城市x与城市y存 ...
- ssh登录 The authenticity of host 192.168.0.xxx can't be established. 的问题
scp免密码登录:Linux基础 - scp免密码登陆进行远程文件同步 执行scp一直是OK的,某天在本地生成了公钥私钥后,scp到某个IP报以下错误 The authenticity of host ...
- 创建django的8大步骤xxx.setAttribute('name', 'user'); 添加属性和值 xxx.attr('name') 查看属性的值 $(xxx).addClass 添加样式 $().after() 添加在标签后面
第一步.创建django 方法一:django-admin startproject 方法二: 直接在python上创建 第二步:创建工程名cmdb python manage.py startapp ...
- The authenticity of host 192.168.0.xxx can't be established.
用ssh登录一个机器(换过ip地址),提示输入yes后,屏幕不断出现y,只有按ctrl + c结束 错误是:The authenticity of host 192.168.0.xxx can't b ...
- 好记心不如烂笔头,ssh登录 The authenticity of host 192.168.0.xxx can't be established. 的问题
用ssh登录一个机器(换过ip地址),提示输入yes后,屏幕不断出现y,只有按ctrl + c结束 错误是:The authenticity of host 192.168.0.xxx can't b ...
- 好记心不如烂笔头,ssh登录 The authenticity of host 192.168.0.xxx can't be established. 的问题
用ssh登录一个机器(换过ip地址),提示输入yes后,屏幕不断出现y,仅仅有按ctrl + c结束 错误是:The authenticity of host 192.168.0.xxx can't ...
- ssh The authenticity of host 192.168.0.xxx can't be established
用ssh登录一个机器(换过ip地址),提示输入yes后,屏幕不断出现y,只有按ctrl + c结束 错误是:The authenticity of host 192.168.0.xxx can't b ...
随机推荐
- 轻松python文本专题-字符与字符值转换
场景: 将字符转换成ascii或者unicode编码 在转换过程中,注意使用ord和chr方法 >>> print(ord('a')) 97 >>> print(c ...
- Android中创建PopupMenu弹出式菜单
之前写过一篇创建option menu的文章:Android中创建option menu 本文主要是讲如何创建PopupMenu弹出式菜单 1.首先创建menu文件menu2.xml: <?xm ...
- jQuery开发技巧
jQuery 事件 - submit() 方法 $("form").submit(function(e){}); 当提交表单时,会发生 submit 事件. 该事件只适用于表单元素 ...
- Go语言类型转换库【github.com/demdxx/gocast】的用法
一.导入库: go get github.com/demdxx/gocast 二.测试代码: // main.go package main import ( "fmt" &quo ...
- tomcat6url请求400错误(%2F与%5C)
近期几天,开发接口时.tomcat报了400错误,查了下原因. 错误原因:url中參数部分包括/,默认tomcat是不支持url參数包括: /(%2F),\(%5C). 解析方法:能够通过加入配置Do ...
- linux高精度struct timespec 和 struct timeval
一.struct timespec 定义: typedef long time_t;#ifndef _TIMESPEC#define _TIMESPECstruct timespec {time_t ...
- Aerospike系列:2:商业版和社区版的比较
http://www.aerospike.com/products-services
- oracle12c安装报错:PRVF-0002的解决方法
出错信息: 安装oracle12c, ./runInstaller 启动图形化报错 PRVF-0002 : Could not retrieve local nodename. 原因: 找不到主机名的 ...
- Java HmacSHA1算法
Java HmacSHA1算法 public static String hmacSha1(String src, String key) { try { SecretKeySpec signingK ...
- great tips in soapui
from this site :http://onebyteatatime.wordpress.com/2009/04/18/soapui-tips-n-tricks-part-2/