# Permanent way of making ES Replicas = 0

**URL:** https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206
**Category:** Elasticsearch
**Created:** [August 17, 2016, 2:25am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206 "2016-08-17T02:25:58Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![jamesl](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jamesl](https://discuss.elastic.co/u/jamesl)
#### Post date: [August 17, 2016, 2:25am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/1 "2016-08-17T02:25:58Z")

</div>

Hello.  
I know that by issuing this command on my ES node it will set all current replicas to 0 but how about if I want to make it persistent so all of them are 0 from now on..

curl -XPUT 'localhost:9200/\_settings' -d '  
{ "index" : { "number\_of\_replicas" : 0 } }'

Thanks.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 17, 2016, 3:30am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/2 "2016-08-17T03:30:15Z")

</div>

Create a priority 1 template applying to `*` indices.

---

<div class="post-metadata">

### Author: ![jamesl](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jamesl](https://discuss.elastic.co/u/jamesl)
#### Post date: [August 17, 2016, 4:08am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/3 "2016-08-17T04:08:57Z")

</div>

Something like this ?

curl -XPUT 'localhost:9200/\_template/priority1' -d '  
{  
"template" : "\*",  
"settings" : {"number\_of\_replicas" : 0 }  
} '

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 17, 2016, 4:13am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/4 "2016-08-17T04:13:58Z")

</div>

Yep, that's the idea! I'd rename it from `priority1` though, make it more explanatory (eg `defaultzeroreplicas`).

---

<div class="post-metadata">

### Author: ![jamesl](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jamesl](https://discuss.elastic.co/u/jamesl)
#### Post date: [August 18, 2016, 12:22am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/5 "2016-08-18T00:22:46Z")

</div>

So, his is what I ran and watched system create a new indices and it was made with zero replica.

curl -XPUT localhost:9200/\_template/zeroreplicas -d '  
{  
"template" : "\*",  
"settings" : {  
"number\_of\_replicas" : 0  
}  
}'

[root@host ~]# curl -XGET localhost:9200/\_template/zeroreplicas?pretty  
{  
"template\_1" : {  
"order" : 0,  
"template" : "\*",  
"settings" : {  
"index" : {  
"number\_of\_replicas" : "0"  
}  
},  
"mappings" : { },  
"aliases" : { }  
}  
}  
[root@host ~]#

So all good I think...

I did notice that I have 2 other templates in the system called .marvel-es-1 and .marvel-es-data-1 which they have "number\_of\_replicas": "1"  
I shouldn't worry about that because my new default template will take precedence?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 18, 2016, 1:29am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/6 "2016-08-18T01:29:02Z")

</div>

Depends on the priority, but it hsould.

---

<div class="post-metadata">

### Author: ![jamesl](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jamesl](https://discuss.elastic.co/u/jamesl)
#### Post date: [August 18, 2016, 1:45am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/7 "2016-08-18T01:45:03Z")

</div>

Ok, will watch the system at 10am tomorrow when it creates the new indices and will see if .Marvel makes a replica of 1 or 0.. If 0 then I'm all good 🙂

Will let you know..

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 18, 2016, 1:49am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/8 "2016-08-18T01:49:01Z")

</div>

You can check the priority of the marvel template, just `GET _mapping`.

---

<div class="post-metadata">

### Author: ![jamesl](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jamesl](https://discuss.elastic.co/u/jamesl)
#### Post date: [August 18, 2016, 5:24am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/9 "2016-08-18T05:24:25Z")

</div>

Tried that only got an output of all my mappings.. Nothing regarding priorities?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 18, 2016, 5:32am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/10 "2016-08-18T05:32:54Z")

</div>

Doh, I meant `_template`. Sorry!

---

<div class="post-metadata">

### Author: ![jamesl](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jamesl](https://discuss.elastic.co/u/jamesl)
#### Post date: [August 18, 2016, 5:56am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/11 "2016-08-18T05:56:57Z")

</div>

No worries.  
pls see attached.  
Both my marvel templates are also priority 0 ?

[http://pastebin.com/QW4wdAfJ](http://pastebin.com/QW4wdAfJ)

strange.

---

<div class="post-metadata">

### Author: ![jamesl](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jamesl](https://discuss.elastic.co/u/jamesl)
#### Post date: [August 20, 2016, 1:14am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/12 "2016-08-20T01:14:33Z")

</div>

ES created new indices this morning with all of them as replicas = 0 .. good but my .marvel-es-1-2016.08.20 was created with a second replica and has one of them assigned to unassigned (because I only have 1 ES node in my Dev box).

Can I update an existing template but only change 1 setting?..  
I think this one needs changing:  
.marvel-es-1  
.marvel-es-1-\*  
"number\_of\_replicas": "1"

---

<div class="post-metadata">

### Author: ![Josh\_Harrison](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@Josh\_Harrison](https://discuss.elastic.co/u/Josh_Harrison)
#### Post date: [August 20, 2016, 3:27am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/13 "2016-08-20T03:27:27Z")

</div>

Based on [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html#multiple-templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html#multiple-templates) - it would suggest that if you put together a zeroreplicas template that looked like  
`{"template":"*", "order":1, "settings":{"number_of_replicas":0}}`  
You would be placing the zeroreplicas template at a higher priority than the marvel templates (which are at order 0), and thus override any conflicting settings in lower priority templates.

---

<div class="post-metadata">

### Author: ![jamesl](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jamesl](https://discuss.elastic.co/u/jamesl)
#### Post date: [August 20, 2016, 8:55am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/14 "2016-08-20T08:55:09Z")

</div>

Hi Josh.  
I created a zeroreplicas template the other day and that seems to have fixed all my other indices so they get created with no replicas except for the marvel ones (maybe becuase they have a specific tempalte?)... Please see a couple of threads up which is an extract of my templates in pastebin.

---

<div class="post-metadata">

### Author: ![Josh\_Harrison](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@Josh\_Harrison](https://discuss.elastic.co/u/Josh_Harrison)
#### Post date: [August 20, 2016, 1:55pm UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/15 "2016-08-20T13:55:53Z")

</div>

Yep, key difference in my suggestion vs what you had posted is that yours didn't specify the "order" parameter, so it used the default value of 0. If you explicitly set it to 1, you should override the replica parameter in the marvel template and set it to 0.

---

<div class="post-metadata">

### Author: ![jamesl](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jamesl](https://discuss.elastic.co/u/jamesl)
#### Post date: [August 21, 2016, 12:31am UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/16 "2016-08-21T00:31:49Z")

</div>

Done. So fingers crossed tomorrow when the marvel creates its new daily indices, there won't be any unassigned? 🙂

curl [http://localhost:9200/\_template/zeroreplicas?pretty](http://localhost:9200/_template/zeroreplicas?pretty)  
{  
"zeroreplicas" : {  
"order" : 1,  
"template" : "\*",  
"settings" : {  
"index" : {  
"number\_of\_replicas" : "0"  
}  
},  
"mappings" : { },  
"aliases" : { }  
}  
}

---

<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 5, 2017, 10:26pm UTC](https://discuss.elastic.co/t/permanent-way-of-making-es-replicas-0/58206/17 "2017-07-05T22:26:24Z")

</div>


