ITPub博客

首页 > 数据库 > MySQL > mysql 1129处理

mysql 1129处理

原创 MySQL 作者:T1YSL 时间:2021-05-18 14:35:28 0 删除 编辑

● 1129 - Host '192.168.2.187' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

原因: 

同一个ip在短时间内产生太多中断的数据库连接而导致的阻塞(超过mysql数据库max_connection_errors的最大值)

此时观察 log_error=SQL2012.err 发现大量 如下错误

2021-04-09T05:29:39.615273Z 281 [Note] Aborted connection 281 to db: 'diancui' user: 'root' host: 'SKY-20160310GED' (Got an error reading communication packets)

2021-04-09T05:29:39.615273Z 278 [Note] Aborted connection 278 to db: 'diancui' user: 'root' host: 'SKY-20160310GED' (Got an error reading communication packets)

先来查看两个参数:

show global status like '%abort%'; 

+------------------+-------+

| Variable_name    | Value |

+------------------+-------+

| Aborted_clients  | 123   |      #表示连接的mysql客户端被kill的数量

| Aborted_connects | 697   |   #表示客户端登录失败的数量

+------------------+-------+

Aborted_clients 可能的原因有:

a)客户端没有主动关闭mysql连接mysql_close()。

b)wait_timeout设置很短被mysql干掉了。

c)客户端由于某些原因被干掉了。


Aborted_connects可能的原因有:

a)没有授权或者密码不对。一般错误日志中会有如下报错(Access denied for ‘user’@‘host’)

b)连接数满了。一般报错包含(too many connections)

c)超过链接时间限制,主要有这个参数控制connect_timeout(mysql默认是10s,基本除非网络环境极端不好,一般不会超时。)


解决办法:

方法一: 增加 max_connection_errors 数量, 治标不治本.  set global max_connect_errors = 1000;  show variables like '%max_connection_errors%';

方法二: mysqladmin flush-hosts -h 127.0.0.1 -uroot -p -P3308 或者在数据库中执行 flush hosts;

















来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69990629/viewspace-2772766/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: mysql大页配置
请登录后发表评论 登录
全部评论
中国开源软件推进联盟PG分会系列技术丛书《快速掌握PostgreSQL版本新特性》一书副主编。数据库技术专家。数据库认证讲师、恩墨学院数据库讲师。擅长MySQL数据库、PostgreSQL等开源数据库。拥有MySQL-OCP 、PostgreSQL-PGCM等数据库认证。

注册时间:2020-12-12

  • 博文量
    152
  • 访问量
    160727