本文爲Windows環境下的相關安裝示例,適用於須要用Logstash和Logstash-input-jdbc將數據從數據庫導入到Elasticsearch中的場景。
安裝JDK8並配置JAVA_HOME環境變量;
安裝Elasticsearch並啓動;java
Logstash官方下載地址mysql
如: 「D:Serverlogstash-6.8.0」git
打開CMD命令行,切換到logstash安裝路徑下的bin目錄,執行:github
logstash -e "input { stdin { } } output { stdout {} }"
正常能夠看到如圖打印啓動成功的信息。sql
能夠輸入測試內容,如「hello world」 進一步驗證。數據庫
CMD命令行切換到bin目錄,執行如下命令安裝Logstash-input-jdbc插件:json
logstash-plugin install logstash-input-jdbc
安裝正常將打印成功信息。框架
input { stdin { } jdbc { jdbc_connection_string => "jdbc:mysql://localhost:3306/example" jdbc_user => "dbuser" jdbc_password => "123456" jdbc_driver_library => "../test/mysql-connector-java-5.1.47.jar" jdbc_driver_class => "com.mysql.jdbc.Driver" statement => "SELECT * FROM user" type => "test" } } output { elasticsearch { hosts => "localhost:9200" index => "world" document_id => "%{id}" } stdout { codec => json_lines } }
logstash -f ../test/test.conf
你將會看到JDBC的查詢結果信息elasticsearch