请考虑elasticsearch.yml中的以下设置
gateway.recover_after_data_nodes: 3
gateway.recover_after_time: 5m
gateway.expected_data_nodes: 3当前设置:假设我有3个数据节点。现在,如果我决定重新启动数据节点(由于设置中的一个小更改),恢复将根据expected_data_nodes设置在节点重新启动后立即开始。将有许多未分配的分片,这些分片将根据其包含的数据进行缓慢分配。
为了避免这种情况,有没有办法将所有未分配的分片分配给特定的节点(在我的例子中是重新启动的节点),一旦这样做了,ES就应该接管重新平衡。
我主要想避免集群状态从黄色到绿色的严重时间延迟。(在我的例子中,它在小时范围内)
我可以使用集群重路由api来实现此目的吗?
或者是否有其他接口可以一次性将所有未分配的分片转移到特定节点?
发布于 2013-05-03 18:01:57
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":为假,然后在服务器上恢复刚刚重启的分片(从关机前的大小开始)非常快。
参考:http://elasticsearch-users.115913.n3.nabble.com/quick-recovery-after-node-restart-in-elasticsearch-td4033876.html#a4034211
https://stackoverflow.com/questions/16231614
复制相似问题