伺服器:
192.168.99.100 centos-node1
192.168.99.101 centos-node2
192.168.99.102 centos-node3
叢集資訊:
etc伺服器: 192.168.99.100:2379
swarm manage: 192.168.99.101:2376
在所有的機器上安裝dokcer
在centos-node1 上docker pull ystyle/etcd
(和quay.io/coreos/etcd:v2.2.5上的是一樣的。)
在所有機器上dokcer pull swarm
k-v
資料庫在centos-node1上執行:
export HOSTIP=192.168.99.100
docker run -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
--name etcd ystyle/etcd \
-name etcd0 \
-advertise-client-urls http://${HOSTIP}:2379,http://${HOSTIP}:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://${HOSTIP}:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://${HOSTIP}:2380 \
-initial-cluster-state new
分別在三個節點執行: 加入叢集
docker run -d swarm join --addr=192.168.99.100:2375 etcd://192.168.99.100:2379/swarm
docker run -d swarm join --addr=192.168.99.101:2375 etcd://192.168.99.100:2379/swarm
docker run -d swarm join --addr=192.168.99.102:2375 etcd://192.168.99.100:2379/swarm
在centos-node2上啟動swarm manage
dokcer run -d -p 2376:2375 swarm manage -H=0.0.0.0:2375 etcd://192.168.99.101:2379/swarm
然後發現不管用叢集執行什麼指令都沒反應, 沒有報錯,pull不成功, images 裡也是空的。
docker info 資訊也很奇怪:
#docker -H tcp://192.168.99.101:2376 info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: swarm/1.1.3
Role: primary
Strategy: spread
Filters: health, port, dependency, affinity, constraint
Nodes: 2
(unknown): 192.168.99.102:2375
└ Status: Pending
└ Containers: 0
└ Reserved CPUs: 0 / 0
└ Reserved Memory: 0 B / 0 B
└ Labels:
└ Error: (none)
└ UpdatedAt: 2016-03-16T14:14:30Z
(unknown): 192.168.99.101:2375
└ Status: Pending
└ Containers: 0
└ Reserved CPUs: 0 / 0
└ Reserved Memory: 0 B / 0 B
└ Labels:
└ Error: (none)
└ UpdatedAt: 2016-03-16T14:14:30Z
Plugins:
Volume:
Network:
Kernel Version: 3.10.0-327.10.1.el7.x86_64
Operating System: linux
Architecture: amd64
CPUs: 0
Total Memory: 0 B
Name: add02820f24f
swarm 節點只能看到兩個
#docker run --rm swarm list etcd://192.168.99.100:2379/swarm
time="2016-03-16T14:19:41Z" level=info msg="Initializing discovery without TLS"
192.168.99.101:2375
192.168.99.102:2375
這是怎麼怎麼回事? 還是我有步驟沒做或遺漏了?
ringa_lee2017-04-24 09:12:06
已解決,主要是連接埠的問題,防火牆裡開放埠就行了,還有就是docker id重複問題直接刪除/etc/docker/key.json文件,重啟docker就行了
具體搭建過程請看