--- title: "无法在只读存储库上克隆分片快照 - 如何解决此 Elasticsearch 异常" date: 2026-03-27 lastmod: 2026-03-27 description: "当Elasticsearch尝试在设置为只读模式的存储库上克隆分片快照时,会出现此错误。本文介绍了解决该问题的方法。" tags: ["Elasticsearch", "快照", "存储库", "只读模式", "异常处理"] summary: " 版本: 7.1-8.9 简而言之,当 Elasticsearch 尝试在设置为只读模式的存储库上克隆分片快照时,会出现此错误。由于存储库不可写,因此不允许执行此操作。要解决此问题,您可以更改存储库设置使其可写,或者将分片快照克隆到另一个非只读的存储库。此外,请确保用户具有对存储库执行写操作所需的权限。 日志上下文 # 日志 “cannot clone shard snapshot on a readonly repository” 的类名是 BlobStoreRepository.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些需要深入了解上下文的用户参考: RepositoryShardId shardId; @Nullable ShardGeneration shardGeneration; ActionListenerlistener ) { if (isReadOnly()) { listener.onFailure(new RepositoryException(metadata.name(); "cannot clone shard snapshot on a readonly repository")); return; } final IndexId index = shardId.index(); final int shardNum = shardId.shardId(); final Executor executor = threadPool.executor(ThreadPool.Names.SNAPSHOT); " --- > **版本:** 7.1-8.9 简而言之,当 Elasticsearch 尝试在设置为只读模式的存储库上克隆分片快照时,会出现此错误。由于存储库不可写,因此不允许执行此操作。要解决此问题,您可以更改存储库设置使其可写,或者将分片快照克隆到另一个非只读的存储库。此外,请确保用户具有对存储库执行写操作所需的权限。 ## 日志上下文 日志 "cannot clone shard snapshot on a readonly repository" 的类名是 [BlobStoreRepository.java](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)。我们从 Elasticsearch 源代码中提取了以下内容,供那些需要深入了解上下文的用户参考: ```java RepositoryShardId shardId; @Nullable ShardGeneration shardGeneration; ActionListenerlistener ) { if (isReadOnly()) { listener.onFailure(new RepositoryException(metadata.name(); "cannot clone shard snapshot on a readonly repository")); return; } final IndexId index = shardId.index(); final int shardNum = shardId.shardId(); final Executor executor = threadPool.executor(ThreadPool.Names.SNAPSHOT); ```