# Shard reroute and exchange Primary and Replica on a node

**URL:** <https://discuss.elastic.co/t/shard-reroute-and-exchange-primary-and-replica-on-a-node/312514>\
**Category:** Elasticsearch\
**Created:** [August 20, 2022, 10:19am UTC](https://discuss.elastic.co/t/shard-reroute-and-exchange-primary-and-replica-on-a-node/312514 "2022-08-20T10:19:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Farid\_N](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/farid_n/32/74144_2.png) [@Farid\_N](https://discuss.elastic.co/u/Farid_N)\
**Post date:** [August 20, 2022, 10:19am UTC](https://discuss.elastic.co/t/shard-reroute-and-exchange-primary-and-replica-on-a-node/312514/1 "2022-08-20T10:19:39Z")

</div>

Hi dears

I have a cluster with 2 nodes. one of them is master and another is replica  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/2/b2f85a1d5b82ffd6cf7184345b1f74c8f2757323.png)

Bellow is all shards in `monitor-node-01` :

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/9/9927eebd8570bb4a80820a187a44dc4a9afec99d.png)

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

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/e/de424c600b8b6fb8a340034c83e09f2ce83a87f9.png)

(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](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html)

```auto
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:

```auto
{
  "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

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [August 20, 2022, 10:45am UTC](https://discuss.elastic.co/t/shard-reroute-and-exchange-primary-and-replica-on-a-node/312514/2 "2022-08-20T10:45:30Z")

</div>

> [@Farid\_N](#):
>
> 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` ?

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 17, 2022, 10:45am UTC](https://discuss.elastic.co/t/shard-reroute-and-exchange-primary-and-replica-on-a-node/312514/3 "2022-09-17T10:45:46Z")

</div>

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