一共三台主机
192.168.19.4
192.168.19.5
192.168.19.6
192.168.19.4
设置主机名
[root@centos redis-cluster]# hostnamectl set-hostname manager
[root@centos redis-cluster]#
初始化swarm集群
[root@centos redis-cluster]# docker swarm init
Swarm initialized: current node (lfjk87d0pguk7tkgoj69fu9nq) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-526bzo5skkyhb509xk6mpbmsm5wepnbt12clg68ozr0n93emtf-adqinc1qrub0uyti0683hjqvw 192.168.19.4:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
获取加入令牌
[root@centos redis-cluster]# docker swarm join-token manager
To add a manager to this swarm, run the following command:
docker swarm join --token SWMTKN-1-526bzo5skkyhb509xk6mpbmsm5wepnbt12clg68ozr0n93emtf-b1r2kkd4ccic3jpdlpsh8sjlq 192.168.19.4:2377
[root@centos redis-cluster]# docker swarm join-token worker
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-526bzo5skkyhb509xk6mpbmsm5wepnbt12clg68ozr0n93emtf-adqinc1qrub0uyti0683hjqvw 192.168.19.4:2377
[root@centos redis-cluster]#
查询集群的所有节点
[root@centos redis-cluster]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
lfjk87d0pguk7tkgoj69fu9nq * manager Ready Active Leader 20.10.11
192.168.19.5
设置机器名