Logstash SQL Server数据导入

Viv*_*pta 10 logstash logstash-configuration

input {
  jdbc {
    jdbc_driver_library => "sqljdbc4.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://192.168.2.126\\SQLEXPRESS2014:1433;databaseName=test
	jdbc_password => "sa@sa2015"
    schedule => "0 0-59 0-23 * * *"
    statement => "SELECT ID , Name, City, State,ShopName FROM dbo.Shops"
	jdbc_paging_enabled => "true"
    jdbc_page_size => "50000"
  }
}
filter {
}
output {
  stdout { codec => rubydebug }
    elasticsearch { 
        protocol => "http"
		index => "shops"
		document_id => "%{id}"
    }
}
Run Code Online (Sandbox Code Playgroud)

我想使用JDBC SQL Server作为输入使用Logstash导入ElasticSearch中的数据,但我得到的错误类路径不正确.

任何人都知道如何使用Logstash连接sqljdbc FILE WITH CONFIG FILE的正确位置

小智 19

我认为"sqljdbc4.jar"文件的路径不正确.这是我用来查询从sql db到elasticsearch(logstash.conf)的数据的配置:

input {
  jdbc {
    jdbc_driver_library => "D:\temp\sqljdbc\sqljdbc_4.2\enu\sqljdbc42.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://DBSVR_NAME;user=****;password=****;"
    jdbc_user => "****"
    jdbc_password => "****"
    statement => "SELECT *
FROM [DB].[SCHEMA].[TABLE]"
  }
}
filter {
}
output {
  elasticsearch {
    hosts => "localhost"
    index => "INDEX_NAME"
    document_type => "DOCUMENT_TYPE"
    document_id => "%{id}"
    protocol => "http"
  }
  stdout { codec => rubydebug }
}
Run Code Online (Sandbox Code Playgroud)

我从这里下载了用于SQL Server的Microsoft JDBC驱动程序:" https://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx "

将文件提取到"jdbc_driver_library"中指定的路径

然后我运行了插件命令:"plugin install logstash-input-jdbc"来安装logstash输入jdbc插件.

最后运行logstash:"logstash -f logstash.conf".

暂且不说:我也在.Net服务应用程序中使用Elasticsearch.Net刷新数据" http://nest.azurewebsites.net/ "

这个视频:"将Elasticsearch添加到现有的.NET/SQL Server应用程序"" https://www.youtube.com/watch?v=sv-MflnT9qI "讨论使用Service Broker队列从sql中获取数据.我们目前正在探索这个选项.

编辑 - 更新主机的主机,如文档中所述https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-hosts