Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable ElasticSeach re-balancing if one node is down

Imagine a case where I have

  • 3(AWS) Nodes
  • Index (lets call it friends) with 3 shards and 1 replica.

S1 (Index friends primary shard 1)

S2 (Index friends primary shard 2)

S3 (Index friends primary shard 3)

R1 (Replica of Shard 1)

R2 (Replica of Shard 2) R3 (Replica of Shard 3)

Lets say that Node1 has (S1 R2) and is the master

Node2 has (S2 R3)
Node3 has (S3 R1)

Now if due to connection failure Node 2 goes down.

Load balancing will happen and Node 1 will promote the replica (R2) as primary and new replica for (R2) will be created in Node3

Finally after load balancing it will be like

Node1 has (S1 S2, R3)
Node3 has (S3 R1, R2)

During this re balancing heavy IO operations happen and the Elastic search health will become red -> yellow then green.

My requirement is that if Node 2 is down the nodes must not re balance. I am OK if the results on query shows results from only shard S1 and S3. And when Node 2 is back again no re balancing should happen.

like image 326
Cyril Cherian Avatar asked Mar 25 '15 09:03

Cyril Cherian


1 Answers

You can accomplish this by disabling shard allocation.

curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.enable": "none"}}'

If you want to turn allocation back on:

curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.enable": "all"}}'
like image 186
Chris Heald Avatar answered Sep 17 '22 14:09

Chris Heald