服务器宕机后,es出现unassigned shards,使用reroute 命令提示 shard has exceeded the maximum number of retries,即使加上 retry_failed=true参数也无法解决 。经过多次尝试和网上查询,发现通过以下步骤可以解决该问题:
- 禁用allocation配置
PUT _cluster/settings { "persistent": { "cluster.routing.allocation.enable": "none" } }
- 重置计数器
POST /_cluster/reroute?retry_failed=true
- 执行reroute命令
POST /_cluster/reroute { "commands": [ { "allocate_replica": { "index": "xx", "shard": 0, "node": "AQ7l1ti9RqejnLg2HN0q1A" } } ] }
- 启用allocation配置
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "all"
}
}