1、认识es自带的工具API
reindex
reindex是Elasticsearch提供的一个api接口,可以把数据从源ES集群导入到当前的ES集群,同样实现了数据的迁移
2、配置参数
设置白名单
如果是A集群 --> B集群,就需要在B中的elasticsearch.yml 设置A地址为白名单
在目标集群(B集群 116)的elasticsearch.yml配置文件,设置远程集群的白名单,添加如下配置:
# reindex.remote.whitelist: A的IP:端口,例如:(注意yml文件空格)
reindex.remote.whitelist: 172.16.1.236:9200
3、编写数据迁移规则
POST http://172.16.1.116:9201/_reindex
{
"source": {
"index": "topic",
"remote": {
"host": "http://172.16.1.236:9200",
"username": "username",
"password": "password"
},
"query": {
"match_all": {}
}
},
"dest": {
"index": "topic-new"
}
}
4、注意事项
对mapping有要求的,提前创建好索引,再执行数据迁移。
1、get /索引名称 获取索引
2、put /索引名称 + mapping信息。创建索引
5、参考资料
这个帖子写的很好,很好
https://blog.csdn.net/qq_21383435/article/details/108953326