先说解决方法:最终我的解决方式是使用心跳机制,创建了一个很简单的查询作业,让它每3小时执行一次。
这几天在凌晨1点是跑kettle作业时遇到了一个问题,报错如下:
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.
报错原因是:mysql会默认每8小时回收一次无用连接。
网上的解决方案有很多:
1.加上 autoReconnect=true 参数:在mysql的连接地址上加上 autoReconnect=true 参数,自测无效。
2.修改mysql的wait_timeout参数,mysql中该参数默认是八小时,如果想通过该参数解决上述问题,围绕这个参数可以将kettle的调度时间设置为小于8小时,或者将wait_timeout参数调到很大,但这个对我的具体业务要求来说不合理,所以没用。
3.在配置kettle的数据连接时,用资源库的形式(没有生效,但我仍然人认为是我哪里的参数没有配置正确导致,望可以解决的大佬在评论区告知一二。)