记一次elasticsearch错误(SearchPhaseExecutionException: all shards failed)

一、问题

logstash突然无法对elasticsearch服务进行读写操作了,提示elasticsearch的地址有问题,检测elasticsearch发现端口存在。查看日志发现有报错。

二、问题原因

有一些索引的数据损坏了

三、解决

官网文档:https://www.elastic.co/guide/cn/elasticsearch/guide/cn/_cluster_health.html

1、查看索引信息

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

{
  "cluster_name" : "test",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 134,
  "active_shards" : 134,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 30,
  "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" : 98.19711538461539  #数据的正常率,100表示一切ok
}

 

2、查看所有所有的状态

green:所有的主分片和副本分片都已分配。你的集群是 100% 可用的。
yellow:所有的主分片已经分片了,但至少还有一个副本是缺失的。不会有数据丢失,所以搜索结果依然是完整的。不过,你的高可用性在某种程度上被弱化。如果 更多的 分片消失,你就会丢数据了。把 yellow 想象成一个需要及时调查的警告。
red:至少一个主分片(以及它的全部副本)都在缺失中。这意味着你在缺少数据:搜索只能返回部分数据,而分配到这个分片上的写入请求会返回一个异常。

curl  'localhost:9200/_cat/indices?v'

 

3、删除red状态的索引

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

 

posted @ 2019-08-13 15:14  巽逸  阅读(26024)  评论(1编辑  收藏  举报