领事从服务器空的答复

我试图让领事服务器集群运行起来。 我有3个docker化的领事服务器正在运行,但我无法访问Web UI,HTTP API或DNS。

$ docker logs net-sci_discovery-service_consul_1 ==> WARNING: Expect Mode enabled, expecting 3 servers ==> Starting Consul agent... ==> Consul agent running! Version: 'v0.8.5' Node ID: 'ccd38897-6047-f8b6-be1c-2aa0022a1483' Node name: 'consul1' Datacenter: 'dc1' Server: true (bootstrap: false) Client Addr: 127.0.0.1 (HTTP: 8500, HTTPS: -1, DNS: 8600) Cluster Addr: 172.20.0.2 (LAN: 8301, WAN: 8302) Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false ==> Log data will now stream in as it occurs: 2017/07/07 23:24:07 [INFO] raft: Initial configuration (index=0): [] 2017/07/07 23:24:07 [INFO] raft: Node at 172.20.0.2:8300 [Follower] entering Follower state (Leader: "") 2017/07/07 23:24:07 [INFO] serf: EventMemberJoin: consul1 172.20.0.2 2017/07/07 23:24:07 [INFO] consul: Adding LAN server consul1 (Addr: tcp/172.20.0.2:8300) (DC: dc1) 2017/07/07 23:24:07 [INFO] serf: EventMemberJoin: consul1.dc1 172.20.0.2 2017/07/07 23:24:07 [INFO] consul: Handled member-join event for server "consul1.dc1" in area "wan" 2017/07/07 23:24:07 [INFO] agent: Started DNS server 127.0.0.1:8600 (tcp) 2017/07/07 23:24:07 [INFO] agent: Started DNS server 127.0.0.1:8600 (udp) 2017/07/07 23:24:07 [INFO] agent: Started HTTP server on 127.0.0.1:8500 2017/07/07 23:24:09 [INFO] serf: EventMemberJoin: consul2 172.20.0.3 2017/07/07 23:24:09 [INFO] consul: Adding LAN server consul2 (Addr: tcp/172.20.0.3:8300) (DC: dc1) 2017/07/07 23:24:09 [INFO] serf: EventMemberJoin: consul2.dc1 172.20.0.3 2017/07/07 23:24:09 [INFO] consul: Handled member-join event for server "consul2.dc1" in area "wan" 2017/07/07 23:24:10 [INFO] serf: EventMemberJoin: consul3 172.20.0.4 2017/07/07 23:24:10 [INFO] consul: Adding LAN server consul3 (Addr: tcp/172.20.0.4:8300) (DC: dc1) 2017/07/07 23:24:10 [INFO] consul: Found expected number of peers, attempting bootstrap: 172.20.0.2:8300,172.20.0.3:8300,172.20.0.4:8300 2017/07/07 23:24:10 [INFO] serf: EventMemberJoin: consul3.dc1 172.20.0.4 2017/07/07 23:24:10 [INFO] consul: Handled member-join event for server "consul3.dc1" in area "wan" 2017/07/07 23:24:14 [ERR] agent: failed to sync remote state: No cluster leader 2017/07/07 23:24:17 [WARN] raft: Heartbeat timeout from "" reached, starting election 2017/07/07 23:24:17 [INFO] raft: Node at 172.20.0.2:8300 [Candidate] entering Candidate state in term 2 2017/07/07 23:24:17 [INFO] raft: Election won. Tally: 2 2017/07/07 23:24:17 [INFO] raft: Node at 172.20.0.2:8300 [Leader] entering Leader state 2017/07/07 23:24:17 [INFO] raft: Added peer 172.20.0.3:8300, starting replication 2017/07/07 23:24:17 [INFO] raft: Added peer 172.20.0.4:8300, starting replication 2017/07/07 23:24:17 [INFO] consul: cluster leadership acquired 2017/07/07 23:24:17 [INFO] consul: New leader elected: consul1 2017/07/07 23:24:17 [WARN] raft: AppendEntries to {Voter 172.20.0.3:8300 172.20.0.3:8300} rejected, sending older logs (next: 1) 2017/07/07 23:24:17 [WARN] raft: AppendEntries to {Voter 172.20.0.4:8300 172.20.0.4:8300} rejected, sending older logs (next: 1) 2017/07/07 23:24:17 [INFO] raft: pipelining replication to peer {Voter 172.20.0.3:8300 172.20.0.3:8300} 2017/07/07 23:24:17 [INFO] raft: pipelining replication to peer {Voter 172.20.0.4:8300 172.20.0.4:8300} 2017/07/07 23:24:18 [INFO] consul: member 'consul1' joined, marking health alive 2017/07/07 23:24:18 [INFO] consul: member 'consul2' joined, marking health alive 2017/07/07 23:24:18 [INFO] consul: member 'consul3' joined, marking health alive 2017/07/07 23:24:20 [INFO] agent: Synced service 'consul' 2017/07/07 23:24:20 [INFO] agent: Synced service 'messaging-service-kafka' 2017/07/07 23:24:20 [INFO] agent: Synced service 'messaging-service-zookeeper' $ curl http://127.0.0.1:8500/v1/catalog/service/consul curl: (52) Empty reply from server dig @127.0.0.1 -p 8600 consul.service.consul ; <<>> DiG 9.8.3-P1 <<>> @127.0.0.1 -p 8600 consul.service.consul ; (1 server found) ;; global options: +cmd ;; connection timed out; no servers could be reached $ dig @127.0.0.1 -p 8600 messaging-service-kafka.service.consul ; <<>> DiG 9.8.3-P1 <<>> @127.0.0.1 -p 8600 messaging-service-kafka.service.consul ; (1 server found) ;; global options: +cmd ;; connection timed out; no servers could be reached 

