DEBUG.WIKI
阿里云;从建站到云上业务;云服务器 · 数据库 · 对象存储;查看产品 →
PanstarCloud:部署应用,接入 AI,云服务器与 AI 网关
IPPeak:从目标地区访问网页,住宅代理、SEO 监测、广告验证

解决 Apache APISIX 报错 failed to query etcd cluster unhealthy 修复

排查 Apache APISIX 启动或同步路由报 failed to query etcd cluster unhealthy,分析 etcd 集群健康状态与 TLS 证书配置。

问题现象

APISIX 启动失败或在运行中报同步中断:

[error] 45#45: *12 failed to query etcd: failed to query etcd cluster: etcd cluster is unhealthy, host: http://127.0.0.1:2379, client: 127.0.0.1

触发根因

  1. etcd 进程未运行或端口 2379 不可达;
  2. etcd 启用了客户端证书验证(mTLS),但 APISIX config.yaml 未指定证书路径;
  3. etcd 节点发生网络分区导致法定人数(Quorum)丢失。

解决步骤

使用 etcdctl 确认集群健康状态

检查 etcd 本地端点状态:

etcdctl --endpoints=http://127.0.0.1:2379 endpoint health

修正 APISIX config.yaml 的 etcd 配置

在 conf/config.yaml 中配置全部可用节点和认证参数:

etcd:
  host:
    - "http://10.0.0.11:2379"
    - "http://10.0.0.12:2379"
  prefix: "/apisix"
  timeout: 30

验证确认

重启 APISIX 服务:

apisix reload

日志显示 etcd cluster is healthy,路由规则加载完毕。