flink sql 程序消费kafka数据到mysql设置参数connector.url问题汇总

1.问题现象:

 使用flink sql程序消费kafka数据写入mysql时,使用TVF表值函数,START_ENENT_TIME和END_ENENT_TIME 始终比消费时间小大约13小时。

解决办法

在写入mysql 的sink表时 在connector.url加上参数 “&serverTimezone=Asia/Shanghai” 。

2.问题现象:

com.MySQL.jdbc.CommunicationsException: The last packet successfully received from the server was58129 seconds ago.The last packet sent successfully to the server was 58129 seconds ago, which 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. 

解决办法

如果连接闲置1小时 (1小时内没有进行数据库操作), mysql就会自动断开连接, 要重启flink sql  task 任务导致数据异常报错. 则需要 connection url加上参数: “&autoReconnect=true”

常用 connector.url

'connector.url' = 'jdbc:mysql://192.168.10.101:3600/dbname?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai',

posted @ 2022-12-06 10:51  whiteY  阅读(531)  评论(0编辑  收藏  举报