【问题标题】:Consul is unable to find the cluster leaderConsul 找不到集群负责人
【发布时间】:2017-05-29 08:56:23
【问题描述】:

我用过这个:

https://github.com/Mashape/docker-kong/tree/master/compose

通过 docker compose 在 Docker 上本地运行 Kong。一旦我运行docker-compose up,我的日志中就会不断出现这个错误:

consul_1 | 2017/05/29 08:44:05 [INFO] raft: Node at 172.17.0.4:8300 [Candidate] entering Candidate state
consul_1 | 2017/05/29 08:44:05 [ERR] raft: Failed to make RequestVote RPC to 172.17.0.3:8300: dial tcp 172.17.0.3:8300: connection refused
consul_1 | 2017/05/29 08:44:05 [ERR] raft: Failed to make RequestVote RPC to 172.17.0.2:8300: dial tcp 172.17.0.2:8300: connection refused
consul_1 | 2017/05/29 08:44:06 [ERR] agent: failed to sync changes: No cluster leader
consul_1 | 2017/05/29 08:44:06 [ERR] agent: failed to sync changes: No cluster leader
consul_1 | 2017/05/29 08:44:06 [ERR] agent: failed to sync changes: No cluster leader

我在 Google 上搜索过,但没有找到任何具体的答案。

【问题讨论】:

    标签: api docker consul kong


    【解决方案1】:

    发生这种情况是因为 consul 对其初始分配的本地 IP (172.17....) 进行了“硬编码”,然后当您再次运行 docker-compose 时,它​​需要一个新 IP,因此我们的朋友 consul 感到困惑。

    因此,作为简单的解决方法,您可以docker-compose rm consul 并重新开始docker-compose up。但请记住,您可能会丢失 consul 的数据(即 Key/Value 存储,但我不知道您的应用程序是否正在使用它)

    作为一个更好的解决方法(它对我有用),添加 -client=0.0.0.0 告诉 consul 硬编码一些更好的东西。

    在 docker-compose.yml 中:

    consul:
      image: progrium/consul:latest
      command: -server -bootstrap -ui-dir /ui -client=0.0.0.0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-21
      • 1970-01-01
      • 2018-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多