docker+ swarm + etcd 集群的问题
高洛峰
高洛峰 2017-04-24 09:10:06
0
1
679

环境信息

服务器:

  • 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

安装etcd 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

这是怎么怎么回事? 还是我有步骤没做或漏了?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
左手右手慢动作

It has been solved. The main problem is the port. Just open the port in the firewall. There is also the problem of duplicate docker id. Just delete the /etc/docker/key.json file and restart docker.
Please see the specific construction process

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template