【问题标题】:Logstash - JDBC - MYSQL config errorLogstash - JDBC - MYSQL 配置错误
【发布时间】:2016-12-28 16:10:41
【问题描述】:

看完这个教程;

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

我正在尝试使用带有 jdbc 的 logstash 获取我的 localhost mysql(使用 laravel valet mysql)以发送到 elasticsearch server 。

这是我的配置:

# 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}

如何解决?

谢谢

【问题讨论】:

    标签: jdbc elasticsearch logstash


    【解决方案1】:

    jdbc 输入的最后一行有错字

    statement = "SELECT * from Receipt"
    

    应该阅读

    statement => "SELECT * from Receipt"
    

    您还需要在 elasticsearch 输出中进行更改

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

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

    【讨论】:

    • 它修复了,但我得到了新错误:INFO:处理对 {}->search-power-yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.ama… 的请求时捕获的 I/O 异常(java.net.SocketException):连接重置 2016 年 8 月 22 日 5 :07:42 PM org.apache.http.impl.execchain.RetryExec 执行
    • 我收到新错误:search-power-yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.amazonaws.com:989 未能响应 {:class=>"Manticore::ClientProtocolException", :level= >:error}
    • 上述错误已修复,现在新问题:2016 年 8 月 23 日星期二 12:13:37 MYT 警告:不建议在没有服务器身份验证的情况下建立 SSL 连接。根据 MySQL 5.5.45+、5.6.26+ 和 5.7.6+ 的要求,如果未设置显式选项,则默认情况下必须建立 SSL 连接。为了符合不使用 SSL 的现有应用程序,verifyServerCertificate 属性设置为“false”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-19
    • 2015-08-13
    • 2021-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多