0
我在MySQL上有3個表。如何從mysql更新Elasticsearch數據?
並將數據索引到elasticsearch。
它的工作與下方。(logstash配置)
input {
jdbc {
jdbc_driver_library => "lib/mysql-connector-java-5.1.33.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/test"
jdbc_user => "test"
jdbc_password => "test"
statement => "SELECT * FROM TABLE1"
schedule => "* * * * *"
type => "table1"
}
//
// two more inputs
//
}
output {
stdout {codec => rubydebug}
if [type] == "table1" {
elasticsearch {
hosts => ["localhost:9200"]
index => "test"
document_type => "%{type}"
document_id => "%{id}"
template => "./template"
template_overwrite => true
}
}
//
// two more outputs
//
}
我刪除兩個其他的輸入和輸出,某些行從TABLE1上MySQL的。
並開始logstash。
它沒有更新。
所以,再次輸入,
curl -XDELETE 'http://localhost:9200/*'
和restared logstash。
但是在elasticsearch上再次添加了三個相同行的表。
如何自動更新elasticsearch數據?
Omg。我正在使用logstash版本2.1.1,它不支持use_column_value,tracking_column,tracking_column_type。有沒有其他的方法來解決2.1.1版本的這個問題? – USER
我已經更新了2.1.1到2.4.1。並添加了三行代碼。 use_column_value => true tracking_column =>「id」 lowercase_column_names => false。 它返回相同的值 – USER
我不確定它是否能夠在沒有** tracking_column_type =>「numeric」**的情況下工作,因爲我只用過它。在檢查是否有任何解決方法之後,我會盡快與您聯繫。 – Kulasangar