--- title: "选举未获胜 – 如何解决此 Elasticsearch 异常" date: 2026-03-11 lastmod: 2026-03-11 description: "当 Elasticsearch 节点尝试成为主节点但失败时会出现此错误。这可能是由于网络问题、配置问题或更高优先级的节点接管导致的。" tags: ["集群管理", "主节点选举", "协调状态"] summary: " 版本: 7-8.9 简要来说,当 Elasticsearch 中的节点尝试成为主节点但失败时,会出现此错误。这可能是由于网络问题、配置问题或更高优先级的节点接管导致的。要解决此问题,请确保所有节点都正确配置且网络连接稳定。此外,检查主节点的优先级设置。如有必要,调整 ‘discovery.zen.minimum_master_nodes’ 设置以避免脑裂场景。 日志上下文 # 日志 “election not won” 的类名是 CoordinationState.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用: * @throws CoordinationStateRejectedException if the arguments were incompatible with the current state of this object. */ public PublishRequest handleClientValue(ClusterState clusterState) { if (electionWon == false) { logger.debug("handleClientValue: ignored request as election not won"); throw new CoordinationStateRejectedException("election not won"); } if (lastPublishedVersion != getLastAcceptedVersion()) { logger.debug("handleClientValue: cannot start publishing next value before accepting previous one"); throw new CoordinationStateRejectedException("cannot start publishing next value before accepting previous one"); } " --- > **版本:** 7-8.9 简要来说,当 Elasticsearch 中的节点尝试成为主节点但失败时,会出现此错误。这可能是由于网络问题、配置问题或更高优先级的节点接管导致的。要解决此问题,请确保所有节点都正确配置且网络连接稳定。此外,检查主节点的优先级设置。如有必要,调整 'discovery.zen.minimum_master_nodes' 设置以避免脑裂场景。 日志上下文 ----------- 日志 "election not won" 的类名是 [CoordinationState.java](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/)。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用: ```java * @throws CoordinationStateRejectedException if the arguments were incompatible with the current state of this object. */ public PublishRequest handleClientValue(ClusterState clusterState) { if (electionWon == false) { logger.debug("handleClientValue: ignored request as election not won"); throw new CoordinationStateRejectedException("election not won"); } if (lastPublishedVersion != getLastAcceptedVersion()) { logger.debug("handleClientValue: cannot start publishing next value before accepting previous one"); throw new CoordinationStateRejectedException("cannot start publishing next value before accepting previous one"); } ```