老师您好,我想用logstash做数据割接,从mysql迁移数据处理数据到另外一个mysql,
使用使用过程中报错:
[2020-01-02T20:47:09,791][ERROR][org.logstash.Logstash ] java.lang.NoClassDefFoundError: Could not initialize class com.mysql.jdbc.PreparedStatement
我用http输入json的方式测试了jdbc-out-put插件,数据可以正常入库
单独测试了input-jdbc可以从数据库中读取数据
请问两个一起使用怎么就报错了呢?
我的config文件:
input {
jdbc {
jdbc_connection_string => "jdbc:mysql://192.168.14.197:3306/logstash197"
jdbc_user => "root"
jdbc_password => "root"
jdbc_driver_library => "E:\maven_jars\mysql\mysql-connector-java\5.1.16\mysql-connector-java-5.1.16.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
statement => “select user_id,user_name,age,money,DATE_FORMAT(create_time, ‘%Y-%m-%d %H:%i:%s’) as create_time from user”
}
}
filter {
mutate {
add_field => {"temp_ts" => "%{create_time}"}
remove_field => ["@timestamp"]
remove_field => ["@version","message","host","path","@timestamp"]
}
date {
match => ["temp_ts", "yyyy-MM-dd HH:mm:ss"]
target => ["temp_ts"]
remove_field => ["create_time"]
}
}
output {
stdout {
codec => rubydebug
}
jdbc{
driver_jar_path => “C:\Users\Administrator.m2\repository\mysql\mysql-connector-java\5.1.27\mysql-connector-java-5.1.27.jar"
driver_class => “com.mysql.jdbc.Driver"
connection_string => “jdbc:mysql://192.168.14.197:3306/logstash197?user=root&password=root"
statement => [“replace into user_copy(user_id, user_name, age, money,create_time) values(?,?,?,?,?)”,”[user_id]”, “[user_name]”, “[age]”, “[money]”,”[temp_ts]"]
}
}