Shard reroute and exchange Primary and Replica on a node

Hi dears

I have a cluster with 2 nodes. one of them is master and another is replica
image

Bellow is all shards in monitor-node-01 :

As you see, all of shards in this node is "Primary" and all "Replica" shards are on monitor-node-02 :

(metricbeat7-8-2 index has just 1 primary shard and 0 replica )

All I want to do is to reroute index metricbeat7-16-2 in a way that monitor-node-02 gets "Primary" and monitor-node-01 gets "Replica"

According to bellow page, I wrote the reroute command:
Cluster reroute API | Elasticsearch Guide [8.3] | Elastic

POST /_cluster/reroute
{
  "commands": [
    {
      "move": {
        "index": "metricbeat-7.16.2-*", "shard": 1,
        "from_node": "monitor-node-01", "to_node": "monitor-node-02"
      }
    },
    {
      "allocate_replica": {
        "index": "metricbeat-7.16.2-*", "shard": 1,
        "node": "monitor-node-01"
      }
    }
  ]
}

But unfortunately got this Error:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "[move_allocation] can't move 1, failed to find it on node {monitor-node-01}{K4hKbNEDQUqdSXmzMxreeA}{KW5a_x0DRHKQbAl_55itjQ}{ELK01-SOFT}{192.168.11.142:9300}{cdfhilmrstw}{ml.machine_memory=8343404544, xpack.installed=true, transform.node=true, ml.max_open_jobs=512, ml.max_jvm_size=3221225472}"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "[move_allocation] can't move 1, failed to find it on node {monitor-node-01}{K4hKbNEDQUqdSXmzMxreeA}{KW5a_x0DRHKQbAl_55itjQ}{ELK01-SOFT}{192.168.11.142:9300}{cdfhilmrstw}{ml.machine_memory=8343404544, xpack.installed=true, transform.node=true, ml.max_open_jobs=512, ml.max_jvm_size=3221225472}"
  },
  "status" : 400
}

How can I exchange these 2 shards? How can I define that index "Metricbeat" should have primary shard on monitoring-node-02 and replica on monitoring-node-01 ?

Thanks

This is something you can't control and will also vary over time of any nodes goes down or shards have issues. Primaries and replicas largely do the same work so you should not need to control this.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.