一、项目场景
今天用mysql给elaticsearch,报了一个很奇怪的error, 如下:
The server time zone value '锟叫癸拷锟斤拷\u05FC时锟斤拷' is unrecognized or represents more than one time zone.
二、问题描述
他说不能识别时区,由于视频老师的mysq版本是mysql 5.7,所以引发了我对版本不一样导致报错的思考!!!
三、解决方案
查看之后才发现,原来jdbc连接mysql 8.0的时候,需要指定时区,即在数据库名字后面添加serverTimezone=UTC,如下:
jdbc_connection_string => "jdbc:mysql:///news&serverTimezone=UTC"
这样子就可以顺利连接上了,特此记录一下。
四、tips
特提供一下mysql连接es的脚本文件写法:
input { jdbc { jdbc_driver_library => "D:\mysql-connector-java-8.0.21.jar" jdbc_driver_class => "com.mysql.cj.jdbc.Driver" jdbc_connection_string => "jdbc:mysql:///news&serverTimezone=UTC" jdbc_user => "root" jdbc_password => "123456" schedule => "* * * * *" statement => "SELECT * FROM news;" } } filter { mutate { split => {"tags" => ","} } } output { elasticsearch { hosts => ["120.79.50.65:9200","120.79.50.65:9201","120.79.50.65:9202"] index => "news" document_id => "%{id}" } }
感兴趣的小伙伴,关注下,感谢支持