注意:jdbc.conf和jdbc.sql文件编码都为ANSI
jdbc.conf内容如下:
input { stdin { } jdbc { jdbc_connection_string => "jdbc:sqlserver://172.19.148.63:1433;databaseName=EB_Search" jdbc_user => "sa" jdbc_password => "123@abcd" jdbc_driver_library => "D:SoftwareELK5.5.0logstash-5.5.0inmssqlsqljdbc4-2.0.jar" jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver" statement_filepath => "D:SoftwareELK5.5.0logstash-5.5.0inmssqljdbc.sql" schedule => "* * * * *" } } output { elasticsearch { hosts => "10.0.10.143:9200" index => "sync_productinfo" } }
jdbc.sql内容如下:
SELECT TOP 1000 * FROM [ProductInfo] ORDER BY CreateTime DESC
启动命令:
cd D:SoftwareELK5.5.0logstash-5.5.0in .logstash.bat -f .mssqljdbc.conf