--- title: "未能删除段文件中未引用的文件 – 如何解决此 Elasticsearch 异常" date: 2026-01-16 lastmod: 2026-01-16 description: "Elasticsearch 无法删除段文件中未引用的文件的错误解决方法" tags: ["文件删除", "段文件", "权限问题"] summary: " 版本: 7.11-7.13 简要来说,当 Elasticsearch 无法删除段文件中未引用的文件时,会出现此错误。这可能是由于权限不足、文件被锁定或磁盘空间问题导致的。要解决此问题,您可以检查并调整文件权限,确保没有进程锁定该文件,或释放磁盘空间。此外,如果问题是暂时的或由故障引起的,重启 Elasticsearch 节点可能会有所帮助。 日志上下文 # 日志 “Failed to remove files not referenced in segment file [” 的类名是 FileRestoreContext.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入了解上下文的人参考: final String indexStoreType = INDEX_STORE_TYPE_SETTING.get(store.indexSettings().getSettings()); if ("snapshot".equals(indexStoreType) == false) { Lucene.pruneUnreferencedFiles(restoredSegmentsFile.name(); store.directory()); } } catch (IOException e) { throw new IndexShardRestoreFailedException(shardId; "Failed to remove files not referenced in segment file [" + restoredSegmentsFile.name() + "] after restore"; e); } /// now; go over and clean files that are in the store; but were not in the snapshot try { " --- > **版本:** 7.11-7.13 简要来说,当 Elasticsearch 无法删除段文件中未引用的文件时,会出现此错误。这可能是由于权限不足、文件被锁定或磁盘空间问题导致的。要解决此问题,您可以检查并调整文件权限,确保没有进程锁定该文件,或释放磁盘空间。此外,如果问题是暂时的或由故障引起的,重启 Elasticsearch 节点可能会有所帮助。 日志上下文 ----------- 日志 "Failed to remove files not referenced in segment file [" 的类名是 [FileRestoreContext.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入了解上下文的人参考: ```java final String indexStoreType = INDEX_STORE_TYPE_SETTING.get(store.indexSettings().getSettings()); if ("snapshot".equals(indexStoreType) == false) { Lucene.pruneUnreferencedFiles(restoredSegmentsFile.name(); store.directory()); } } catch (IOException e) { throw new IndexShardRestoreFailedException(shardId; "Failed to remove files not referenced in segment file [" + restoredSegmentsFile.name() + "] after restore"; e); } /// now; go over and clean files that are in the store; but were not in the snapshot try { ```