--- title: "安全索引至少有一个主分片不可用 – 如何解决此Elasticsearch异常" date: 2026-03-23 lastmod: 2026-03-23 description: "Elasticsearch安全索引的主分片不可用异常的原因分析及解决方案,包括节点重启、网络检查、磁盘空间清理等排查步骤。" tags: ["安全索引", "分片不可用", "集群健康", "索引管理"] summary: " 版本: 6.8-7.1 简而言之,当Elasticsearch无法访问安全索引的至少一个主分片时,就会发生此错误。这可能是由于网络问题、节点故障或磁盘空间问题导致的。要解决此问题,您可以尝试重启Elasticsearch节点、检查网络连接或释放磁盘空间。此外,请确保集群健康状态为绿色或黄色,而不是红色。如果问题仍然存在,您可能需要重新索引数据或增加主分片的数量。 日志上下文 # 日志"at least one primary shard for the security index is unavailable"的类名是 SecurityIndexManager.java。我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人使用: if (localState.indexAvailable) { throw new IllegalStateException("caller must make sure to use a frozen state and check indexAvailable"); } if (localState.indexExists) { return new UnavailableShardsException(null; "at least one primary shard for the security index is unavailable"); } else { return new IndexNotFoundException(SECURITY_INDEX_NAME); } } " --- > **版本:** 6.8-7.1 简而言之,当Elasticsearch无法访问安全索引的至少一个主分片时,就会发生此错误。这可能是由于网络问题、节点故障或磁盘空间问题导致的。要解决此问题,您可以尝试重启Elasticsearch节点、检查网络连接或释放磁盘空间。此外,请确保集群健康状态为绿色或黄色,而不是红色。如果问题仍然存在,您可能需要重新索引数据或增加主分片的数量。 ## 日志上下文 ----------- 日志"at least one primary shard for the security index is unavailable"的类名是[SecurityIndexManager.java](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)。我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人使用: ```java if (localState.indexAvailable) { throw new IllegalStateException("caller must make sure to use a frozen state and check indexAvailable"); } if (localState.indexExists) { return new UnavailableShardsException(null; "at least one primary shard for the security index is unavailable"); } else { return new IndexNotFoundException(SECURITY_INDEX_NAME); } } ```