[root@swarm01 ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
pxginxl7p0ck7sc6lc3r7yfvg * swarm01 Ready Active Leader 18.09.4
wwjbu34lqg9diney4e4xpes3l swarm02 Ready Active Reachable 18.09.4
0pv07jzs0cf4581q283r1nqp5 swarm03 Ready Active 18.09.4
1
2
3
4
5
环境准备(这里只配置swarm01,其余两个同理)
准备三个docker环境的虚拟机,要求之间具有联通关系
swarm01主机相关操作
hostname swarm01(主机名称命名)
还有可能需要配置静态ip
vim /etc/sysconfig/network-scripts/ifcfg-en33(编辑网络配置文件,名称可能不是这个,具体系统具体对待)
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
[root@swarm01 network-scripts]#
查看集群初始化效果
[root@swarm01 network-scripts]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
2g6592p43eonilcjvivw3ww1f * swarm01 Ready Active Leader 18.09.4
[root@swarm01 network-scripts]#
获取控制节点的token
[root@swarm01 network-scripts]# docker swarm join-token manager
To add a manager to this swarm, run the following command:
拷贝这句话在swarm02上执行
[root@swarm02 ~]# docker swarm join --token SWMTKN-1-2gyvi3dxuyuw9h5red8hty6hu9rvgwsxfmo296e1ajtfln0rsl-3ujqri9fd63dns6v37z9cxd84 192.168.198.131:2377
This node joined a swarm as a manager.
[root@swarm02 ~]#
获取工作节点的token
[root@swarm01 network-scripts]# docker swarm join-token worker
To add a worker to this swarm, run the following command:
拷贝这句话在swarm03执行
[root@swarm03 ~]# docker swarm join --token SWMTKN-1-2gyvi3dxuyuw9h5red8hty6hu9rvgwsxfmo296e1ajtfln0rsl-exsbzi1308n0kstnrizfwqyv5 192.168.198.131:2377
This node joined a swarm as a worker.
[root@swarm03 ~]#