1 docker swarm 初始化
阿新 • • 發佈:2021-12-08
1 用法
docker swarm init [OPTIONS]
在manager0節點操作
192.168.7.102
[root@manager01 testswarm]# docker swarm init --advertise-addr 192.168.7.102
Swarm initialized: current node (v1ld63hqjtm8bx9z10bbhig5x) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-1znl7nt91ucwz5doyuh53k6bhwihw7ked01804r60zfz8egg5c-5ej7hfjrflos3i4d4d49lfo4h 192.168.7.102:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
將192.168.7.102 作為管理節點
新增其他管理節點,用docker swarm join-token manager 命令獲得
[root@manager01 testswarm]# docker swarm join-token manager To add a manager to this swarm, run the following command: docker swarm join--token SWMTKN-1-1znl7nt91ucwz5doyuh53k6bhwihw7ked01804r60zfz8egg5c-7kr2iheffncoz6fqcj49n4fql 192.168.7.102:2377
在其他管理節點上執行 這個節點則作為管理節點新增進來
[root@node01 ~]# docker swarm join --token SWMTKN-1-1znl7nt91ucwz5doyuh53k6bhwihw7ked01804r60zfz8egg5c-7kr2iheffncoz6fqcj49n4fql 192.168.7.102:2377 This node joined a swarmas a manager.
離開叢集,在要離家的叢集上執行
docker swarm leave -f
準備
其中一臺機器是經理(稱為manager01
),其中兩臺是工人(node01和node02)
192.168.7.102 manager01 192.168.6.9 node01 192.168.6.17 node02
在manager01 執行
[root@manager01 testswarm]# docker swarm init Swarm initialized: current node (shd6lryp0b2frr9ypzbqofdib) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-3bfwjhrg0sjsbrx8dqxez3hdmt38hmj0x18ph0w7prafw9c6fb-5hl8g51f7uimqleq7x9li5ukw 192.168.7.102:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
在 node01 和node02 上分別執行
docker swarm join --token SWMTKN-1-3bfwjhrg0sjsbrx8dqxez3hdmt38hmj0x18ph0w7prafw9c6fb-5hl8g51f7uimqleq7x9li5ukw 192.168.7.102:2377
在manager01 上檢視
[root@manager01 testswarm]# docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION shd6lryp0b2frr9ypzbqofdib * manager01 Ready Active Leader 20.10.11 mzqgkj7ry6hvy3ef54jz83w8t node01 Ready Active 20.10.11 l6btk3f69mojxe2e6aprc9jcr node02 Ready Active 20.10.11
部署