logstash同步mysql数据,多表同步配制

来源:互联网 发布:内存稳定性测试软件 编辑:程序博客网 时间:2024/06/11 10:42
input {
    stdin {
    }
    jdbc {
      # mysql jdbc connection string to our backup databse
      jdbc_connection_string => "jdbc:mysql://192.168.42.147:3306/test"
      # the user we wish to excute our statement as
      jdbc_user => "root"
      jdbc_password => "root"
      # the path to our downloaded jdbc driver
      jdbc_driver_library => "/home/hadoop/opt/logstash-2.3.2/mysql-connector-java-5.1.29.jar"
      # the name of the driver class for mysql
      jdbc_driver_class => "com.mysql.jdbc.Driver"
      jdbc_paging_enabled => "true"
      jdbc_page_size => "50000"
      statement_filepath => "jdbc.sql"
      schedule => "* * * * *"
      type => "gjhz"
    }
jdbc {
      # mysql jdbc connection string to our backup databse
      jdbc_connection_string => "jdbc:mysql://192.168.42.147:3306/test"
      # the user we wish to excute our statement as
      jdbc_user => "root"
      jdbc_password => "root"
      # the path to our downloaded jdbc driver
      jdbc_driver_library => "/home/hadoop/opt/logstash-2.3.2/mysql-connector-java-5.1.29.jar"
      # the name of the driver class for mysql
      jdbc_driver_class => "com.mysql.jdbc.Driver"
      jdbc_paging_enabled => "true"
      jdbc_page_size => "50000"
      statement_filepath => "jdbc2.sql"
      schedule => "* * * * *"
      type => "rjfw"
    }
}


filter {
    json {
        source => "message"
        remove_field => ["message"]
    }
}


output {
 if [type] == "gjhz"{
elasticsearch {
        hosts => "192.168.42.190:9200"
        index => "zkr"

document_id => "%{a_id}"
    }
 }else{
elasticsearch {
        hosts => "192.168.42.190:9200"
        index => "zkr"
document_id => "%{d_id}"
    }
 }
    


    stdout {
        codec => json_lines
    }
}