Here I am demonstrating the operation under Windows
First download logstash-5.6.1, directly to the official website to download
1. You need to create the following jdbc.conf and myes.sql two files
input {stdin {} jdbc {jdbc_driver_library="D:\jdbcconfig\sqljdbc4-4.0.jar"Jdbc_driver_class="Com.microsoft.sqlserver.jdbc.SQLServerDriver"jdbc_connection_string="jdbc:sqlserver://127.0.0.1:1433;databasename=abtest"Jdbc_user="SA"Jdbc_password="123456"# Schedule=Timeshare Month Year # Schedule= * A* * *//Would execute at 22:00 every daySchedule ="* * * * *"jdbc_paging_enabled=truejdbc_page_size= +Clean_run=falseUse_column_value=true
#设置查询条件的字段 Tracking_column=lastedittime Record_last_run=trueLast_run_metadata_path="D:\jdbcconfig\data\station_parameter.txt"
#设置列名小写 lowercase_column_names=trueStatement_filepath="/jdbcconfig/myes.sql"#索引的类型 Type="Test"}}filter {json {source="message"Remove_field= ["message"]}}output {elasticsearch {hosts= ["172.16.57.233:9200"] Action="Index"#索引 Index="Test"document_id="%{productid}"} stdout {#codec=Json_lines
#设置输出的格式 codec=Line {format="ProductID:%{[productid]} isdeleted:%{[isdeleted]} lastedittime:%{[lastedittime]}" } }}
It is important to note that the configured path is correct and no execution will error
Myes.sql is the SQL statement inside where you need to execute the query
SELECT *
From [Dbo].test
The first thing to do is start Elasticsearch,
Then execute the following command in the bin directory of the Logstash: Logstash-f jdbcconfig/jdbc.conf
The data will begin to sync ....
Synchronizing SQL Server data to Elasticsearch with LOGSTASH-INPUT-JDBC