4
votes

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

1
Can you elaborate a bit on why you want to do this? One of the given answers can do the job. But the cluster can rebalance the shards when it wants to. Maybe you have a server on another rack or you have fast and slow servers, other hard disks. Solutions for these scenarios differ. - Jettro Coenradie
I was looking for the relocating api. Thanks - Jalal

1 Answers

6
votes

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