elasticsearch

How to move shards around in a cluster


I have a 5 node cluster with 5 indices and 5 shards for each index. Currently the shards of each index are evenly distributed accross the nodes. I need to move shards belonging to 2 different indices from a specific node to a different node on the same cluster


Solution

  • You can use the shard reroute API A sample command looks like below -

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

    This moves shard 0 of index test from node1 to node2