Reindex可用于Elasticsearch跨集群数据迁移,并且不会复制原索引的mapping(映射)、shard(分片)、replicas(副本)等配置信息。
1、仅在目标ES的elasticsearch.yml文件中添加如下配置
#reindex操作远程列表
reindex.remote.whitelist: ["192.168.101.101:9200"]
2、在目标集群执行如下命令(kibana执行)
POST _reindex?wait_for_completion=false
{
"conflicts": "proceed",#有异常时,继续执行
"source": {
"index": "test_index_db",#源索引
"size": 4000, #速度控制
"query": {
"bool": {
##查询条件
}
},
"_source": {
"excludes": ["字段1","字段2"] #排除字段
},
"remote": {
"host": "192.168.101.101:9200",
"socket_timeout": "1m",
"connect_timeout": "10s"
}
},
"dest": {
"index": "test_index_db",#目标索引
}
}
3、GET _tasks?detailed=true&actions=*reindex 查看任务执行情况
参考文章:
本文介绍了如何使用Elasticsearch的Reindex功能进行跨集群的数据迁移,该方法不会复制源索引的配置信息,如mapping、shard和replicas。主要步骤包括在目标集群的配置文件中添加远程列表,通过Kibana执行POST_reindex命令指定源索引、查询条件、排除字段和目标索引,并监控GET_tasks接口查看迁移任务的执行情况。


被折叠的 条评论
为什么被折叠?



