集群容器管理之swarm ---集群部署

集群部署及节点管理

使用swarm前提: Docker版本1.12+

集群节点之间保证TCP 2377、TCP/UDP 7946和UDP 4789端口通信

节点规划: 操作系统:centos7.4.1708

管理节点:192.168.3.245  node1

工作节点:192.168.3.244

工作节点:192.168.3.246

管理节点初始化swarm: docker swarm init --advertise-addr 192.168.3.245

工作节点加入swarm: docker swarm join --token SWMTKN-1-XXX 192.168.3.245:2377

cat /etc/yum.repos.d/docker.repo
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

  

#curl -sSL https://get.docker.com/ | sh

# systemctl start docker

# systemctl enable docker

# curl -L https://get.daocloud.io/docker/compose/releases/download/1.20.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

# docker-compose -v
docker-compose version 1.20.1, build 5d8c71b

[root@node1 ~]# docker swarm init --advertise-addr 192.168.3.245
Swarm initialized: current node (72664vnxwv9efmib5lr9rli3j) is now a manager.

To add a worker to this swarm, run the following command:

docker swarm join \
--token SWMTKN-1-0blcl3t4a82sutk6dmj9otdjvr5t1y9tklcx624izcvab38vo8-8yvuv3p8k5yg8h87ka6e3h3o0 \
192.168.3.245:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

集群容器管理之swarm  ---集群部署

[root@node2 ~]# docker swarm join --token SWMTKN-1-0blcl3t4a82sutk6dmj9otdjvr5t1y9tklcx624izcvab38vo8-8yvuv3p8k5yg8h87ka6e3h3o0 192.168.3.245:2377

[root@node3 ~]# docker swarm join --token SWMTKN-1-0blcl3t4a82sutk6dmj9otdjvr5t1y9tklcx624izcvab38vo8-8yvuv3p8k5yg8h87ka6e3h3o0 192.168.3.245:2377

集群容器管理之swarm  ---集群部署

[root@node1 ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
72664vnxwv9efmib5lr9rli3j * node1 Ready Active Leader
odtu70p5unyiy3hvowbraw2lj node3 Ready Active
zhg2isim7fj2osyvg7x7yls0i node2 Ready Active

集群容器管理之swarm  ---集群部署

[root@node1 ~]# docker node --help

Usage: docker node COMMAND

Manage Swarm nodes

Options:
--help Print usage

Commands:
demote Demote one or more nodes from manager in the swarm
inspect Display detailed information on one or more nodes
ls List nodes in the swarm
promote Promote one or more nodes to manager in the swarm
ps List tasks running on one or more nodes, defaults to current node
rm Remove one or more nodes from the swarm
update Update a node

Run 'docker node COMMAND --help' for more information on a command.

[root@node1 ~]# docker node inspect --pretty node1
ID: 72664vnxwv9efmib5lr9rli3j
Hostname: node1
Joined at: 2018-03-31 00:12:44.776269654 +0000 utc
Status:
State: Ready
Availability: Active
Address: 127.0.0.1
Manager Status:
Address: 192.168.3.245:2377
Raft Status: Reachable
Leader: Yes
Platform:
Operating System: linux
Architecture: x86_64
Resources:
CPUs: 4
Memory: 7.639 GiB
Plugins:
Network: bridge, host, macvlan, null, overlay
Volume: local
Engine Version: 1.13.1

[root@node1 ~]# docker node inspect --pretty node2
ID: zhg2isim7fj2osyvg7x7yls0i
Hostname: node2
Joined at: 2018-03-31 00:14:47.092619115 +0000 utc
Status:
State: Ready
Availability: Active
Address: 192.168.3.244
Platform:
Operating System: linux
Architecture: x86_64
Resources:
CPUs: 4
Memory: 7.639 GiB
Plugins:
Network: bridge, host, macvlan, null, overlay
Volume: local
Engine Version: 1.13.1

[root@node1 ~]# docker node inspect --pretty node3
ID: odtu70p5unyiy3hvowbraw2lj
Hostname: node3
Joined at: 2018-03-31 00:14:49.644601659 +0000 utc
Status:
State: Ready
Availability: Active
Address: 192.168.3.246
Platform:
Operating System: linux
Architecture: x86_64
Resources:
CPUs: 4
Memory: 7.639 GiB
Plugins:
Network: bridge, host, macvlan, null, overlay
Volume: local
Engine Version: 1.13.1

上一篇:哪个HTML5内建对象用于在画布上绘制?()


下一篇:【Problem】前端项目运行:Module build failed:Error Node Sass does not yet support my current environmen