Permanent way of making ES Replicas = 0

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.

Create a priority 1 template applying to * indices.

Something like this ?

curl -XPUT 'localhost:9200/_template/priority1' -d '
{
"template" : "*",
"settings" : {"number_of_replicas" : 0 }
} '

1 Like

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

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?

Depends on the priority, but it hsould.

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 :slight_smile:

Will let you know..

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

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

Doh, I meant _template. Sorry!

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

http://pastebin.com/QW4wdAfJ

strange.

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"

Based on 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.

2 Likes

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.

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.

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

curl http://localhost:9200/_template/zeroreplicas?pretty
{
"zeroreplicas" : {
"order" : 1,
"template" : "*",
"settings" : {
"index" : {
"number_of_replicas" : "0"
}
},
"mappings" : { },
"aliases" : { }
}
}

1 Like