ELK:ElasticSearch UNASSIGNED 分片恢復
阿新 • • 發佈:2021-01-02
技術標籤:大資料處理elasticsearchUNASSIGNED
記錄下解決方法:
es的健康狀態yellow,並一直持續yellow,檢視shards,存在UNASSIGNED分片
首先查詢:
curl -XGET http://127.0.0.1:9200/_cat/shards | grep UNASSIGNED | sort
可以看到所有的 UNASSIGNED分片
Elasticsearch是有自動分配節點功能的,但一直沒有分配成功,是什麼原因導致的呢?我們首先來檢視下es的自動分配功能
curl -XGET http://127.0.0.1:9200/_cluster/settings
{
"persistent" : { },
"transient" : { }
}
沒有啟動自動分配功能
那麼有如下解決方式
解決方式1:
啟動自動分配功能
curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/_cluster/settings -d
'{
"persistent": {},
"transient": {
"cluster": {
"routing": {
"allocation": {
"enable": "all" }
}
}
}
}'
檢視自動分配功能
curl -XGET http://127.0.0.1:9200/_cluster/settings?pretty
{
"persistent" : { },
"transient" : {
"cluster" : {
"routing" : {
"allocation" : {
"enable" : "all"
}
}
}
}
}
解決方式2:
重建副本分片
PUT /index/_settings
{
"index" : {
"number_of_replicas" : 0
}
}
重新分配副本分片
PUT /index/_settings
{
"index" : {
"number_of_replicas" : 1
}
}
兩種方式都可以解決由於副本丟失等造成的yellow狀態 副本分片 UNASSIGNED