[Elasticsearch]:无法恢复主分片

[Elasticsearch]: Unable to Recover Primary Shard

我使用的是 Elasticsearch 2.3.5 版本。我必须从备份磁盘中恢复完整的数据。除了 2 个碎片外,所有东西都恢复了。在检查日志时,我发现了以下错误。

错误:

Caused by: java.nio.file.NoSuchFileException: /data/<cluster_name>/nodes/0/indices/index_name/shard_no/index/_c4_49.liv
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:177)
        at java.nio.channels.FileChannel.open(FileChannel.java:287)
        at java.nio.channels.FileChannel.open(FileChannel.java:335)
        at org.apache.lucene.store.NIOFSDirectory.openInput(NIOFSDirectory.java:81)
        at org.apache.lucene.store.FileSwitchDirectory.openInput(FileSwitchDirectory.java:186)
        at org.apache.lucene.store.FilterDirectory.openInput(FilterDirectory.java:89)
        at org.apache.lucene.store.FilterDirectory.openInput(FilterDirectory.java:89)
        at org.apache.lucene.store.Directory.openChecksumInput(Directory.java:109)
        at org.apache.lucene.codecs.lucene50.Lucene50LiveDocsFormat.readLiveDocs(Lucene50LiveDocsFormat.java:83)
        at org.apache.lucene.index.SegmentReader.<init>(SegmentReader.java:73)
        at org.apache.lucene.index.ReadersAndUpdates.getReader(ReadersAndUpdates.java:145)
        at org.apache.lucene.index.ReadersAndUpdates.getReadOnlyClone(ReadersAndUpdates.java:197)
        at org.apache.lucene.index.StandardDirectoryReader.open(StandardDirectoryReader.java:99)
        at org.apache.lucene.index.IndexWriter.getReader(IndexWriter.java:435)
        at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:100)
        at org.elasticsearch.index.engine.InternalEngine.createSearcherManager(InternalEngine.java:283)
        ... 12 more

任何人都可以建议为什么会发生这种情况,或者我可以跳过这个特定文件吗?

提前致谢

不幸的是,从文件系统备份中恢复 Elasticsearch 并不是恢复数据的可靠方法,有时会像这样失败。您应该始终使用 snapshot and restore instead. Your version is rather old, but more recent versions include this warning in the docs(这也适用于您的版本):

WARNING: You cannot back up an Elasticsearch cluster by simply copying the data directories of all of its nodes. Elasticsearch may be making changes to the contents of its data directories while it is running; copying its data directories cannot be expected to capture a consistent picture of their contents. If you try to restore a cluster from such a backup, it may fail and report corruption and/or missing files. Alternatively, it may appear to have succeeded though it silently lost some of its data. The only reliable way to back up a cluster is by using the snapshot and restore functionality.

有可能恢复也悄无声息地丢失了其他分片中的数据,无法判断。假设您也没有丢失分片中保存的数据的快照,恢复它的唯一方法是从其源重新索引它。