# Confusing replica count setting

**URL:** https://discuss.elastic.co/t/confusing-replica-count-setting/3384
**Category:** Elasticsearch
**Created:** [September 29, 2010, 7:24am UTC](https://discuss.elastic.co/t/confusing-replica-count-setting/3384 "2010-09-29T07:24:34Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Ask\_Bjorn\_Hansen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ask_bjorn_hansen/32/2995_2.png) [@Ask\_Bjorn\_Hansen](https://discuss.elastic.co/u/Ask_Bjorn_Hansen)
#### Post date: [September 29, 2010, 7:24am UTC](https://discuss.elastic.co/t/confusing-replica-count-setting/3384/1 "2010-09-29T07:24:34Z")

</div>

Hi everyone,

I am running 0.11.0.

I have a two node cluster (for testing and not much data). I wanted  
to make sure that the data is on both nodes so if one goes away, the  
system will continue running on the other.

I expected that I needed to set number\_of\_replicas to 2, but that  
seems to actually make the system want to make _3_ copies of the data,  
is that right?

Vaguely related question:

What'd be the right setting for gateway.recover\_after\_nodes in a 2  
node cluster?

- ask

curl -XPUT '[http://x17.dev:9200/jobso/\_settings](http://x17.dev:9200/jobso/_settings)' -d '{ "index" :  
{ "number\_of\_replicas": 1 } }'; echo  
{"ok":true}

$ curl -XGET '[http://x17.dev:9200/\_cluster/health?pretty=true](http://x17.dev:9200/_cluster/health?pretty=true)'  
{  
"status" : "green",  
"timed\_out" : false,  
"number\_of\_nodes" : 2,  
"active\_primary\_shards" : 5,  
"active\_shards" : 10,  
"relocating\_shards" : 0,  
"initializing\_shards" : 0,  
"unassigned\_shards" : 0  
}

$ curl -PUET 'http://x17.dev:9200jobso/\_settings' -d '{ "index" :  
{ "number\_of\_replicas": 2 } }'; echo  
{"ok":true}

