码迷,mamicode.com
首页 > 数据库 > 详细

logstash-input-jdbc 同时同步多个表的情况

时间:2017-11-16 14:10:05      阅读:1606      评论:0      收藏:0      [点我收藏+]

标签:doc   pass   user   pat   nec   log   注意事项   class   rod   

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}"
        }
    }
}

注意事项,数据库里面的字段不要用type,如果有,as成其他的名字,不然的话,这里判断会有异常

logstash-input-jdbc 同时同步多个表的情况

标签:doc   pass   user   pat   nec   log   注意事项   class   rod   

原文地址:http://www.cnblogs.com/tu6ge/p/7843510.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!