elasticsearch 启动报错 SearchPhaseExecutionException[Failed to execute phase [query], all shards failed]

发布时间 2023-05-20 16:48:28作者: 林诺欧巴

Elasticsearch 启动报错:

[2023-05-19T22:39:32,161][DEBUG][o.e.a.s.TransportSearchAction] [X-111.ecs] All shards failed for phase: [query]
[2020-05-19T22:39:32,162][WARN ][r.suppressed             ] [X-111.ecs] path: /.kibana_task_manager/_search, params: {ignore_unavailable=true, index=.kibana_task_manager}
org.elasticsearch.action.search.SearchPhaseExecutionException: all shards failed
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:305) ~[elasticsearch-8.7.0.jar:8.7.0]
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:139) ~[elasticsearch-8.7.0.jar:8.7.0]

 

1、查看索引信息

curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
{
  "cluster_name" : "elasticsearch",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 14,
  "active_shards" : 14,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 4,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 77.77777777777779
}

 

2、查看状态

curl  'localhost:9200/_cat/indices?v'
health status index                                uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   logstash-nginx-access-log-2023.05.06 yJLiEgQqQEa9aBxoy1Ge9A   1   1      13704            0      3.6mb          3.6mb
yellow open   logstash-nginx-error-log-2023.05.07  Kc13mo7NSIiFKyu6ABGS6w   1   1        603            0      491kb          491kb
yellow open   logstash-nginx-error-log-2023.05.06  UJjcWNgkR3uiJi0ynxu51Q   1   1        491            0    374.1kb        374.1kb
yellow open   logstash-nginx-access-log-2023.05.07 WjZi_913Qv-HSYzhy-qOGA   1   1      13784            0      3.2mb          3.2mb
  • green:所有的主分片和副本分片都已分配。你的集群是 100% 可用的。
  • yellow:所有的主分片已经分片了,但至少还有一个副本是缺失的。不会有数据丢失,所以搜索结果依然是完整的。不过,你的高可用性在某种程度上被弱化。如果 更多的 分片消失,你就会丢数据了。把 yellow 想象成一个需要及时调查的警告。
  • red:至少一个主分片(以及它的全部副本)都在缺失中。这意味着你在缺少数据:搜索只能返回部分数据,而分配到这个分片上的写入请求会返回一个异常。

 

3、删除 yellow、red 状态的索引

curl -XDELETE http://localhost:9200/index_name

# 例如
curl -XDELETE http://localhost:9200/
logstash-nginx-access-log-2023.05.06

 

重启 ES 问题解决