kettle作业连接mysql资源库8小时后报错

Posted on Posted in kettle异常

kettle作业在运行一段时间后会报错,原因是mysql会默认每8小时回收一次无用连接。错误日志如下:

记录保存到数据库中.0 – The last packet successfully received from the server was 612,479,928 milliseconds ago. The last packet sent successfully to the server was 612,479,928 milliseconds ago. is longer than the server configured value of ‘wait_timeout’. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property ‘autoReconnect=true’ to avoid this problem.

然后你的作业就失败了,必须重新启动kettle才能解决。
经过多次排查,最终解决。

无效解决方案:

加上 autoReconnect=true 参数

外部解决方案:

虽然能解决8小时mysql自动丢弃无用连接的问题,但是不能解决mysql宕机后的自动重连。

1.更改mysql的wait_timeout(默认8小时),改成更长的检测时间,比如1年(在墙内找到的大多数是这种方式)

修改方式,自行百度

2.将kettle的调度周期设置短(在国外的论坛讨论中发现)

例如wait_timeout是8小时,只需把调度周期设为<8小时即可

完美解决方案

在kettle5.4测试不通过,在kettle7测试通过。
配置数据源连接时,采用连接池,配置如下

2021-10-18_16-46-20

关于连接池参数,
kettle使用的是:
apache dbcp connetions pool.
修改方式,自行百度
作者:帅气小伙
链接:https://www.jianshu.com/p/63b78ce2973e
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。