ElasticSearch重启之后shard未分配问题的解决
?
環境:
- Ubuntu16.04
- elasticsearch 6.2.3
- 3個master節點,10個data節點
- 每個分片有一個副本
故障:
? ? 將一個數據節點的elasticsearch換成docker elasticsearch,分詞器沒有添加到plugins中。隨后把分詞器添加到plugins中后,發現有的分片沒有被分配,但是ES集群啟動正常,只不過一直是yellow狀態。而且unassigned分片一直未被分配。
解決辦法
首先執行:GET user/_recovery?active_only=true?發現集群并沒有進行副本恢復。
點擊未進行分配的分片,發現allocation_status: "no_attempt"
原因是:shard 自動分配 已經達到最大重試次數5次,仍然失敗了,所以導致"shard的分配狀態已經是:no_attempt"。這時在Kibana Dev Tools,執行命令:POST /_cluster/reroute?retry_failed=true即可。由index.allocation.max_retries參數來控制最大重試次數。
The cluster will attempt to allocate a shard a maximum of index.allocation.max_retries times in a row (defaults to 5), before giving up and leaving the shard unallocated.
當執行reroute命令對分片重新路由后,ElasticSearch會自動進行負載均衡,負載均衡參數cluster.routing.rebalance.enable默認為true。?
It is important to note that after processing any reroute commands Elasticsearch will perform rebalancing as normal (respecting the values of settings such as cluster.routing.rebalance.enable) in order to remain in a balanced state.
?總結
一般來說,ElasticSearch會自動分配 那些 unassigned shards,當發現某些shards長期未分配時,首先看下是否是因為:為索引指定了過多的primary shard 和 replica 數量,然后集群中機器數量又不夠。另一個原因就是本文中提到的:由于故障,shard自動分配達到了最大重試次數了,這時執行 reroute 就可以了。
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的ElasticSearch重启之后shard未分配问题的解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 将springboot jar应用打包成
- 下一篇: docker 部署springboot容