MySQL 客户端报错 no operations allowed after connection closed

这个报错一般是客户端连接已经被中断了,但客户端不知道,还想重用该连接,在重用的时候就会遇到 no operations allowed after connection closed。

通过show processlist命令可以看到部分应用连接空闲时间很长(command字段为sleep,time为空闲时间)。

 

一、 可能导致该报错原因

  • 数据库中 interactive_timeout 参数设置过短 [10-86400]
  • 数据库中 wait_timeout 参数设置过短 [1-31536000]
  • Connection pools 中 connection 的 lifetime 设置过长
  • 防火墙有空闲超时设置

二、 可用解决方法

  • 增大数据库中 interactive_timeout 参数设置
  • 增大数据库中 wait_timeout 参数设置
  • 缩短 Connection pools 中 connection 的 lifetime 设置
  • 应用定期发送例如 select 1语句到数据库,保活连接
  • 加长防火墙空闲超时设置

猜你喜欢

转载自blog.csdn.net/Hehuyi_In/article/details/111563469