【问题标题】:Incremental indexing using Logstash from SQL Server to Elasticsearch使用 Logstash 从 SQL Server 到 Elasticsearch 的增量索引
【发布时间】:2020-01-10 03:33:03
【问题描述】:

大家好,我在运行我的 logstash 以从 SQLserver 数据库索引记录到 elasticsearch 时遇到错误

Java Version : 13
Logstash : 7.2.0
Elastic search :  7.2.0
JDBC Driver :  mssql-jdbc-7.4.1.jre12-shaded

我的配置文件

input {
jdbc {
jdbc_driver_library => "C:\Users\Mohan\Downloads\MsoftDriver\sqljdbc_7.4\enu\mssql-jdbc-7.4.1.jre12-shaded.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://DESKTOP-VHDBS6E\SQLEXPRESS:1433;databaseName=mohan;"
jdbc_user => "mohan"
jdbc_password => "mohan"
statement => "SELECT * FROM [User_Name]"
start_position=> "beginning"
}
}
filter {
}

output {
elasticsearch {
hosts => "http://localhost:9200"

index => "Employee"

}
stdout { codec => rubydebug }
}

低于错误

 Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Something is wrong with your configuration.", :backtrace=>["C:/Users/Mohan/Desktop/EsearchKibana/logstash-7.2.0/logstash-core/lib/logstash/config/mixin.rb:87:in `config_init'", "C:/Users/Mohan/Desktop/EsearchKibana/logstash-7.2.0/logstash-core/lib/logstash/inputs/base.rb:60:in `initialize'", "org/logstash/plugins/PluginFactoryExt.java:258:in `plugin'", "org/logstash/plugins/PluginFactoryExt.java:120:in `buildInput'", "org/logstash/execution/JavaBasePipelineExt.java:50:in `initialize'", "C:/Users/Mohan/Desktop/EsearchKibana/logstash-7.2.0/logstash-core/lib/logstash/java_pipeline.rb:24:in `initialize'", "C:/Users/Mohan/Desktop/EsearchKibana/logstash-7.2.0/logstash-core/lib/logstash/pipeline_action/create.rb:36:in `execute'", "C:/Users/Mohan/Desktop/EsearchKibana/logstash-7.2.0/logstash-core/lib/logstash/agent.rb:325:in `block in converge_state'"]}

谁能帮我解决这个问题?

【问题讨论】:

    标签: elasticsearch logstash-configuration logstash-jdbc


    【解决方案1】:

    错误是由于 start_position=> “开始”。请评论并尝试一次。

    【讨论】:

      【解决方案2】:

      嗯,jdbc-input 插件没有这样的设置“start_position”。 Logstash 无法识别此设置,因此失败。看看doc - 你不会在那里找到它。

      另外,请注意,Java 9 及更高版本的 jdbc-input-plugin 中存在错误(我猜这将是您的配置的下一个问题)。所以请参考这个github issue和这个workaround,当logstash因为无法加载jdbc驱动而失败时。

      【讨论】:

      • 您好,我会试试这个,但我需要澄清一下,我使用的是 SQL Server 2014 Express Edition,我的 Java 版本是 13。对于这个设置,我的 JDBC 驱动程序应该是什么。任何想法?我的 JDBC 驱动程序也遇到了问题
      • 嗨。我在回答中发布了两个指向该问题的链接。
      • 我已经看到尝试相同的方式让您发布
      • 我建议您针对该特定问题提出一个新问题,因为该问题似乎已解决。
      【解决方案3】:

      您好,以上所有问题都为我解决了,我希望这是由于错误的 JDBC 驱动程序造成的。我直接从下面的链接而不是 Microsoft 下载了 JDBC 客户端,并将文件放在

      \logstash-7.2.0\logstash-core\lib\jars

      https://www.elastic.co/downloads/past-releases/jdbc-client-7-2-0

      注意:我的logstash版本是7.2.0

      logstash 配置适用于增量索引方法

      input {
      jdbc {
      jdbc_driver_library => ""
      jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
      jdbc_connection_string => "jdbc:sqlserver://DESKTOP-VHDBS6E\SQLEXPRESS:1433;databaseName=xxxxx;"
      jdbc_user => "xxxxx"
      jdbc_password => ""xxxx
      jdbc_paging_enabled => true
      tracking_column => modified_date
      use_column_value => true
      clean_run => true
      tracking_column_type => "timestamp"
      schedule => "*/2 * * * * *"
      statement => "SELECT * from [User_Name] where modified_date >:sql_last_value"
      }
      }
      
      filter {
       mutate {
         remove_field => ["@version","@timestamp"]
       }
      }
      
      output {
      elasticsearch {
      hosts => "http://localhost:9200"
      index => "employee"
      document_type => "_doc"
      document_id => "%{id}"
      
      }
      stdout { codec => rubydebug }
      }
      

      我希望这篇文章对那些尝试使用 logstash 处理 Elasticsearch 的增量索引的人有所帮助

      【讨论】:

        猜你喜欢
        • 2021-05-12
        • 1970-01-01
        • 1970-01-01
        • 2015-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多