【发布时间】:2017-03-14 21:07:38
【问题描述】:
我不太清楚sql_last_value 在我这样发表声明时做了什么:
statement => "SELECT * from mytable where id > :sql_last_value"
我可以稍微理解使用它的原因,它不会浏览整个数据库表以更新字段,而是只更新新添加的记录。如果我错了,请纠正我。
所以我想做的是,使用logstash 创建索引:
input {
jdbc {
jdbc_connection_string => "jdbc:mysql://hostmachine:3306/db"
jdbc_user => "root"
jdbc_password => "root"
jdbc_validate_connection => true
jdbc_driver_library => "/path/mysql_jar/mysql-connector-java-5.1.39-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
schedule => "* * * * *"
statement => "SELECT * from mytable where id > :sql_last_value"
use_column_value => true
tracking_column => id
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
}
}
output {
elasticsearch {
#protocol => http
index => "myindex"
document_type => "message_logs"
document_id => "%{id}"
action => index
hosts => ["http://myhostmachine:9402"]
}
}
一旦我这样做了,文档就根本不会上传到索引中。我哪里错了?
任何帮助都将不胜感激。
【问题讨论】:
-
您的表中是否有一个时间戳列在每次记录更新时都会更新?
-
@Val nop 我不知道。我必须有一个才能更新每条记录吗?
-
这样更容易获取最新更新的记录。更新记录时,id 不会更改,您可能无法获取更新记录。
-
在您的主文件夹中,您可以尝试删除
.logstash_jdbc_last_run文件,看看是否效果更好。 -
我将尝试使用时间戳值并返回。你的意思是
logstash的主文件夹?
标签: elasticsearch jdbc logstash logstash-configuration elasticsearch-5