logstash:无法使用logstash连接mysql?

问题描述 投票:0回答:2

我正在尝试使用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::配置错误堆栈: /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
  
执行语句' /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'中的块

mysql logstash
2个回答
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


0
投票

根据MySQL文档

要使用的类是

com.mysql.cj.jdbc.Driver
。你尝试过吗?

© www.soinside.com 2019 - 2024. All rights reserved.