$ curl -XGET '[http://x17.dev:9200/\_cluster/health?pretty=true](http://x17.dev:9200/_cluster/health?pretty=true)'  
{  
"status" : "yellow",  
"timed\_out" : false,  
"number\_of\_nodes" : 2,  
"active\_primary\_shards" : 5,  
"active\_shards" : 10,  
"relocating\_shards" : 0,  
"initializing\_shards" : 0,  
"unassigned\_shards" : 5

---

<div class="post-metadata">

### Author: ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)
#### Post date: [September 29, 2010, 7:58am UTC](https://discuss.elastic.co/t/confusing-replica-count-setting/3384/2 "2010-09-29T07:58:03Z")

</div>

Hi,

On Wed, Sep 29, 2010 at 9:24 AM, Ask Bjørn Hansen [ask@develooper.com](mailto:ask@develooper.com)wrote:

> Hi everyone,
> 
> I am running 0.11.0.
> 
> I have a two node cluster (for testing and not much data). I wanted  
> to make sure that the data is on both nodes so if one goes away, the  
> system will continue running on the other.
> 
> I expected that I needed to set number\_of\_replicas to 2, but that  
> seems to actually make the system want to make _3_ copies of the data,  
> is that right?

If number\_or\_replicas is set to 1 then it means that for each shard there  
can be allocated one other replica in the cluster (if node available, ES  
will not allocate shard and its replica to the same node).

> Vaguely related question:
> 
> What'd be the right setting for gateway.recover\_after\_nodes in a 2  
> node cluster?

I found the following thread in mail list:  
[http://elasticsearch-users.115913.n3.nabble.com/gateway-recover-after-nodes-question-tp1480972.html](http://elasticsearch-users.115913.n3.nabble.com/gateway-recover-after-nodes-question-tp1480972.html)  
Is it helpful?

> - ask
> 
> curl -XPUT '[http://x17.dev:9200/jobso/\_settings](http://x17.dev:9200/jobso/_settings)' -d '{ "index" :  
> { "number\_of\_replicas": 1 } }'; echo  
> {"ok":true}
> 
> $ curl -XGET '[http://x17.dev:9200/\_cluster/health?pretty=true](http://x17.dev:9200/_cluster/health?pretty=true)'  
> {  
> "status" : "green",  
> "timed\_out" : false,  
> "number\_of\_nodes" : 2,  
> "active\_primary\_shards" : 5,  
> "active\_shards" : 10,  
> "relocating\_shards" : 0,  
> "initializing\_shards" : 0,  
> "unassigned\_shards" : 0  
> }
> 
> $ curl -PUET 'http://x17.dev:9200jobso/\_settings' -d '{ "index" :  
> { "number\_of\_replicas": 2 } }'; echo  
> {"ok":true}
> 
> $ curl -XGET '[http://x17.dev:9200/\_cluster/health?pretty=true](http://x17.dev:9200/_cluster/health?pretty=true)'  
> {  
> "status" : "yellow",  
> "timed\_out" : false,  
> "number\_of\_nodes" : 2,  
> "active\_primary\_shards" : 5,  
> "active\_shards" : 10,  
> "relocating\_shards" : 0,  
> "initializing\_shards" : 0,  
> "unassigned\_shards" : 5

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [September 29, 2010, 9:27am UTC](https://discuss.elastic.co/t/confusing-replica-count-setting/3384/3 "2010-09-29T09:27:19Z")

</div>

Hey,

Lukas answered the question regarding the replicas, its basically the  
number of replicas for each shard. So a 2 shards with 1 replica will end up  
with total of 4 shards.

Regarding the recover\_after\_nodes, it only affect the system after a full  
cluster shutdown, so I would say set it to 2, since a full cluster shutdown  
will probably mean you are there to make sure two nodes start :).

-shay.banon

On Wed, Sep 29, 2010 at 9:58 AM, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:

> Hi,
> 
> On Wed, Sep 29, 2010 at 9:24 AM, Ask Bjørn Hansen [ask@develooper.com](mailto:ask@develooper.com)wrote:
> 
> > Hi everyone,
> > 
> > I am running 0.11.0.
> > 
> > I have a two node cluster (for testing and not much data). I wanted  
> > to make sure that the data is on both nodes so if one goes away, the  
> > system will continue running on the other.
> > 
> > I expected that I needed to set number\_of\_replicas to 2, but that  
> > seems to actually make the system want to make _3_ copies of the data,  
> > is that right?
> 
> If number\_or\_replicas is set to 1 then it means that for each shard there  
> can be allocated one other replica in the cluster (if node available, ES  
> will not allocate shard and its replica to the same node).
> 
> > Vaguely related question:
> > 
> > What'd be the right setting for gateway.recover\_after\_nodes in a 2  
> > node cluster?
> 
> I found the following thread in mail list:  
> [http://elasticsearch-users.115913.n3.nabble.com/gateway-recover-after-nodes-question-tp1480972.html](http://elasticsearch-users.115913.n3.nabble.com/gateway-recover-after-nodes-question-tp1480972.html)  
> Is it helpful?
> 
> > - ask
> > 
> > curl -XPUT '[http://x17.dev:9200/jobso/\_settings](http://x17.dev:9200/jobso/_settings)' -d '{ "index" :  
> > { "number\_of\_replicas": 1 } }'; echo  
> > {"ok":true}
> > 
> > $ curl -XGET '[http://x17.dev:9200/\_cluster/health?pretty=true](http://x17.dev:9200/_cluster/health?pretty=true)'  
> > {  
> > "status" : "green",  
> > "timed\_out" : false,  
> > "number\_of\_nodes" : 2,  
> > "active\_primary\_shards" : 5,  
> > "active\_shards" : 10,  
> > "relocating\_shards" : 0,  
> > "initializing\_shards" : 0,  
> > "unassigned\_shards" : 0  
> > }
> > 
> > $ curl -PUET 'http://x17.dev:9200jobso/\_settings' -d '{ "index" :  
> > { "number\_of\_replicas": 2 } }'; echo  
> > {"ok":true}
> > 
> > $ curl -XGET '[http://x17.dev:9200/\_cluster/health?pretty=true](http://x17.dev:9200/_cluster/health?pretty=true)'  
> > {  
> > "status" : "yellow",  
> > "timed\_out" : false,  
> > "number\_of\_nodes" : 2,  
> > "active\_primary\_shards" : 5,  
> > "active\_shards" : 10,  
> > "relocating\_shards" : 0,  
> > "initializing\_shards" : 0,  
> > "unassigned\_shards" : 5

---

<div class="post-metadata">

### Author: ![Ask\_Bjorn\_Hansen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ask_bjorn_hansen/32/2995_2.png) [@Ask\_Bjorn\_Hansen](https://discuss.elastic.co/u/Ask_Bjorn_Hansen)
#### Post date: [September 30, 2010, 1:11am UTC](https://discuss.elastic.co/t/confusing-replica-count-setting/3384/4 "2010-09-30T01:11:41Z")

</div>

On Sep 29, 2:27 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Hey,
> 
> Lukas answered the question regarding the replicas, its basically the  
> number of replicas for each shard. So a 2 shards with 1 replica will end up  
> with total of 4 shards.

Yes, my confusion here is that "1 replica" means "one extra copy" –  
this makes perfect sense but was just not the terminology I was used  
to. For a small setup it's very nice that it automatically figures  
out to just spread out to two copies by default.

> Regarding the recover\_after\_nodes, it only affect the system after a full  
> cluster shutdown, so I would say set it to 2, since a full cluster shutdown  
> will probably mean you are there to make sure two nodes start :).

