构建集群
实验环境:rhel7.3
test1: 172.25.52.11 主节点
test2: 172.25.52.22 辅节点
test3: 172.25.52.33 辅节点
实验:
(1).搭建实验环境
做此实验的前提是真机已经完成了证书的制作
[root@test1 ~]# ls
anaconda-ks.cfg
docker-engine-17.03.1.ce-1.el7.centos.x86_64.rpm
docker-engine-selinux-17.03.1.ce-1.el7.centos.noarch.rpm
[root@test1 ~]# yum install *
[root@test1 ~]# systemctl start docker
[root@test1 ~]# yum install -y bash-*
[root@test1 ~]# docker swarm init
Swarm initialized: current node (534lg9252rj3w8s88o0lb8kkz) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-4331clm1g9imylu1ymt8lgg04ou64wxrnjmnacc9tu3cu96340-294r7jtbu5rz4xpocyxhb89ib \
172.25.52.11:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
[root@test2 ~]# ls
anaconda-ks.cfg
docker-engine-17.03.1.ce-1.el7.centos.x86_64.rpm
docker-engine-selinux-17.03.1.ce-1.el7.centos.noarch.rpm
[root@test2 ~]# yum install -y *
[root@test2 ~]# systemctl start docker
[root@test2 ~]# docker swarm join \
> --token SWMTKN-1-4331clm1g9imylu1ymt8lgg04ou64wxrnjmnacc9tu3cu96340-294r7jtbu5rz4xpocyxhb89ib \
> 172.25.52.11:2377
This node joined a swarm as a worker.
[root@test3 ~]# ls
anaconda-ks.cfg
docker-engine-17.03.1.ce-1.el7.centos.x86_64.rpm
docker-engine-selinux-17.03.1.ce-1.el7.centos.noarch.rpm
[root@test3 ~]# yum install * -y
[root@test3 ~]# systemctl start docker
[root@test3 ~]# docker swarm join \
> --token SWMTKN-1-4331clm1g9imylu1ymt8lgg04ou64wxrnjmnacc9tu3cu96340-294r7jtbu5rz4xpocyxhb89ib \
> 172.25.52.11:2377
This node joined a swarm as a worker.
测试:
[root@test1 ~]# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
534lg9252rj3w8s88o0lb8kkz * test1 Ready Active Leader
89</