【Linux】Docker swarm集群

1.三台服务器准备 Ubuntu18.04

192.168.0.5 manager

192.168.0.4 node1

192.168.0.8 node2

2.添加以上入/etc/hosts

3.设定hostname

hostnamectl set-hostname manager

hostnamectl set-hostname node1

hostnamectl set-hostname node2

4.分别安装docker

  • wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-19.03.6-3.el7.x86_64.rpm
  • wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
  • wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-19.03.6-3.el7.x86_64.rpm
  • yum install -y docker-ce-cli-19.03.6-3.el7.x86_64.rpm containerd.io-1.2.6-3.3.el7.x86_64.rpm docker-ce-19.03.6-3.el7.x86_64.rpm
  • systemctl start docker

5.分别配置国内源

  • vi /etc/docker/daemon.json
  • {
  • "registry-mirrors": ["http://hub-mirror.c.163.com"]
  • }
  • systemctl daemon-reload
  • systemctl restart docker

6.分别安装criu

  • yum install -y criu

 

 

7.manager节点初始化swarm集群

[root@manager ~]# docker swarm init --advertise-addr 192.168.0.105
Swarm initialized: current node (jy9rsowc1xbiroxvtami7yl18) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-4v55ca4vw1t5gihtiay5pu0qdzpof75km0ke3gsapxlllx4ush-eg1u7serdhg729le2el7h0s17 192.168.0.105:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

8.在node节点执行join加入集群

    docker swarm join --token SWMTKN-1-4v55ca4vw1t5gihtiay5pu0qdzpof75km0ke3gsapxlllx4ush-eg1u7serdhg729le2el7h0s17 192.168.0.105:2377

9.manager节点查看节点

[root@manager ~]# docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
jy9rsowc1xbiroxvtami7yl18 *   manager             Ready               Active              Leader              18.03.1-ce
xpnx8viazr8c0lctvgbsd94up     node1               Ready               Active                                  18.03.1-ce
41pfh71ycle45opuhixoe5w14     node2               Ready               Active                                  18.03.1-ce

 

参考:https://www.cnblogs.com/zhujingzhi/p/9792432.html

posted @ 2020-02-21 22:09    阅读(313)  评论(0编辑  收藏  举报