Writing API update for setting number of replicas to 0

We are trying to eliminate replicas in our non-prod environment to save space and we do not need the replicas. we know this is counter to the fault tolerance but it is something we must do. I found this on the documentation but not sure where to invoke it because I am not an API guy _

curl -H "Content-Type: application/json" -XPUT localhost:9200/*/_settings -d '{ "index" : { "number_of_replicas" : 0 } }'

is this run the Kibana dev tools? also we need to use -

(Optional, Boolean) If true, existing index settings remain unchanged. Defaults to false. 

to preserve what is there - what does the entire command actually look like or is there a FILE where I can change the setting and restart services to accomplish this.

The below command in Dev Tools will set every index to 0.

PUT /_settings
  "index" : {
    "number_of_replicas" : 0
1 Like

I saw that but do you just put the preserve_existing in like this?


Sorry, I don't really understand preserve_existing or have used it.

From the documentation though it sounds like you want to keep this false. If you set as true then nothing at all will change.

Can you find out what the syntax is for the option since you are there at elastic. From what I understand the option is to KEEP the setting for the shards that already exist and any new shards would be created without replicas. Our Security team will also want to know the risk of having no replicas. what is the average fault rate for shards itself. We keep all data on an NFS partition so shards are all kept in the same place.

I tried this .

PUT /_settings
  "index" : {
    "number_of_replicas" : 0,
   "preserve_existing" : True

but received an error in the dev tools- I just need to know how to use options. Thanks for any help you can provide.

My recommendation, here, would be to use a template, rather than using preserve_existing since it gets you more in line with what you're after, if you want new indices to not have replicas.

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html has some explanations on how to do that, and you can have anything that's created under that pattern have the settings you specify. You'd want to set number_of_replicas to a numeric value like 0 for your use case.

Alternatively, you can alter the number of replicas by using ILM and tiering with hot/warm/cold etc.

While the shards themselves may not fail, though they can and do at times, you are more likely to lose a node and incur data loss, so it is not recommended, and I do hope you have snapshots in place and configured.

Also, NFS tends to be a poor choice due to the overhead from attribute hits, though it can be alleviated, to a degree, with some mount time settings, I would still steer away from it if you can.

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