1,logstash-7.15.1\bin 目录下建文件 logstash.conf
input {
jdbc {
jdbc_connection_string => "jdbc:mysql://localhost:3306/o2d"
jdbc_user => "root"
jdbc_password => "root"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_driver_library => "E:\es\logstash-7.15.1\mysql\mysql-connector-java-8.0.28.jar"
statement => "SELECT id,street_name,street_number,mls_number,pic,city,listing_price FROM listing "
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "listing"
document_id => "%{id}"
}
}
2,cmd 运行
logstash -f E:\es\logstash-7.15.1\bin\logstash.conf
注意 mysql的字段需要与索引库一致