以下操作均在root用户下,其他用户请加上sudo
机器列表:
Name | Role | Cpu | Memory | Ip |
---|---|---|---|---|
docker1 | manager | 4 | 8.2 GB | 192.168.1.101 |
docker2 | worker | 4 | 8.2 GB | 192.168.1.102 |
分别进行linux安装docker
完成镜像加速配置即可,后续不用继续进行
初始化集群
注意所有节点docker 服务必须已启动
- 在manager 节点上执行
docker swarm init --advertise-addr 192.168.1.101
- 结果
Swarm initialized: current node (oqela4wtpa9m7e8a6zi9k9rbl) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-03md8tqw24sd0tbxkyqxmiay5nixniax9c301f49qjorhsj069-44eeph3lldj3lopzk7tiiv1ve 192.168.1.101:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
- 在worker节点上运行
docker swarm join --token SWMTKN-1-4ilbka9hoz58wapezioxy7pnaq0rbhucokrzl7joukhibwsf3g-0h7k726dvpmftzu4rij88f7lc 192.168.1.101:2377
- 结果
This node joined a swarm as a worker.
- 验证
## manager节点运行命令。
docker node ls
## 结果如下
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
x2n8p4qly9xkhpul49b96bx60 * docker1 Ready Active Leader 18.09.6-ce
b0p8o0vee21pf9nijcvoy0g72 docker2 Ready Active 18.09.6-ce
部署GUI
docker service create --name portainer --publish 9000:9000 --constraint 'node.role == manager' --mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock portainer/portainer -H unix:///var/run/docker.sock
部署可视化
docker service create --name=viz --publish=8088:8080/tcp --constraint=node.role==manager --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock manomarks/visualizer
验证
首次打开会提示创建管理员账户
- open http://192.168.1.101:8088或者点击上个页面中
Go to cluster visualizer
网友评论