1:فایل .bat با محتوای زیر میسازیم
logstash.bat -f jdbc-config.txt -l log_folder
2:محتوای فایل jdbc-config.txt:
input {
jdbc {
last_run_metadata_path => "C:\logstash-7.10.0\bin\cache\table1.txt"
jdbc_driver_library => "C:\logstash-7.10.0\bin\mysql-connector-java-5.1.49-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/database_name"
jdbc_user => "root"
jdbc_password => ""
statement => "SELECT * from table1 WHERE id > :sql_last_value ORDER BY id ASC LIMIT 10000"
schedule => "* * * * *"
use_column_value => true
tracking_column => "id"
type => "table1"
}
jdbc {
last_run_metadata_path => "C:\logstash-7.10.0\bin\cache\table2.txt"
jdbc_driver_library => "C:\logstash-7.10.0\bin\mysql-connector-java-5.1.49-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/database_name"
jdbc_user => "root"
jdbc_password => ""
statement => "SELECT * from table2 WHERE id > :sql_last_value ORDER BY id ASC LIMIT 10000"
schedule => "* * * * *"
use_column_value => true
tracking_column => "id"
type => "table2"
}
}
output{
elasticsearch {
hosts => ["localhost:9200"]
index => "%{type}"
document_id => "%{id}"
}
stdout { codec => rubydebug }
}
3:فولدر cache و log رو هم بسازین
4: فایل mysql-connector-java-5.1.49-bin.jar رو هم باید از لینک زیر دانلود کنید
https://jar-download.com/artifacts/mysql/mysql-connector-java/5.1.49/source-code