要不要再翻翻文档呢?

es集群之间选择性数据迁移的方法有哪些

Elasticsearch | 作者 Chen Ziyan | 发布于2018年07月28日 | 阅读数:4463

现有有两个集群,需要将一个集群的数据中比如名字 like“张三”的人的数据迁移到另一个集群当中。用logstash可能实现吗?怎么实现?用java代码的话如何进行两个集群的数据交互?希望有大佬可以回答我的问题,谢谢!!
已邀请:

rochy - rochy_he

赞同来自:

1. 使用 reindex 的方式;
POST _reindex
{
"source": {
"remote": {
"host": "http://otherhost:9200",
"username": "user",
"password": "pass"
},
"index": "source",
"query": {
"match": {
"test": "data"
}
}
},
"dest": {
"index": "dest"
}
}

2. 使用 logstash;
input {
# Read all documents from Elasticsearch matching the given query
elasticsearch {
hosts => "localhost"
query => '{ "query": { "match": { "statuscode": 200 } }, "sort": [ "_doc" ] }'
}
}

3. 自己代码实现:建立两个集群的client,然后将一个集群的索引的数据使用 scroll的方式遍历出来,在使用bulk方式提交到另一个集群即可。

zqc0512 - andy zhou

赞同来自:

reindex snapshot
snapshot is better than reindex.

God_lockin

赞同来自:

如果对时效性之类的要求不高,单纯的想dump一份数据出来的话,我觉得你可以:
1. A集群(原集群)下线
2. 找到A集群的data目录
3. 把里面的数据全部拷贝到B集群(目标集群)
4. 把B集群启动起来让他自动扫数据做重分片
 

要回复问题请先登录注册