我也无法让我的服务通过HTTP API注册; 上面显示的那些是在容器启动时使用configuration脚本注册的。

这是我docker-compose.yml

 version: '2' services: consul1: image: "consul:latest" container_name: "net-sci_discovery-service_consul_1" hostname: "consul1" ports: - "8400:8400" - "8500:8500" - "8600:8600" volumes: - ./etc/consul.d:/etc/consul.d command: "agent -server -ui -bootstrap-expect 3 -config-dir=/etc/consul.d -bind=0.0.0.0" consul2: image: "consul:latest" container_name: "net-sci_discovery-service_consul_2" hostname: "consul2" command: "agent -server -join=consul1" links: - "consul1" consul3: image: "consul:latest" container_name: "net-sci_discovery-service_consul_3" hostname: "consul3" command: "agent -server -join=consul1" links: - "consul1" 

我对docker和领事都相对陌生。 我浏览过网页,上面的选项是我对所需内容的理解。 任何有关前进的build议都会受到欢迎。

编辑:

docker container ps -all结果:

 $ docker container ps --all CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e0a1c3bba165 consul:latest "docker-entrypoint..." 38 seconds ago Up 36 seconds 8300-8302/tcp, 8500/tcp, 8301-8302/udp, 8600/tcp, 8600/udp net-sci_discovery-service_consul_3 7f05555e81e0 consul:latest "docker-entrypoint..." 38 seconds ago Up 36 seconds 8300-8302/tcp, 8500/tcp, 8301-8302/udp, 8600/tcp, 8600/udp net-sci_discovery-service_consul_2 9e2dedaa224b consul:latest "docker-entrypoint..." 39 seconds ago Up 38 seconds 0.0.0.0:8400->8400/tcp, 8301-8302/udp, 0.0.0.0:8500->8500/tcp, 8300-8302/tcp, 8600/udp, 0.0.0.0:8600->8600/tcp net-sci_discovery-service_consul_1 27b34c5dacb7 messagingservice_kafka "start-kafka.sh" 3 hours ago Up 3 hours 0.0.0.0:9092->9092/tcp net-sci_messaging-service_kafka 0389797b0b8f wurstmeister/zookeeper "/bin/sh -c '/usr/..." 3 hours ago Up 3 hours 22/tcp, 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp net-sci_messaging-service_zookeeper 

编辑:

更新了docker-compose.yml以包含端口的长格式:

 version: '3.2' services: consul1: image: "consul:latest" container_name: "net-sci_discovery-service_consul_1" hostname: "consul1" ports: - target: 8400 published: 8400 mode: host - target: 8500 published: 8500 mode: host - target: 8600 published: 8600 mode: host volumes: - ./etc/consul.d:/etc/consul.d command: "agent -server -ui -bootstrap-expect 3 -config-dir=/etc/consul.d -bind=0.0.0.0 -client=127.0.0.1" consul2: image: "consul:latest" container_name: "net-sci_discovery-service_consul_2" hostname: "consul2" command: "agent -server -join=consul1" links: - "consul1" consul3: image: "consul:latest" container_name: "net-sci_discovery-service_consul_3" hostname: "consul3" command: "agent -server -join=consul1" links: - "consul1" 

在Consul Web Gui页面中 ,确保已经启动了带有-ui参数的代理。

UI可以在与HTTP API相同的端口上的/ uipath中使用。
默认情况下,这是http:// localhost:8500 / ui

我看到8500映射到广播(0.0.0.0)您的主机。

也检查(如在这个答案 ),如果client_addr可以帮助(至less为​​了testing)