用logstash2.2.2把mysql数据库中的数据导入到elasticsearch2.2.1

1.解压logstash2.2.2后台,进入到etc目录下,创建logstash-simple.conf,添加如下配置,根据自己的环境修改

input {

    jdbc {

        jdbc_driver_library => "/usr/local/elasticsearch-2.2.1/mysqldriver/mysql-connector-java-5.1.30-bin.jar"

        jdbc_driver_class => "com.mysql.jdbc.Driver"

        jdbc_connection_string => "jdbc:mysql://10.10.13.7:3306/carsrc?autoReconnect=true&useSSL=false"

        jdbc_user => "devuser"

        jdbc_password => "devuser"

        schedule => "* * * * *"

        jdbc_default_timezone => "Asia/Shanghai"

        statement => "SELECT * FROM company_secondcar_source_order;"

    }

}

output {

    elasticsearch {

        index => "carsrc"

        document_type => "secondcarsource"

        document_id => "%{car_source_id}"

        hosts => ["10.10.13.7:9200"]

    }

}

2.然后执行

./logstash -f ../etc/logstash-simple.conf

这样就会把表里的数据导入elasticsearch

posted @ 2017-12-20 15:46  Nice&&Day  阅读(757)  评论(0编辑  收藏  举报