# Why won't my Shards Assign?!

**URL:** https://discuss.elastic.co/t/why-wont-my-shards-assign/158033
**Category:** Elasticsearch
**Created:** [November 23, 2018, 3:16pm UTC](https://discuss.elastic.co/t/why-wont-my-shards-assign/158033 "2018-11-23T15:16:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![MultiplierMultiplier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/multipliermultiplier/32/25063_2.png) [@MultiplierMultiplier](https://discuss.elastic.co/u/MultiplierMultiplier)
#### Post date: [November 23, 2018, 3:16pm UTC](https://discuss.elastic.co/t/why-wont-my-shards-assign/158033/1 "2018-11-23T15:16:04Z")

</div>

I have a cluster with two Graylog nodes and three elasticsearch nodes. I have 4 primaries and 1 replica per index.

I have recently been testing resillience by running 'service elasticsearch stop' to stop one of the ES nodes, when I check unassigned shards using: `curl -s 'http://localhost:9200/_cat/shards?pretty' | grep UNASSIGNED` it returns a third of the shards being unassigned.

I chose one at random and ran the curl command:

> [http://localhost:9200/\_cluster/allocation/explain?include\_yes\_decisions=true](http://localhost:9200/_cluster/allocation/explain?include_yes_decisions=true)' -d '{  
> "index": "graylog\_0",  
> "shard": 3,  
> "primary": true  
> }'

I got the following errors:

> ```
> "index": "graylog_0",
> "shard": 3,
> "primary": true
> }'
> {
> "index" : "graylog_0",
> "shard" : 3,
> "primary" : true,
> "current_state" : "unassigned",
> "unassigned_info" : {
> "reason" : "NODE_LEFT",
> "at" : "2018-11-23T13:52:36.979Z",
> "details" : "node_left[x9ohTd5uRyyK9kHhzIlIzg]",
> "last_allocation_status" : "no_valid_shard_copy"
> },
> "can_allocate" : "no_valid_shard_copy",
> "allocate_explanation" : "cannot allocate because a previous copy of the primary shard existed but can no longer be found on the nodes in the cluster",
> "node_allocation_decisions" : [
> {
> "node_id" : "D3wazOlhQ3-C36kepICG7w",
> "node_name" : "es-1",
> "transport_address" : "10.19.0.6:9300",
> "node_decision" : "no",
> "store" : {
> "found" : false
> }
> },
> {
> "node_id" : "LUbM7G9RQL2L-lGxfO7SIQ",
> "node_name" : "es-2",
> "transport_address" : "10.19.0.8:9300",
> "node_decision" : "no",
> "store" : {
> "found" : false
> }
> }
> ]
> }
> 
> ```

Surely if a node leaves, the primary shards are moved onto another node or the replica of the said shard is made primary?

Any ideas?

Cheers,

G

---

<div class="post-metadata">

### Author: ![MultiplierMultiplier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/multipliermultiplier/32/25063_2.png) [@MultiplierMultiplier](https://discuss.elastic.co/u/MultiplierMultiplier)
#### Post date: [November 23, 2018, 4:23pm UTC](https://discuss.elastic.co/t/why-wont-my-shards-assign/158033/2 "2018-11-23T16:23:22Z")

</div>

I found the issue. Half of the indices were created without replicas and half with, so when one node goes offline it takes down some shards that have no replicas, therefore the data doesn't exist in the cluster anymore.

Does anyone know how to reindex all indices?

Cheers,

G

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [November 23, 2018, 4:35pm UTC](https://discuss.elastic.co/t/why-wont-my-shards-assign/158033/3 "2018-11-23T16:35:49Z")

</div>

> [@MultiplierMultiplier](#):
>
> Does anyone know how to reindex all indices?

If this is to solve the problem of having indices with no replicas, you can simply set the number of replicas to 1 on those indices, no need to reindex anything. To set every index to have one replica:

```auto
PUT /_settings
{
  "number_of_replicas": 1
}

```

To just apply it to a specific index, `indexname`,

```auto
PUT /indexname/_settings
{
  "number_of_replicas": 1
}

```

---

<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: [December 21, 2018, 4:35pm UTC](https://discuss.elastic.co/t/why-wont-my-shards-assign/158033/4 "2018-12-21T16:35:53Z")

</div>

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