2016-08-08 111 views
2

我有3個虛擬機。他們都有docker 1.12,他們都在centos7上運行。 所有的端口都打開,並且虛擬機的能夠ping海誓山盟 我開始了我的集羣節點無法加入羣集

docker swarm init --advertise-addr 192.168.140.12 

泊塢窗信息給我:

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. 

泊塢窗信息給我:

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

ssh訪問不需要。這些虛擬機之間是否有可能阻止端口2377流量的防火牆? – BMitch

+0

我執行'systemctl disable firewalld'因此防火牆不是我想的問題。 – DenCowboy

+0

當我執行泊塢窗信息時,我看到這個改變sometims:網絡:空橋宿主覆蓋,橋接主機覆蓋null和返回。我的問題是否正常? – DenCowboy

回答

1

我所有的虛擬機的主機名稱分別爲:的localhost.localdomain。 我在每臺服務器上更改/etc/hosts的主機名並重新啓動。 現在我可以創建我的羣集併成功添加節點。

+1

你可以給我一個示例如何修改/ etc/hosts中的主機名 – Kain

0

我有同樣的問題,並通過同步每個工作節點的日期與主節點日期相同解決。

[email protected]$sudo date --set="$([email protected] date)" 

之後,嘗試更新工作節點,它應該工作。

+0

我在所有節點上都有相同的時間,但問題也存在。 – QtRoS

0

如果以下解決方案均未奏效。嘗試在主服務器上禁用防火牆並查看它是否有效。

-1

我有同樣的問題,要做到這一點,你通常不得不使用docker機器的通用驅動程序,但我發現這個驅動程序不能像它應該那樣工作......實際上,docker機器只能使用virtualbox驅動程序在物理機器上,而不是VM和雲驅動程序。

所以,如果你不能這樣做,真的不知道如何,但據我搜索,並沒有找到一個解決方案使用Swarm與遠程主機。

放棄團隊之後,雖然Kubernetes可以工作,但Kubernetes的問題在於它必須用於雲或安裝在VSphere和I上,因此我無法在ESX中使用更多比300 VM ...

2

也許你使用的是一個http代理。

您可以使用以下命令查看dockerd在做什麼。

# strace -Fp `pidof dockerd` 2>&1 |grep -v futex |grep -v epoll_wait |grep -v pselect 
+0

OMG謝謝你!我不知道Docker Swarm節點使用http進行通信(默認端口2377)! 我配置了一個http代理,如下面的鏈接所述,所以「docker swarm join」也使用了這個代理,儘管我的工作人員和我的經理在同一個局域網中。 https://stackoverflow.com/questions/23111631/cannot-download-docker-images-behind-a-proxy#answer-28093517 –

0

正如wenjianhn解釋,請確保您沒有爲搬運工配置HTTP代理你的工作節點上(如描述here)。事實上,Swarm節點通過http進行通信(默認端口2377),因此如果您配置了http代理,它將使用它,即使管理器節點位於您的LAN中。

此外,還要確保沒有防火牆阻止端口2377交通:

[email protected]$ telnet ip-of-manager 2377 

如果您不能打開端口2377 telnet連接,這意味着該端口被防火牆阻止(要麼是工作節點的防火牆,要麼是經理的防火牆)。