msql的max_connect_errors 问题

Tomcat连接池异常解决
本文介绍了当Tomcat启动后连接池无法正常使用的情况及其原因,包括数据库错误连接达到最大值导致服务器拒绝连接的问题,并提供了几种解决方案,如使用mysqladmin flush-hosts命令解除屏蔽等。
部署运行你感兴趣的模型镜像
一、程序运行一段时间后,tomcat启动后,连接池不能使用,拿不到数据库连接,查看catalina.out发现如下错误:
[http-80-35] ERROR sls.database.DBConn - org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create Poola
bleConnectionFactory (null, message from server: Host localhost is blocked because of many connection errors; unblock with mysqladmin flush-hosts)

二、出现的原因:
数据库的错误链接处达到最大,数据库服务器拒绝连接。
由于出现某台host连接错误次数等于max_connect_errors(默认10) ,主机'host_name'再次尝试时被屏蔽。可有效反的防止dos攻击,使用'mysqladmin flush-hosts'解除屏蔽。【连接次数失败过多,并超过max_connect_erros的值后,服务器会直接拒绝来源机器的所有连接,只要把mysql server默认 max_connect_errors = 10
把这个值设置大点就好了,记得一定要执行mysqladmin flush-hosts命令来解锁,原来的主机才可以恢复正常连接的.】
三、解决方案:
1.查看数据库允许的错误链接数:
show status 看那个abort_client.
2.运行:
mysqladmin flush-hosts命令,解除数据库的连接屏蔽,重新允许数据库被访问。

3.也可以重启mysql数据库,这样,也可以将错误链接数清零。

4.修改my.inf或者:my.cnf修改max_connect_errors的值,可以适当大些。
配置文件中,如果没有此键值,请在[mysqld]内增加该值。
# Maximum amount of errors allowed per host. If this limit is reached,
# the host will be blocked from connecting to the MySQL server until
# "FLUSH HOSTS" has been run or the server was restarted. Invalid
# passwords and other errors during the connect phase result in
# increasing this value. See the "Aborted_connects" status variable for
# global counter.
max_connect_errors = 10

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值