如何在集群中移动分片

How to move shards around in a cluster

我有一个 5 节点集群,其中有 5 个索引,每个索引有 5 个分片。目前每个索引的分片均匀分布在节点上。我需要将属于 2 个不同索引的分片从特定节点移动到同一集群上的不同节点

您可以使用 shard reroute API 示例命令如下所示 -

curl -XPOST 'localhost:9200/_cluster/reroute' -H 'Content-Type: application/json' -d '{
    "commands" : [ {
        "move" :
            {
              "index" : "test", "shard" : 0,
              "from_node" : "node1", "to_node" : "node2"
            }
        }
    ]
}'

这会将索引测试的分片 0 从节点 1 移动到节点 2