主机分配如下,支持双活,中断其中1台,primary会通过consul自动重新选举
10.40.100.141 docker-manager0.venic.com
10.40.100.142 docker-manager1.venic.com
首先在镜像服务器上148上,拉取一个官网 的 consul镜像,方便等下在其它三台上快速启动
# docker pull swarm && docker tag swarm:latest docker-registry.venic.com:5000/swarm:latest
# docker push docker-registry.venic.com:5000/swarm:latest
10.40.100.141上
docker run -d -p 4000:4000 --restart=always --name manager0 docker-registry.venic.com:5000/swarm:latest manage -H :4000 --replication --advertise 10.40.100.141:4000 consul://docker-consul.venic.com:8500
10.40.100.142上
docker run -d -p 4000:4000 --restart=always --name manager1 docker-registry.venic.com:5000/swarm:latest manage -H :4000 --replication --advertise 10.40.100.142:4000 consul://docker-consul.venic.com:8500
在2台机器上执行查看状态,可以看到选举了谁做主
[[email protected] /]# docker -H :4000 info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: swarm/1.2.5
Role: primary
Strategy: spread
Filters: health, port, containerslots, dependency, affinity, constraint
Nodes: 0
Plugins:
Volume:
Network:
Swarm:
NodeID:
Is Manager: false
Node Address:
Security Options:
Kernel Version: 3.10.0-514.2.2.el7.x86_64
Operating System: linux
Architecture: amd64
CPUs: 0
Total Memory: 0 B
Name: 27fbbfe0fae4
Docker Root Dir:
Debug Mode (client): false
Debug Mode (server): false
WARNING: No kernel memory limit support
[[email protected] /]# docker -H :4000 info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: swarm/1.2.5
Role: replica
Primary: 10.40.100.141:4000
Strategy: spread
Filters: health, port, containerslots, dependency, affinity, constraint
Nodes: 0
Plugins:
Volume:
Network:
Swarm:
NodeID:
Is Manager: false
Node Address:
Security Options:
Kernel Version: 3.10.0-514.2.2.el7.x86_64
Operating System: linux
Architecture: amd64
CPUs: 0
Total Memory: 0 B
Name: 716ec5e0ef90
Docker Root Dir:
Debug Mode (client): false
Debug Mode (server): false
WARNING: No kernel memory limit support