--- title: "不允许创建快照 – 如何解决此 Elasticsearch 异常" date: 2026-03-14 lastmod: 2026-03-14 description: "当尝试在 Elasticsearch 中创建快照时,由于某些条件限制导致操作不被允许而引发的异常问题及解决方案" tags: ["快照", "异常处理", "索引分片"] summary: "版本: 6.8-8.9 简而言之,当您尝试在 Elasticsearch 中创建快照时,由于某些条件限制导致操作不被允许,就会发生此错误。这可能是因为集群未处于可以安全创建快照的状态,或者存储库是只读的。要解决此问题,您可以检查集群健康状况并确保其处于良好状态。如果存储库是只读的,您可以修改其设置以允许写入操作。此外,请确保用户具有创建快照所需的必要权限。 日志上下文 # 日志 “snapshot is not allowed” 的类名是 IndexShard.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入了解上下文的人参考: final IndexShardState state = this.state; // one time volatile read // we allow snapshot on closed index shard; since we want to do one after we close the shard and before we close the engine if (state == IndexShardState.STARTED || state == IndexShardState.CLOSED) { return getEngine().acquireLastIndexCommit(flushFirst); } else { throw new IllegalIndexShardStateException(shardId; state; "snapshot is not allowed"); } } /** * Acquires the {@link IndexCommit} which should be included in a snapshot." --- > **版本:** 6.8-8.9 简而言之,当您尝试在 Elasticsearch 中创建快照时,由于某些条件限制导致操作不被允许,就会发生此错误。这可能是因为集群未处于可以安全创建快照的状态,或者存储库是只读的。要解决此问题,您可以检查集群健康状况并确保其处于良好状态。如果存储库是只读的,您可以修改其设置以允许写入操作。此外,请确保用户具有创建快照所需的必要权限。 日志上下文 ----------- 日志 "snapshot is not allowed" 的类名是 [IndexShard.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入了解上下文的人参考: ```java final IndexShardState state = this.state; // one time volatile read // we allow snapshot on closed index shard; since we want to do one after we close the shard and before we close the engine if (state == IndexShardState.STARTED || state == IndexShardState.CLOSED) { return getEngine().acquireLastIndexCommit(flushFirst); } else { throw new IllegalIndexShardStateException(shardId; state; "snapshot is not allowed"); } } /** * Acquires the {@link IndexCommit} which should be included in a snapshot. ```