服务器:
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就行了
具体搭建过程请看