Elasticsearch 分片错误failed shard recovery解决办法

Elasticsearch 分片错误failed shard recovery解决办法

今天早上Elasticsearch莫名奇怪的报错了。整个控制台不停的打印出

[2016-06-07 08:55:00,976][WARN ][indices.cluster ] [secilog] [[seci-201
606][1]] marking and sending shard failed due to [failed recovery]

org.elasticsearch.index.gateway.IndexShardGatewayRecoveryException: [seci-201606
][1] failed recovery at org.elasticsearch.index.gateway.IndexShardGatewayService$1.run(IndexS
hardGatewayService.java:162)

[2016-06-07 08:40:41,967][WARN ][cluster.action.shard ] [secilog] [seci-201606][1] received shard failed for [seci-201606][1], node[xGIRwM34TdWcKgV95BI74g], [P], s[INITIALIZING], indexUUID [t75Egn6rT2WyBYQk_2X3IQ], reason [shard failure [failed recovery][IndexShardGatewayRecoveryException[[seci-201606][1] failed recovery]; nested: EngineCreationFailureException[[seci-201606][1] failed to create engine]; nested: CorruptIndexException[codec footer mismatch: actual footer=-464453631 vs expected footer=-1071082520 (resource: MMapIndexInput(path="D:secislandsecilogelasticsearchdata192.168.21.5odesindicesseci-2016061index\_6exw.cfs"))]; ]]

通过错误内容大概可以看出是数据的一个分片出了问题。这个问题的解决在网上比较少,特在此介绍一下。

检查:localhost:9200/_cluster/health

从内容上可以看出有红色的状态,表示出了比较严重的问题。

问题解决:

先停掉Elasticsearch。

转到Elasticsearch的lib目录

在目录下执行java -cp lucene-core-4.10.4.jar -ea:org.apache.lucene... org.apache.lucene.index.CheckIndex D:secislandsecilogelasticsearchdata192.168.21.5odesindicesseci-2016061index -fix

然后重启看下是否好了。如果还没有好可以再次停掉Elasticsearch。

到D:secislandsecilogelasticsearchdata192.168.21.5odesindicesseci-2016061ranslog目录。

删掉里面的*.recovery文件。

然后重启Elasticsearch。

这样就解决了分片损坏的问题。

赛克蓝德(secisland)版权所有,转载须保留出处。

推荐阅读