Logstash:无法将MySQL与Logstash连接?

时间:2018-07-12 10:48:28

标签: mysql logstash

我正在尝试使用Logstash与MySQL建立连接,并在下面的conf文件中的代码中写入弹性搜索

input {
    jdbc {
        jdbc_connection_string => "jdbc:mysql://192.168.2.24:3306/test"
        # The user we wish to execute our statement as
        jdbc_user => "uname"
        jdbc_password => "pass"
        # The path to our downloaded jdbc driver
        jdbc_driver_library => "/usr/local/Cellar/logstash/6.2.4/mysql-connector-java-8.0.11.jar"
        jdbc_driver_class => "com.mysql.jdbc.Driver"
        # our query
        statement => "SELECT * FROM report_table"
    }
}

output {
    elasticsearch {
    action => "index"
    hosts => "localhost:9200"
    index => "mysqlsample"
    document_type => "record"
    }
}

在执行上述操作时出现以下错误:

  

错误:com.mysql.jdbc.Driver未加载。确定要包括在内吗   :jdbc_driver_library中正确的jdbc驱动程序?例外:   LogStash :: ConfigurationError堆栈:   /usr/local/Cellar/logstash/6.2.4/libexec/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.9/lib/logstash/plugin_mixins/jdbc.rb:162:in   open_jdbc_connection' /usr/local/Cellar/logstash/6.2.4/libexec/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.9/lib/logstash/plugin_mixins/jdbc.rb:220:in execute_statement'   /usr/local/Cellar/logstash/6.2.4/libexec/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.9/lib/logstash/inputs/jdbc.rb:264:in   execute_query' /usr/local/Cellar/logstash/6.2.4/libexec/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.9/lib/logstash/inputs/jdbc.rb:250:in 运行'   /usr/local/Cellar/logstash/6.2.4/libexec/logstash-core/lib/logstash/pipeline.rb:514:in   inputworker' /usr/local/Cellar/logstash/6.2.4/libexec/logstash-core/lib/logstash/pipeline.rb:507:in 阻止start_input'

1 个答案:

答案 0 :(得分:0)

听起来像是jdbc_driver_library => "/usr/local/Cellar/logstash/6.2.4/mysql-connector-java-8.0.11.jar"的问题。

您确定这是有效路径吗?那是正确的连接器吗?也许尝试使用文档中提到的那个:mysql-connector-java-5.1.36-bin.jar