标签:
在上一篇中简略的说了一下es同步数据脚本的大致情况,但是实际情况里肯定不会像上一篇里面的脚本那么简单。比如目前我就有三张表,两张实体表,一张关联表。大致实现如下:
bin目录建立一个statefile.json文件:
{ "type" : "jdbc", "statefile" : "statefile.json", "jdbc": { "url" : "jdbc:mysql://", "user" : "", "password" : "", "type" : "actor", "index": "test", "schedule" : "0 * * * * ?", "metrics" : { "lastexecutionstart" : "0", "lastexecutionend" : "0", "counter" : "1" }, "sql" : [ { "statement" : "select a.actor_id as _id ,a.*,GROUP_CONCAT(b.tag_name ) as tag_name from ( ( gd_actor_info as a left join gd_actor_tag as ab on a.actor_id = ab.actor_id ) left join gd_tag_actor as b on ab.tag_id = b.tag_id) where a.update_time >? or ab.update_time > ? group by a.actor_id ", "parameter" : [ "$metrics.lastexecutionstart" ,"$metrics.lastexecutionstart" ] } ] } }
主要是lastexecutionstart设置为0,为了让第一次执行能进行一次全量备份。
其实sh脚本信息也就都在上面了,再写一个就好了
Elasticsearch mysql 增量同步 三表联合 脚本
标签:
原文地址:http://www.cnblogs.com/csonezp/p/5490206.html