# Shard recovery with only one node in the cluster

**URL:** https://discuss.elastic.co/t/shard-recovery-with-only-one-node-in-the-cluster/9124
**Category:** Elasticsearch
**Created:** [September 24, 2012, 8:26pm UTC](https://discuss.elastic.co/t/shard-recovery-with-only-one-node-in-the-cluster/9124 "2012-09-24T20:26:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![f\_shantanu](https://avatars.discourse-cdn.com/v4/letter/f/e480ec/32.png) [@f\_shantanu](https://discuss.elastic.co/u/f_shantanu)
#### Post date: [September 24, 2012, 8:26pm UTC](https://discuss.elastic.co/t/shard-recovery-with-only-one-node-in-the-cluster/9124/1 "2012-09-24T20:26:29Z")

</div>

I have an elastic search cluster with 3 data nodes. I have set up the  
indices to have 5 shards and 2 replicas/shard. I have noticed that if I  
shut down the cluster and start just one node then the shards remain  
unallocated. The shards get allocated when I start up all the other nodes  
in the cluster. Is there any thing I can do so that atleast all the primary  
shards are allocated even if there is just one node in the cluster? Note  
the indices are recovered but not allocated, i.e. the cluster health is red.

--

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [September 25, 2012, 9:50am UTC](https://discuss.elastic.co/t/shard-recovery-with-only-one-node-in-the-cluster/9124/2 "2012-09-25T09:50:11Z")

</div>

On Mon, 2012-09-24 at 13:26 -0700, Shantanu wrote:

> I have an Elasticsearch cluster with 3 data nodes. I have set up the  
> indices to have 5 shards and 2 replicas/shard. I have noticed that if  
> I shut down the cluster and start just one node then the shards remain  
> unallocated. The shards get allocated when I start up all the other  
> nodes in the cluster. Is there any thing I can do so that atleast all  
> the primary shards are allocated even if there is just one node in the  
> cluster? Note the indices are recovered but not allocated, i.e. the  
> cluster health is red.

Change the number of replicas to 2. That will ensure that each of your  
nodes has a copy of all of the data.

Alternatively, start all 3 nodes, then shut down 1 and wait for the  
cluster to return to 'green'. Then you can shut down a second node, and  
the remaining node will have all the data (although cluster health will  
be yellow, because it is missing a replica)

clint

> --

--

---

<div class="post-metadata">

### Author: ![f\_shantanu](https://avatars.discourse-cdn.com/v4/letter/f/e480ec/32.png) [@f\_shantanu](https://discuss.elastic.co/u/f_shantanu)
#### Post date: [September 26, 2012, 2:28pm UTC](https://discuss.elastic.co/t/shard-recovery-with-only-one-node-in-the-cluster/9124/3 "2012-09-26T14:28:13Z")

</div>

I already have the number of replicas set to 2. When I start up all the  
nodes and shut them one by one then indexing and searching works fine with  
just one node in the cluster (I have set the write consistency to 1).  
However we have use cases where we need to start up just one node.

As I mentioned in my original post, when I start up one node, the primary  
shards are not allocated until there are atleast 2 nodes in the cluster.  
This behavior is some how associated with the with the number of replicas.  
When I reduce the number of replicas to 1 then the primary shards are  
allocated as soon as the first node comes up. I could not find any  
documentation explaining why this happens. Is there any way of getting  
around this w/o changing the number of replicas?

On Tuesday, September 25, 2012 5:50:27 AM UTC-4, Clinton Gormley wrote:

> On Mon, 2012-09-24 at 13:26 -0700, Shantanu wrote:
> 
> > I have an Elasticsearch cluster with 3 data nodes. I have set up the  
> > indices to have 5 shards and 2 replicas/shard. I have noticed that if  
> > I shut down the cluster and start just one node then the shards remain  
> > unallocated. The shards get allocated when I start up all the other  
> > nodes in the cluster. Is there any thing I can do so that atleast all  
> > the primary shards are allocated even if there is just one node in the  
> > cluster? Note the indices are recovered but not allocated, i.e. the  
> > cluster health is red.
> 
> Change the number of replicas to 2. That will ensure that each of your  
> nodes has a copy of all of the data.
> 
> Alternatively, start all 3 nodes, then shut down 1 and wait for the  
> cluster to return to 'green'. Then you can shut down a second node, and  
> the remaining node will have all the data (although cluster health will  
> be yellow, because it is missing a replica)
> 
> clint
> 
> > --

--

---

<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: [July 6, 2017, 3:11am UTC](https://discuss.elastic.co/t/shard-recovery-with-only-one-node-in-the-cluster/9124/4 "2017-07-06T03:11:17Z")

</div>


