is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
2016-01-27 11:34
776 查看
一.问题描述
研发跟我反映他们从某个地址访问mysql数据库报类似如下错误
ERROR 1129 (00000): #HY000Host 'aaaa' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
二.问题可能原因
该问题是从某个地址到数据库产生了过多连续的不成功的连接(因为在成功连接之前连接被中断了),详细信息该考如下官方文档中关于max_connect_errors的说明
If more than this many successive connection requests from a host are interrupted without a successful connection, the server blocks that host from further connections. You can unblock blocked hosts by flushing the host cache. To do so, issue a
flush-hostscommand. If a connection is established successfully within fewer than
after a previous connection was interrupted, the error count for the host is cleared to zero. However, once a host is blocked, flushing the host cache is the only way to unblock it. The default is 100 as of MySQL 5.6.6, 10 before that.
##如果从某个地址连续多次发起的数据库连接请求在未成功完成连接之前就被中断,在这样的请求到达一定次数后(max_connect_errors设定值)数据库会阻塞这个地址过来的连接(报错信息如is
blocked because of many connection errors)。刷新host cache可以解除阻塞。你可以通过执行flush hosts或者mysqladmin flush-host 命令来刷新 host cache。如果在不成功的连接达到max_connect_errors之前,从该地址成功连接到数据库了,那么该error计数被清零。一旦某个地址因为这个原因连接被阻塞,那么flushing the host cache 是唯一的解决方法。
三. 分析并解决问题
1)查看数据库当前max_connect_errors参数设置
2)查看研发反应的地址 是否达到了max_connect_errors限制
我们可以通过performanc_schema数据库下的host_cache表查看
3) 解决问题
从官方文档中我们可以知道,该问题通过flush host cache来解决
##执行flush hosts命令后 host_cache表被清空,问题解决。
研发跟我反映他们从某个地址访问mysql数据库报类似如下错误
ERROR 1129 (00000): #HY000Host 'aaaa' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
二.问题可能原因
该问题是从某个地址到数据库产生了过多连续的不成功的连接(因为在成功连接之前连接被中断了),详细信息该考如下官方文档中关于max_connect_errors的说明
max_connect_errors
Command-Line Format | --max_connect_errors=# | |
System Variable | Name | max_connect_errors |
Variable Scope | Global | |
Dynamic Variable | Yes | |
Permitted Values (32-bit platforms, <= 5.6.5) | Type | integer |
Default | 10 | |
Min Value | 1 | |
Max Value | 4294967295 | |
Permitted Values (32-bit platforms, >= 5.6.6) | Type | integer |
Default | 100 | |
Min Value | 1 | |
Max Value | 4294967295 | |
Permitted Values (64-bit platforms, <= 5.6.5) | Type | integer |
Default | 10 | |
Min Value | 1 | |
Max Value | 18446744073709551615 | |
Permitted Values (64-bit platforms, >= 5.6.6) | Type | integer |
Default | 100 | |
Min Value | 1 | |
Max Value | 18446744073709551615 |
FLUSH HOSTSstatement or execute a mysqladmin
flush-hostscommand. If a connection is established successfully within fewer than
max_connect_errorsattempts
after a previous connection was interrupted, the error count for the host is cleared to zero. However, once a host is blocked, flushing the host cache is the only way to unblock it. The default is 100 as of MySQL 5.6.6, 10 before that.
##如果从某个地址连续多次发起的数据库连接请求在未成功完成连接之前就被中断,在这样的请求到达一定次数后(max_connect_errors设定值)数据库会阻塞这个地址过来的连接(报错信息如is
blocked because of many connection errors)。刷新host cache可以解除阻塞。你可以通过执行flush hosts或者mysqladmin flush-host 命令来刷新 host cache。如果在不成功的连接达到max_connect_errors之前,从该地址成功连接到数据库了,那么该error计数被清零。一旦某个地址因为这个原因连接被阻塞,那么flushing the host cache 是唯一的解决方法。
三. 分析并解决问题
1)查看数据库当前max_connect_errors参数设置
mysql> show variables like 'max_connect_errors'; +--------------------+-------+ | Variable_name | Value | +--------------------+-------+ | max_connect_errors | 500 | +--------------------+-------+ 1 row in set (0.00 sec)
2)查看研发反应的地址 是否达到了max_connect_errors限制
我们可以通过performanc_schema数据库下的host_cache表查看
mysql> use performance_schema; Database changed mysql> select * from host_cache\G; *************************** 1. row *************************** IP: 172.172.xxx.123 HOST: xxxx.xx.xxx.com HOST_VALIDATED: YES SUM_CONNECT_ERRORS: <span style="color:#ff0000;">500 >>我们可以看到error计数已经达到设定的500次,所以从这个地址过来的连接请求会被阻塞</span> COUNT_HOST_BLOCKED_ERRORS: 18832 COUNT_NAMEINFO_TRANSIENT_ERRORS: 34556 COUNT_NAMEINFO_PERMANENT_ERRORS: 0 COUNT_FORMAT_ERRORS: 0 COUNT_ADDRINFO_TRANSIENT_ERRORS: 0 COUNT_ADDRINFO_PERMANENT_ERRORS: 0 COUNT_FCRDNS_ERRORS: 0 COUNT_HOST_ACL_ERRORS: 0 COUNT_NO_AUTH_PLUGIN_ERRORS: 0 COUNT_AUTH_PLUGIN_ERRORS: 0 COUNT_HANDSHAKE_ERRORS: 34809 COUNT_PROXY_USER_ERRORS: 0 COUNT_PROXY_USER_ACL_ERRORS: 0 COUNT_AUTHENTICATION_ERRORS: 0 COUNT_SSL_ERRORS: 0 COUNT_MAX_USER_CONNECTIONS_ERRORS: 0 COUNT_MAX_USER_CONNECTIONS_PER_HOUR_ERRORS: 0 COUNT_DEFAULT_DATABASE_ERRORS: 0 COUNT_INIT_CONNECT_ERRORS: 0 COUNT_LOCAL_ERRORS: 0 COUNT_UNKNOWN_ERRORS: 0 FIRST_SEEN: 2015-11-27 17:48:29 LAST_SEEN: 2016-01-27 10:54:09 FIRST_ERROR_SEEN: 2015-11-27 17:48:29 LAST_ERROR_SEEN: 2016-01-27 10:54:09
3) 解决问题
从官方文档中我们可以知道,该问题通过flush host cache来解决
mysql> flush hosts; Query OK, 0 rows affected (0.00 sec) mysql> select * from host_cache\G; Empty set (0.00 sec) ERROR: No query specified
##执行flush hosts命令后 host_cache表被清空,问题解决。
相关文章推荐
- mysql-group_concat
- MySQL的lock tables和unlock tables的用法(转载)
- mysql5.6全量备份
- MySQl的几个配置项
- mysql 日期函数相关 及一个小sql写法
- mysql 常用命令集锦[绝对精华]
- mysql5.7 gtid复制安装及排错
- MySQL5.6.11安装步骤(Windows7 64位)
- MySQL中的LOCATE和POSITION函数使用方法
- MySQL服务安装之二:二进制方式一键安装脚本
- MySQL四舍五入函数ROUND(x)、ROUND(x,y)和TRUNCATE(x,y) 【转】
- mysql中优化sql语句查询的30种方法
- Mysql host '192.168.1.1' is not allowed to connect to this mysql server
- Mysql自定义函数
- mysql 主从不同步处理--数据库初始化
- vs2012利用MFC开发基于对话框的小软件指南(连接Mysql数据库)
- mysql5.7.10下载安装、配置与使用
- 前出塞mysql中update的low_priority解决并发问题
- mysql查询首字母小写的例子
- mysql 中的case when 和ifnull判断