【问题标题】:Changing default consul http port更改默认领事 http 端口
【发布时间】:2019-02-20 01:36:36
【问题描述】:

我需要更改默认 http 端口,因为另一个应用程序已经在使用 8500。

此命令有效:

consul info -http-addr=http://127.0.0.1:18500

我无法弄清楚这等于配置文件中的配置设置。

这是我当前的设置:

datacenter = "test_test"
data_dir = "/opt/consul"
encrypt = "**********"
performance {
  raft_multiplier = 1
}
ports {
  http = 18500
  dns = 18600
  server = 18300
}
addresses {
  http = "127.0.0.1"
}
retry_join = ["10.60.0.5"]`

运行 join 或 info 命令时的错误消息:

Error querying agent: Get http://127.0.0.1:8500/v1/agent/self: dial tcp 127.0.0.1:8500: connect: connection refused

【问题讨论】:

    标签: consul


    【解决方案1】:

    如果你使用:

    {
        "ports": {
            "http": 18500
        }
    }
    

    那么consul默认会绑定到localhost:

    ==> Log data will now stream in as it occurs:
    
        2019/02/19 17:28:23 [INFO] raft: Initial configuration (index=1): [{Suffrage:Voter ID:4887467c-c84b-15b4-66f7-ad3f822631e0 Address:172.17.0.2:8300}]
        2019/02/19 17:28:23 [INFO] raft: Node at 172.17.0.2:8300 [Follower] entering Follower state (Leader: "")
        2019/02/19 17:28:23 [INFO] serf: EventMemberJoin: b884fe85d115.dc1 172.17.0.2
        2019/02/19 17:28:23 [INFO] serf: EventMemberJoin: b884fe85d115 172.17.0.2
        2019/02/19 17:28:24 [INFO] consul: Adding LAN server b884fe85d115 (Addr: tcp/172.17.0.2:8300) (DC: dc1)
        2019/02/19 17:28:24 [INFO] consul: Handled member-join event for server "b884fe85d115.dc1" in area "wan"
        2019/02/19 17:28:24 [WARN] agent/proxy: running as root, will not start managed proxies
        2019/02/19 17:28:24 [INFO] agent: Started DNS server 127.0.0.1:8600 (tcp)
        2019/02/19 17:28:24 [INFO] agent: Started DNS server 127.0.0.1:8600 (udp)
        2019/02/19 17:28:24 [INFO] agent: Started HTTP server on 127.0.0.1:18500 (tcp)
    
    

    显然,来自其他节点的任何人都无法连接到您的引导服务器。

    你应该配置地址和端口:

    {
        "addresses": {
            "http": "0.0.0.0"
        },    
        "ports": {
            "http": 18500
        }
    }
    

    现在您可以看到任何 IP 0.0.0.0/0 的绑定

    ==> Log data will now stream in as it occurs:
    
        2019/02/19 17:35:11 [INFO] raft: Initial configuration (index=1): [{Suffrage:Voter ID:ef42f35f-7505-d1fc-3f91-16f144d91fc6 Address:172.17.0.2:8300}]
        2019/02/19 17:35:11 [INFO] raft: Node at 172.17.0.2:8300 [Follower] entering Follower state (Leader: "")
        2019/02/19 17:35:11 [INFO] serf: EventMemberJoin: ac34230483e0.dc1 172.17.0.2
        2019/02/19 17:35:11 [INFO] serf: EventMemberJoin: ac34230483e0 172.17.0.2
        2019/02/19 17:35:11 [INFO] agent: Started DNS server 127.0.0.1:8600 (udp)
        2019/02/19 17:35:11 [WARN] agent/proxy: running as root, will not start managed proxies
        2019/02/19 17:35:11 [INFO] consul: Adding LAN server ac34230483e0 (Addr: tcp/172.17.0.2:8300) (DC: dc1)
        2019/02/19 17:35:11 [INFO] agent: Started DNS server 127.0.0.1:8600 (tcp)
        2019/02/19 17:35:11 [INFO] consul: Handled member-join event for server "ac34230483e0.dc1" in area "wan"
        2019/02/19 17:35:11 [INFO] agent: Started HTTP server on [::]:18500 (tcp)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-31
      • 2013-11-30
      • 1970-01-01
      • 1970-01-01
      • 2015-06-21
      • 2014-08-29
      • 2014-08-27
      相关资源
      最近更新 更多