mysql5.7.17日志时间戳(log_timestmaps)与系统时间不一致问题以及日志报Got an error reading communication packets情况分析

一、mysql安装后error_log日志时间戳默认为UTC(如下图),因此会造成与系统时间不一致,与北京时间相差8个小时。

mysql5.7.17日志时间戳(log_timestmaps)与系统时间不一致问题以及日志报Got an error reading communication packets情况分析_第1张图片

解决errro_logs时间戳与linux系统时间不一致问题

step1:

登录到mysql环境执行

SET GLOBAL log_timestamps = SYSTEM;(立即生效,重启mysql服务,失效)

step2:

vim /etc/my.cnf 添加配置如下,保证下次mysqld重启依然生效

mysql5.7.17日志时间戳(log_timestmaps)与系统时间不一致问题以及日志报Got an error reading communication packets情况分析_第2张图片

 二、关于mysql的error_log出现" Got an error reading communication packets"

先来查看两个参数:

mysql5.7.17日志时间戳(log_timestmaps)与系统时间不一致问题以及日志报Got an error reading communication packets情况分析_第3张图片

解释:

Aborted_clients  1  #表示有一个连接的mysql客户端被连接被kill的数量,在error_log下为这样

2017-10-16T05:56:27.610616Z 90 [Note] Aborted connection 90 to db: 'app' user: 'root' host: '1.202.149.126' (Got an error reading communication packets)
2017-10-16T05:59:00.829660Z 329 [Warning] IP address '192.168.0.8' could not be resolved: Name or service not known

 MySQL认为读到了一个错误的包,并将该连接Aborted

模拟:

在linux下打开多个客户端,每个客户端登录mysql,然后我们在其中的一个linux客户端下,强制kill其他mysql客户端登录进程,同时监控error_log情况,即可出现上面日志情况。

 Aborted_connects 7 #表示有客户端因为密码或其他什么原因登录失败的数量

你可能感兴趣的:(mysql)