Docker学习(12)----搭建Docker+Swarm+consul+registrator+shipyard管理平台

操作环境

CentOS Linux release 7.4.1708 (Core) 

Docker version 1.12.6, build 85d7426/1.12.6

网络拓扑图:

Docker学习(12)----搭建Docker+Swarm+consul+registrator+shipyard管理平台_第1张图片

操作步骤

部署Docker

1.分别在Docker-Manager以及Docker-Node-1上部署Docker

#yum -y install docker

2.修改/etc/sysconfig/docker配置文件如下,添加OPTIONS参数:

# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi

# Do not add registries in this file anymore. Use /etc/containers/registries.conf
# from the atomic-registries package.
#

# docker-latest daemon can be used by starting the docker-latest unitfile.
# To use docker-latest client, uncomment below lines
#DOCKERBINARY=/usr/bin/docker-latest
#DOCKERDBINARY=/usr/bin/dockerd-latest
#DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest
#DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest

######Setting by myself############
OPTIONS='-H 0.0.0.0:2375 -H unix:///var/run/docker.sock'

3.使用阿里云的加速器

[root@docker-manager ~]# vi /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://wghlmi3i.mirror.aliyuncs.com"]
}

4.启动docker

#systemctl daemon-reload
#systemctl restart docker
#systemctl enable docker

初始化swarm

1.在Docker-Manager端执行

#docker swarm init --advertise-addr 10.10.200.226

而后会提示在swarm node端执行命令docker swarm join     --token SWMTKN-1-1v2hktdyr80t6abbg9suaez8sv7bgalu0tfrfe6f83mgs8k43m-980hsux03oxjn6h0f17xjzngm     10.10.200.226:2377

2. 在Docker-Node-1端执行上述命令加入Swarm Cluster中

#docker swarm join     --token SWMTKN-1-1v2hktdyr80t6abbg9suaez8sv7bgalu0tfrfe6f83mgs8k43m-980hsux03oxjn6h0f17xjzngm     10.10.200.226:2377

3.在Docker-Manager端查看swarm node

[root@docker-manager ~]# docker node ls
ID                           HOSTNAME        STATUS  AVAILABILITY  MANAGER STATUS
9txkm6wwyj7u5o8qm72doh9u8 *  docker-manager  Ready   Active        Leader
aawwqsazinyns2y56kqp7owwv    docker-node-1   Ready   Active        

部署Consul、shipyard、registrator

1.在Docker-Manager节点部署Consul

#docker run -d --restart=always -p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -p 8600:53 -p 8600:53/udp -h manager-node  --name=consul progrium/consul -server -bootstrap -ui-dir=/ui -advertise 10.10.200.226 -client 0.0.0.0

2.在Docker-Node-1阶段部署Consul

#docker run -d --restart=always -p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -h node1 --name=consul progrium/consul -server  -join 10.10.200.226 -advertise 10.10.200.227 -client 0.0.0.0


3.在Docker-Manager节点部署shipyard、registrator

部署rethinkdb

#docker run -d --restart=always --name shipyard-rethinkdb rethinkdb

部署shipyard-swarm-manager

#docker run -d -p 3375:3375 --restart=always --name shipyard-swarm-manager swarm:latest manage --host tcp://0.0.0.0:3375 consul://10.10.200.226:8500

部署shipyard-swarm-agent

#docker run -d --restart=always --name shipyard-swarm-agent swarm:latest join --addr 10.10.200.226:2375 consul://10.10.200.226:8500

部署registrator

#docker run -d --restart=always --name=registrator --net=host -v /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator -ip 10.10.200.226 consul://10.10.200.226:8500

4.在Docker-Node-1节点部署shipyard、registrator

部署Shipyard-swarm-agent

#docker run -d --restart=always --name shipyard-swarm-agent swarm:latest join --addr 10.10.200.227:2375 consul://10.10.200.226:8500

部署registrator

#docker run -d --restart=always --name=registrator --net=host -v /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator -ip 10.10.200.227 consul://10.10.200.227:8500

5.在Docker-Manager节点上启动Shipyard-Controller

#docker run -d --restart=always --name shipyard-controller --link shipyard-rethinkdb:rethinkdb --link shipyard-swarm-manager:swarm -p 8080:8080 shipyard/shipyard:latest    server -d tcp://swarm:3375

启动shipyard-controller后,可以通过http://10.10.200.226:8080访问shipyard web,用户名/密码为admin/shipyard

Docker学习(12)----搭建Docker+Swarm+consul+registrator+shipyard管理平台_第2张图片



Docker学习(12)----搭建Docker+Swarm+consul+registrator+shipyard管理平台_第3张图片

Docker学习(12)----搭建Docker+Swarm+consul+registrator+shipyard管理平台_第4张图片

Docker学习(12)----搭建Docker+Swarm+consul+registrator+shipyard管理平台_第5张图片

至此,就完成了Centos7下Docker+swarm+consul+registrator+shipyard的部署。

你可能感兴趣的:(docker)