2016-08-22 107 views
0

看完本教程後,Logstash - JDBC - MYSQL配置錯誤

https://www.youtube.com/watch?v=ZnI_rlrei1s

我試圖使用logstash使用JDBC發送到elasticsearch服務器獲取我的本地主機的MySQL(使用laravel代客MySQL的)。

這是我的配置:

# file: db.conf 
input { 
jdbc { 
    # MySQL jdbc connection string to our database, mydb 
    jdb_connection_string => "jdbc:mysql://localhost:3306/dragon" 
    # The user we wish to execute our statement as 
    jdbc_user => "root" 
    # The user password 
    jdbc_password => "" 
    # The path to our downloaded jdbc driver 
    jdbc_driver_library => "/Users/muaz/downloads/logstash/mysql-connector-java-5.1.39-bin.jar" 
    # The name of the deliver clas for MySQL 
    jdbc_driver_class => "com.mysql.jdbc.Driver" 
    # Our query 
    statement = "SELECT * from Receipt" 
} 
} 
output { 
# stdout { codec => json_lines } 
elasticsearch { 
    # protocol = https 
    index => "power_receipt" 
    document_type => "Receipt" 
    document_id => "%{id}" 
    host => "https://search-power-yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.amazonaws.com" 
} 
} 

,我又把它使用命令(logstash文件夾)運行:

./bin/logstash agent -f db.conf 

它產生:

fetched an invalid config {:config=>"# file: db.conf\ninput {\n\tjdbc {\n\t\t# MySQL jdbc connection string to our database, mydb\n\t\tjdb_connection_string => \"jdbc:mysql://localhost:3306/dragon\"\n\t\t# The user we wish to execute our statement as \n\t\tjdbc_user => \"root\"\n\t\t# The user password\n\t\tjdbc_password => \"\"\n\t\t# The path to our downloaded jdbc driver\n\t\tjdbc_driver_library => \"/Users/muaz/downloads/logstash/mysql-connector-java-5.1.39-bin.jar\"\n\t\t# The name of the deliver clas for MySQL\n\t\tjdbc_driver_class => \"com.mysql.jdbc.Driver\"\n\t\t# Our query\n\t\tstatement = \"SELECT * from Receipt\"\n\t}\n}\noutput {\n\t# stdout { codec => json_lines }\n\telasticsearch {\n\t\t# protocol = https\n\t\tindex => \"slurp_receipt\"\n\t\tdocument_type => \"Receipt\"\n\t\tdocument_id => \"%{id}\"\n\t\thost => \"https://search-power-yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.amazonaws.com\"\n\t}\n}\n\n\n", :reason=>"Expected one of #, => at line 15, column 13 (byte 521) after # file: db.conf\ninput {\n\tjdbc {\n\t\t# MySQL jdbc connection string to our database, mydb\n\t\tjdb_connection_string => \"jdbc:mysql://localhost:3306/dragon\"\n\t\t# The user we wish to execute our statement as \n\t\tjdbc_user => \"root\"\n\t\t# The user password\n\t\tjdbc_password => \"\"\n\t\t# The path to our downloaded jdbc driver\n\t\tjdbc_driver_library => \"/Users/muaz/downloads/logstash/mysql-connector-java-5.1.39-bin.jar\"\n\t\t# The name of the deliver clas for MySQL\n\t\tjdbc_driver_class => \"com.mysql.jdbc.Driver\"\n\t\t# Our query\n\t\tstatement ", :level=>:error} 

如何解決呢?

謝謝

回答

1

你有你的jdbc輸入的最後一行一個錯字

statement = "SELECT * from Receipt" 

應該在你的elasticsearch輸出讀

statement => "SELECT * from Receipt" 

而且你需要更改

host => "https://search-power-yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.amazonaws.com" 

hosts => ["https://search-power-yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.amazonaws.com"] 
+0

其固定,但我得到新的錯誤: INFO:I/O異常(java.net.SocketException異常)處理請求以{}當抓 - >的http://搜索加電yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.amazonaws.com:989:Connection reset 2016年8月22日下午5:07:42 org.apache.http.impl.execchain.RetryExec執行 –

+0

我得到了新的錯誤:search-power -yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.amazonaws.com:989無法響應{:class =>「Manticore :: ClientProtocolException」,::level =>:error} –

+0

上面的錯誤已得到修復,現在出現新問題:星期二8月23日12:13:37 MYT 2016 WARN:建立SSL連接而不需要服務器不建議進行身份驗證。根據MySQL 5.5.45+,5.6.26+和5.7.6+的要求,如果未設置顯式選項,則必須默認建立SSL連接。爲了符合不使用SSL的現有應用程序,verifyServerCertificate屬性設置爲'false'。 –