系统中 logstash-input-jdbc 同步时需要多个不同业务的索引
如果我想将a表的内容同步到 y 索引的 a类型下, 将b表内容同步到 y 索引的b类型下,如何配置?
Google了下,看到有博主这样配置
但是测试后发现结果并不对!!!
下面是我的配置:
input {
jdbc {
jdbc_connection_string => "jdbc:mysql://localhost:3306/crm?zeroDateTimeBehavior=convertToNull"
jdbc_user => "root"
jdbc_password => ""
jdbc_driver_library => "D:/siyang/elasticsearch-5.2.2/logstash-5.2.2/mysql-connector-java-5.1.30.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
statement_filepath => "filename.sql"
schedule => "* * * * *"
type => "jdbc_office"
}
jdbc {
jdbc_connection_string => "jdbc:mysql://localhost:3306/crm?zeroDateTimeBehavior=convertToNull"
jdbc_user => "root"
jdbc_password => ""
jdbc_driver_library => "D:/siyang/elasticsearch-5.2.2/logstash-5.2.2/mysql-connector-java-5.1.30.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
statement => "SELECT * from sys_user"
schedule => "* * * * *"
type => "jdbc_user"
}
}
output {
stdout {
codec => json_lines
}
if[type] == "jdbc_office"{
elasticsearch {
hosts => "localhost:9200"
index => "contacts4"
document_type => "office1"
document_id => "%{id}"
}
}
if[type] == "jdbc_user"{
elasticsearch {
hosts => "localhost:9200"
index => "contacts4"
document_type => "user1"
document_id => "%{id}"
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
大意了!!原因在filename.sql中,这条查询语句在logs中报了异常:[logstash.inputs.jdbc ] Exception when executing JDBC query {:exception=>#<Sequel::DatabaseError: Java::JavaSql::SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp>}。