Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticSearch: How to disable shard reallocation of all shards?

I developed a search plugin for elasticsearch, but when upgrading this plugin, i need to shutdown the nodes one by one, and each time i have to wait for the reallocation process a long time. In the document, it said the reallocation process can be stopped by:

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

When I run this command, i got following error:

ElasticsearchIllegalArgumentException[Can't update non dynamic settings[[index.transient.cluster.routing.allocation.enable]] for open indices[..]

What can i do?

btw: sorry for my poor english...

like image 717
Jin-Yuan Chen Avatar asked Apr 02 '15 08:04

Jin-Yuan Chen


People also ask

How do I reduce number of shards in Elasticsearch?

If you're using time-based index names, for example daily indices for logging, and you don't have enough data, a good way to reduce the number of shards would be to switch to a weekly or a monthly pattern. You can also group old read-only indices., by month, quarter or year.

How many copies of shards are in each Elasticsearch shard?

primary vs replica shards – elasticsearch will create, by default, 5 primary shards and one replica for each index. That means that each elasticsearch index will be split into 5 chunks and each chunk will have one copy, for high availability.

What is shard allocation in Elasticsearch?

Shard allocation, which is an algorithm by which Elasticsearch decides which unallocated shards should go on which nodes, Shard rebalancing, which is the process of moving a shard from one node to another.


2 Answers

So close!

Try:

curl -XPUT 'http://localhost:9200/_cluster/settings' -d '{
"transient" : {
    "cluster.routing.allocation.disable_allocation": "true"
}}'
like image 171
GlenRSmith Avatar answered Oct 10 '22 05:10

GlenRSmith


OP might use an older Elasticsearch version that doesn't support updating "cluster.routing.allocation.enable" and/or "cluster.routing.rebalance.enable" dynamically.

However, on more recent Elasticsearch versions, those 2 settings should be dynamic or transient, not static or persistent any more.

Here are more details about shards-allocation settings from Elasticsearch current doc.

https://www.elastic.co/guide/en/elasticsearch/reference/current/shards-allocation.html

And user can apply/revoke these settings in Kibana Dev Tool Console, like these

PUT _cluster/settings
{
  "transient" : {
    "cluster.routing.allocation.enable": "none",
    "cluster.routing.rebalance.enable" : "none"
  }
}

# After bouncing ES cluster
PUT _cluster/settings
{
  "transient" : {
    "cluster.routing.allocation.enable": "all",
    "cluster.routing.rebalance.enable" : "all"
  }
}
like image 27
Hang Avatar answered Oct 10 '22 03:10

Hang