参考:https://blog.csdn.net/weixin_34293141/article/details/93057113
同事反馈公司的一个java客户端工具运行异常,后台log如下:
2022-12-08 10:52:28 WARN BasicResourcePool:223 - com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@18afde8 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: java.sql.SQLException: null, message from server: "Host 'VBJVDI00378.test.com' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'" at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1095) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031) at com.mysql.jdbc.ConnectionImpl.log重点:
2022-12-08 10:52:28 WARN BasicResourcePool:223 - com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@18afde8 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
java.sql.SQLException: null, message from server: "Host 'VBJVDI00378.test.com' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"
根据重点log,可以找到以下几点:
1)问题:
Host 'VBJVDI00378.test.com' is blocked because of many connection errors
同一个ip在短时间连接MySQL服务失败次数超过max_connection_errors参数设定值(默认10),MySQL则认为是数据库出错,并且阻止了站点的链接。
2)解决方法一:
unblock with 'mysqladmin flush-hosts
终端中执行mysqladmin -uroot -p -h localhost flush-hosts
或者连接数据库后执行flush hosts
mysql>flush hosts
3)解决方法二:
进入数据库将max_connection_errors参数调高,或者修改my.cnf(需要重启MySQL)。
mysql>show variables like '%max_connection_errors%';
mysql>set global max_connect_errors = 1000;
mysql>show variables like '%max_connection_errors%';
注意:配置有master/slave主从数据库的要把主库和从库都修改一遍的。
标签:java,节点,v2,mchange,mysql,锁定,com,BasicResourcePool From: https://www.cnblogs.com/21summer/p/16977662.html