Title

ES 启动报错:all shards failed

1、查看健康情况:

curl -XGET 'http://127.0.0.1:9200/_cluster/health?pretty=true'

 最后一栏:active_shards_percent_as_number 的值,健康状态的值没有达到 100,现在才 50 多。

 

2、查看损坏索引:

curl -XGET 'http://127.0.0.1:9200/_cat/indices?v&pretty'

看最左边的 health 下面的状态颜色,应该都为  green 才对,现在有 yellow ,有些时候是 red 等

 

3、开始修复:

curl -H "Content-Type: application/json" -XPUT 'http://127.0.0.1:9200/_all/_settings' -d '
{
    "index" : {
       "number_of_replicas" : 0
    }
}'

 返回 {"acknowledged":true} 即修复好。

 

4、最后再查看健康状态:

active_shards_percent_as_number 已恢复为 100 ,即可正常启动 es 了。

 

【最后:如果遇到还是不行,可以选择 delete 损坏的索引:】

curl -X DELETE "localhost:9200/.kibana_task_manager_7.17.16_001"

 扩展:

查看所有为red的索引

curl -s 'http://10.50.209.162:30105/_cat/indices/?v' | grep red
 
查看未分配的分片还有原因
curl -X GET "localhost:30105/_cat/shards?h=index,shard,prirep,state,unassigned.reason&v"

posted @ 2024-07-02 10:56  Esurts~  阅读(142)  评论(0)    收藏  举报