下载
解压
jdbc插件安装
logstash-plugin install logstash-input-jdbc
编辑conf文件
input {
stdin { }
jdbc {
jdbc_connection_string => "jdbc:mysql://ip:3306/test"
jdbc_user => ""
jdbc_password => ""
jdbc_driver_library => "/home/es/es6.4.3/logstash/lib/mysql-connector-java-8.0.13.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
statement => "SELECT * FROM banner"
schedule => "* * * * *"
}
}
output {
stdout {
codec => json_lines
}
elasticsearch {
hosts => "localhost:9200"
index => "banner"
document_type => "banner"
document_id => "%{id}"
}
}
执行
sh logstash -f ../config/mysqlToEs.conf
后台运行
nohup ./logstash -f ../config/mysqlToEs.conf &