在elasticsearch中重启节点后快速恢复 [英] quick recovery after node restart in elasticsearch

查看:24
本文介绍了在elasticsearch中重启节点后快速恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑 elasticsearch.yml 中的以下设置

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 个数据节点.现在,如果我决定重新启动数据节点(由于设置中的一个小变化),恢复将在节点重新启动后根据预期的_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)

我可以为此使用集群重新路由 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.allocation.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.

参考:http://elasticsearch-users.115913.n3.nabble.com/quick-recovery-after-node-restart-in-elasticsearch-td4033876.html#a4034211

这篇关于在elasticsearch中重启节点后快速恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