SearchPhaseExecutionException[无法执行阶段[查询],所有分片都失败]

SearchPhaseExecutionException[Failed to execute phase [query], all shards failed]

最近我们的服务器在没有正确关闭 Elastic Search / Kibana 的情况下重新启动。重新启动后,两个应用程序都是 运行 但不再创建索引。我在调试模式下检查了 logstash 设置,它正在向 Elastic Search 发送数据。

现在我创建的所有 windows 报告此错误:

Oops! SearchPhaseExecutionException[Failed to execute phase [query], all shards failed]

我尝试重新启动 Elastic Search / Kibana,并清除了一些索引。我进行了很多搜索,但无法正确解决此问题。

当前集群健康状态为红色,如图所示。

关于如何排除故障的任何帮助都已点赞。谢谢

编辑:

[2015-05-06 00:00:01,561][WARN ][cluster.action.shard     ] [Indech] [logstash-2015.03.16][1] sending failed shard for [logstash-2015.03.16][1], node[fdSgUPDbQB2B3NQqX7MdMQ], [P], s[INITIALIZING], indexUUID [aBcfbqnNR4-AGEdIR8dVdg], reason [Failed to start shard, message [IndexShardGatewayRecoveryException[[logstash-2015.03.16][1] failed to recover shard]; nested: ElasticsearchIllegalArgumentException[No version type match [101]]; ]]
[2015-05-06 00:00:01,561][WARN ][cluster.action.shard     ] [Indech] [logstash-2015.03.16][1] received shard failed for [logstash-2015.03.16][1], node[fdSgUPDbQB2B3NQqX7MdMQ], [P], s[INITIALIZING], indexUUID [aBcfbqnNR4-AGEdIR8dVdg], reason [Failed to start shard, message [IndexShardGatewayRecoveryException[[logstash-2015.03.16][1] failed to recover shard]; nested: ElasticsearchIllegalArgumentException[No version type match [101]]; ]]
[2015-05-06 00:00:02,591][WARN ][indices.cluster          ] [Indech] [logstash-2015.04.21][4] failed to start shard
org.elasticsearch.index.gateway.IndexShardGatewayRecoveryException: [logstash-2015.04.21][4] failed to recover shard
    at org.elasticsearch.index.gateway.local.LocalIndexShardGateway.recover(LocalIndexShardGateway.java:269)
    at org.elasticsearch.index.gateway.IndexShardGatewayService.run(IndexShardGatewayService.java:132)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: org.elasticsearch.ElasticsearchIllegalArgumentException: No version type match [52]
    at org.elasticsearch.index.VersionType.fromValue(VersionType.java:307)
    at org.elasticsearch.index.translog.Translog$Create.readFrom(Translog.java:364)
    at org.elasticsearch.index.translog.TranslogStreams.readTranslogOperation(TranslogStreams.java:52)
    at org.elasticsearch.index.gateway.local.LocalIndexShardGateway.recover(LocalIndexShardGateway.java:241)

日志中我关心的是:

[2015-05-06 15:13:48,059][DEBUG][action.search.type       ] All shards failed for phase: [query]



{
  "cluster_name" : "elasticsearch",
  "status" : "red",
  "timed_out" : false,
  "number_of_nodes" : 8,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 120,
  "active_shards" : 120,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 310
}

您有许多损坏的传输日志文件,您需要将其删除。您可以在 data/{clustername}/nodes/0/indices/logstash-2015.04.21/4/translog 中找到它,在 data/{clustername}/nodes/0/indices/logstash-2015.03.16/1/translog 中找到另一个。也许还有其他人,但这是我从您提供的代码片段中可以看出的。当然,会丢失 translog 文件中的内容。

如果索引不再有索引文件(data/{clustername}/nodes/0/indices/[index_name] 下仅存在 _state 文件夹)这意味着该索引中不再有数据,此时您可以删除指数。如果仍然需要,则需要重新索引该数据。如果您决定删除索引,则需要关闭节点并删除 data/{clustername}/nodes/0/indices 下与您提到的索引文件夹类似的文件夹(空,仅包含 _state 文件夹)。

  1. 尝试删除您的索引并重新创建。有时会有帮助。

  2. 或者您可能正在尝试在同一查询中查询 intstring 字段。

当未定义索引的 IndexTemplate 时,也会出现此错误。