我有3个VM。它们都有docker 1.12,它们运行在centos7上。 所有端口都打开,vm可以互相ping通 我用
开始了我的集群docker swarm init --advertise-addr 192.168.140.12
Docker信息告诉我:
Swarm: active
NodeID: 0drcj2nku1mv8t16fxva48edxx
Is Manager: true
ClusterID: cchn0yzospwoe1h9f55d7omxx
Managers: 1
Nodes: 1
现在我尝试将节点(其他虚拟机)加入群集。我使用了启动我的经理后推荐的命令。
docker swarm join \
--token SWMTKN-1-48ythur5k6ckkz90ttlprw37p9z3ldclws51qirw5wdyfmvevr-3sb2t66b2fj6e4dhmfo1vavxx \
192.168.140.12:2377
但我得到了:
Error response from daemon: Timeout was reached before node was joined. Attempt to join the cluster will continue in the background. Use "docker info" command to see the current swarm status of your node.
Docker信息告诉我:
Swarm: pending
NodeID:
Error: rpc error: code = 1 desc = context canceled
Is Manager: false
Node Address: 192.168.140.14
关于群集管理员:
# netstat -tulpn | grep docker
tcp6 0 0 :::2377 :::* LISTEN 1602/dockerd
tcp6 0 0 :::7946 :::* LISTEN 1602/dockerd
tcp6 0 0 :::8080 :::* LISTEN 3398/docker-proxy
tcp6 0 0 :::32768 :::* LISTEN 3199/docker-proxy
tcp6 0 0 :::32769 :::* LISTEN 3219/docker-proxy
tcp6 0 0 :::32770 :::* LISTEN 3341/docker-proxy
tcp6 0 0 :::32771 :::* LISTEN 3436/docker-proxy
tcp6 0 0 :::2375 :::* LISTEN 1602/dockerd
udp6 0 0 :::7946 :::* 1602/dockerd
如何调试此问题或者我忘记执行某些重要步骤?服务器是否需要相互ssh访问?感谢
登录节点:
Aug 8 09:50:24 localhost dockerd: time="2016-08-08T09:50:24.393432145-04:00" level=error msg="Handler for POST /v1.24/swarm/leave returned error: This node is not part of swarm"
Aug 8 09:51:01 localhost su: (to root) worker1 on pts/1
Aug 8 09:51:34 localhost dockerd: time="2016-08-08T09:51:34.384408514-04:00" level=error msg="Handler for POST /v1.24/swarm/join returned error: Timeout was reached before node was joined. Attempt to join the cluster will continue in the background. Use \"docker info\" command to see the current swarm status of your node."
Aug 8 09:51:40 localhost su: (to root) worker1 on pts/1
Aug 8 09:52:47 localhost dhclient[1277]: DHCPREQUEST on eno16777736 to 192.168.140.254 port 67 (xid=0x11f8fba8)
Aug 8 09:52:47 localhost dhclient[1277]: DHCPACK from 192.168.140.254 (xid=0x11f8fba8)
Aug 8 09:52:47 localhost NetworkManager[953]: <info> address 192.168.140.13
Aug 8 09:52:47 localhost NetworkManager[953]: <info> plen 24 (255.255.255.0)
Aug 8 09:52:47 localhost NetworkManager[953]: <info> gateway 192.168.140.2
Aug 8 09:52:47 localhost NetworkManager[953]: <info> server identifier 192.168.140.254
Aug 8 09:52:47 localhost NetworkManager[953]: <info> lease time 1800
Aug 8 09:52:47 localhost NetworkManager[953]: <info> nameserver '192.168.140.2'
Aug 8 09:52:47 localhost NetworkManager[953]: <info> domain name 'localdomain'
Aug 8 09:52:47 localhost NetworkManager[953]: <info> (eno16777736): DHCPv4 state changed bound -> bound
Aug 8 09:52:47 localhost dbus[878]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
Aug 8 09:52:47 localhost dbus-daemon: dbus[878]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
Aug 8 09:52:47 localhost systemd: Starting Network Manager Script Dispatcher Service...
Aug 8 09:52:47 localhost dhclient[1277]: bound to 192.168.140.13 -- renewal in 713 seconds.
Aug 8 09:52:47 localhost dbus[878]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Aug 8 09:52:47 localhost dbus-daemon: dbus[878]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Aug 8 09:52:47 localhost nm-dispatcher: Dispatching action 'dhcp4-change' for eno16777736
Aug 8 09:52:47 localhost systemd: Started Network Manager Script Dispatcher Service.
有时警告:
level=warning msg="failed to retrieve remote root CA certificate: rpc error: code = 1 desc = context canceled
答案 0 :(得分:3)
也许您使用的是http代理。
您可以使用以下命令查看dockerd正在做什么。
# strace -Fp `pidof dockerd` 2>&1 |grep -v futex |grep -v epoll_wait |grep -v pselect
答案 1 :(得分:1)
我所有虚拟机的主机名都是:localhost.localdomain。
我在每个服务器上更改了/etc/hosts
中的主机名并重新启动。
现在,我能够创建我的群集群并成功添加节点。
答案 2 :(得分:1)
正如wenjianhn所解释的那样,请确保您没有在您的worker-node上配置Docker的http代理(如here所述)。实际上,Swarm节点通过HTTP进行通信(默认端口2377);因此,如果您配置了http-proxy,您的工作节点将使用配置的http-proxy,即使管理器节点位于您的LAN中也是如此。
此外,请确保没有防火墙阻止端口2377上的流量:
user@workernode$ telnet ip-of-manager 2377
如果您无法在端口2377上打开telnet连接,则表示此端口被防火墙阻止(工作节点的防火墙,或者是管理员的防火墙)。 / p>
答案 3 :(得分:0)
我遇到了同样的问题,并通过同步每个工作节点与主节点日期相同的日期来解决。
pi@workernode$sudo date --set="$(username@masternode date)"
之后,尝试更新worker节点,它应该可以工作。
答案 4 :(得分:0)
如果以下解决方案均无效。尝试在主服务器上禁用防火墙,看看它是否有效。
答案 5 :(得分:0)
我有类似的问题。我检查了是否没有配置代理,也没有防火墙,但是“ docker swarm join”无效。我注意到“ docker info”中列出了不再存在的管理器。 “ docker node ls”没有显示任何异常。
最终,我通过在“ docker swarm join”寻址的节点上执行“ service docker restart”解决了我的问题。显然,docker守护程序内部的某些内部记帐不同步。