弹性搜索节点重新启动后快速恢复 [英] quick recovery after node restart in elasticsearch
问题描述
请考虑以下弹性搜索的设置
Consider the below settings in the elasticsearch.yml
gateway.recover_after_data_nodes: 3
gateway.recover_after_time: 5m
gateway.expected_data_nodes: 3
当前设置:
说,我有3数据节点。现在如果我决定重新启动一个数据节点(由于设置的变化很小),则根据expected_data_nodes设置,恢复将在节点重新启动后立即启动。将有许多未分配的碎片,根据其包含的数据,缓慢分配。
Current setting: Say, I have 3 data nodes. Now if I decide to restart a data node(due to a small change in setting), the recovery will start immediately after node restart as per the expected_data_nodes setting. There will be many unassigned shards, which will get allocated slowly depending on the data it contains.
为了避免这种情况,是否有任何方法分配所有未分配的碎片到一个特定的节点(在我的情况下是重新启动的节点),一旦完成,ES应该接管重新平衡。
In order to avoid that, is there any way to allocate all the unassigned shards to a specific node?(in my case the restarted node) and once that is done, ES should take over the rebalancing.
主要是我想避免重要的时间集群状态从黄色到绿色(在我的情况下是小时数)
Mainly I want to avoid the heavy timelag of the cluster state from yellow to green.(it is in the range of hours in my case)
我可以使用集群reroute api来实现吗?
Can I use the cluster reroute api for this purpose?
还是有任何其他api将所有未分配的分片一次性转移到特定节点?
or is there any other api to transfer all the unassigned shards to specific node at one go?
推荐答案
对于Elasticsearch版本> = 1.0.0:
curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.enable": "none"}}'
/etc/init.d/elasticsearch restart
curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.enable": "all"}}'
对于早期版本的ES :
curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.disable_allocation": true}}'
/etc/init.d/elasticsearch restart
curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.disable_allocation": false}}'
碎片保持未分配,直到cluster.routing。 alloc.disable_allocation:false,然后在服务器上的分片恢复刚刚重新启动(从关机前的大小开始)
非常快。
Shard keep unallocated until "cluster.routing.allocation.disable_allocation": false, then shards recover on the server just restarted (starting at size they were before shutdown) It is very quick.
这篇关于弹性搜索节点重新启动后快速恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!