How do I stop ES replication in my setup?

How do I stop ES replication in my setup?

Question:
ES is be default to replicate data being received for high availability. Though this makes sure that we have all the data available even if one of the analyser node goes down but it also slows down the overall indexing. In some places, we may want to stop this replication. To do this, what should we do?

Answer:
You can do this temporarily on a set of indices by directly setting “number_of_replicas” to zero using curl XPUT

vunet@demo:~$ curl -XPUT -H "Content-Type:application/json" localhost:9200/vunet-1-1-test-index-2021.06.15/_settings -d '{ "index": { "number_of_replicas" : 0 } }'

However if you want this to be permanent, please update the index template corresponding to the index. For example if the index template name is “vunet”

Copy the current template to a tmp file.

curl -s localhost:9200/_template/vunet?pretty > /tmp/123

Open the tmp file, remove the second line and the corresponding end braces “}” at the end of the file.

Within the index settings block set number_of_replicas to zero.

"settings" : {
"index" : {
"number_of_replicas" : "0",
"refresh_interval" : "30s"
}
},

The upload the template using

curl -XPUT -H "Content-Type:application/json" localhost:9200/_template/vunet -d@/tmp/123

 

Note: Please double check your uploaded template by doing an XGET as before.