If after a full shutdown one node isn't coming back because of some  
hardware problem or similar, would that prevent the other node from  
starting up correctly?

- ask

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [September 30, 2010, 5:13am UTC](https://discuss.elastic.co/t/confusing-replica-count-setting/3384/5 "2010-09-30T05:13:41Z")

</div>

On Thu, Sep 30, 2010 at 3:11 AM, Ask Bjørn Hansen [ask@develooper.com](mailto:ask@develooper.com)wrote:

> On Sep 29, 2:27 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Hey,
> > 
> > Lukas answered the question regarding the replicas, its basically the  
> > number of replicas for each shard. So a 2 shards with 1 replica will end  
> > up  
> > with total of 4 shards.
> 
> Yes, my confusion here is that "1 replica" means "one extra copy" –  
> this makes perfect sense but was just not the terminology I was used  
> to. For a small setup it's very nice that it automatically figures  
> out to just spread out to two copies by default.
> 
> > Regarding the recover\_after\_nodes, it only affect the system after a  
> > full  
> > cluster shutdown, so I would say set it to 2, since a full cluster  
> > shutdown  
> > will probably mean you are there to make sure two nodes start :).
> 
> If after a full shutdown one node isn't coming back because of some  
> hardware problem or similar, would that prevent the other node from  
> starting up correctly?

Yes, the recovery process will not start up until the number of nodes is  
discovered, so if just 1 will be in the picture, then nothing will be  
recovered.

> - ask

---

<div class="post-metadata">

### Author: ![Ask\_Bjorn\_Hansen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ask_bjorn_hansen/32/2995_2.png) [@Ask\_Bjorn\_Hansen](https://discuss.elastic.co/u/Ask_Bjorn_Hansen)
#### Post date: [September 30, 2010, 8:46am UTC](https://discuss.elastic.co/t/confusing-replica-count-setting/3384/6 "2010-09-30T08:46:10Z")

</div>

On Sep 29, 10:13 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Yes, the recovery process will not start up until the number of nodes is  
> discovered, so if just 1 will be in the picture, then nothing will be  
> recovered.

For two node clusters it'd be useful with a setting for "wait X  
seconds for another node and start recovery then" -- or is there one  
already?

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [September 30, 2010, 10:42am UTC](https://discuss.elastic.co/t/confusing-replica-count-setting/3384/7 "2010-09-30T10:42:07Z")

</div>

There is something similar, there is gateway.recover\_after\_time that will  
also wait for that time to recover, but there isn't something that waits for  
2 or that amount of time given has passed. Which does make sense, want to  
add an issue for that (and a name for that setting 😉 ).

On Thu, Sep 30, 2010 at 10:46 AM, Ask Bjørn Hansen [ask@develooper.com](mailto:ask@develooper.com)wrote:

> On Sep 29, 10:13 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Yes, the recovery process will not start up until the number of nodes is  
> > discovered, so if just 1 will be in the picture, then nothing will be  
> > recovered.
> 
> For two node clusters it'd be useful with a setting for "wait X  
> seconds for another node and start recovery then" -- or is there one  
> already?

---

<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, 4:18am UTC](https://discuss.elastic.co/t/confusing-replica-count-setting/3384/8 "2017-07-06T04:18:40Z")

</div>


