- 浏览: 2551007 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Docker Swarm 2020(1)Simply Install and Use Swarm
Check my Docker
> docker --version
Docker version 19.03.8, build afacb8b
Swarm Manager - rancher-home
Swarm Worker - rancher-worker1
Swarm Worker - rancher-worker2
Some useful ports:
2377 - cluster management
7946 - node to node
4789 - overlay network
On rancher-home
> docker swarm init --advertise-addr 192.168.56.110
Swarm initialized: current node (st1b4xuylrj6mm5oggsk6hp04) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
If I forget about the token information just in case
> docker swarm join-token worker
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
> docker info
Swarm: active
NodeID: st1b4xuylrj6mm5oggsk6hp04
Is Manager: true
ClusterID: linol1nuatvwjbvquh1fg7x8h
Managers: 1
Nodes: 1
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
Add the worker node to the swarm cluster
On rancher-worker1
> docker --version
Docker version 19.03.8, build afacb8b
Join the cluster
> docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
On rancher-worker2
> docker --version
Docker version 19.03.8, build afacb8b
> docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
On the manager machine, we can see all the nodes
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
ccr3520glvgpyg7dn1zbkr8zg rancher-worker2 Ready Active 19.03.8
Remove the node from cluster
> docker swarm leave
Node left the swarm.
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
ccr3520glvgpyg7dn1zbkr8zg rancher-worker2 Down Active 19.03.8
Remove it from the manager
> docker node rm --force ccr3520glvgpyg7dn1zbkr8zg
ccr3520glvgpyg7dn1zbkr8zg
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
Manager and Deploy Service
Create a simple service
> docker service create --replicas 1 --name helloworld alpine ping docker.com
m45as37skje2gts6t6curew77
overall progress: 1 out of 1 tasks
1/1: running [==================================================>]
verify: Service converged
List the service
> docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
m45as37skje2 helloworld replicated 1/1 alpine:latest
Check the detail
> docker service inspect --pretty helloworld
ID: m45as37skje2gts6t6curew77
Name: helloworld
Service Mode: Replicated
Replicas: 1
Placement:
UpdateConfig:
Parallelism: 1
On failure: pause
Monitoring Period: 5s
Max failure ratio: 0
Update order: stop-first
List the server information
> docker service ps helloworld
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
vo5d6agsy1dw helloworld.1 alpine:latest rancher-home Running Running about a minute ago
Scale the service to 5
> docker service scale helloworld=5
List all the services
> docker service ps helloworld
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
30nlrg5uu4c8 helloworld.1 alpine:latest rancher-home Running Running 3 minutes ago
vo5d6agsy1dw \_ helloworld.1 alpine:latest rancher-home Shutdown Failed 3 minutes ago "task: non-zero exit (255)"
fa9e3qlmcm47 helloworld.2 alpine:latest rancher-worker2 Running Running 30 seconds ago
8mr4dyaga779 helloworld.3 alpine:latest rancher-worker1 Running Running 29 seconds ago
7hbk7w99fo8z helloworld.4 alpine:latest rancher-worker1 Running Running 29 seconds ago
0s7rbd9vwv3r helloworld.5 alpine:latest rancher-home Running Running 35 seconds ago
Remove the service
> docker service rm helloworld
Run and Update the Tomcat Service
> docker service create --replicas 1 --name tomcat-service tomcat:8.5.8
Scale up to 2
> docker service scale tomcat-service=2
Rolling update to tomcat:9.0.33
> docker service update --image tomcat:9.0.33 tomcat-service
Check status
> service ps tomcat-service
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
tei2ojnu7jxk tomcat-service.1 tomcat:9.0.33 rancher-worker2 Running Running 33 seconds ago
p6fg4k7l2jie \_ tomcat-service.1 tomcat:8.5.8 rancher-worker2 Shutdown Shutdown 53 seconds ago
q2it5kmfvois tomcat-service.2 tomcat:9.0.33 rancher-home Running Running 55 seconds ago
e3dnf70mx0km \_ tomcat-service.2 tomcat:8.5.8 rancher-home Shutdown Shutdown about a minute ago
r5kvdoruqdcf tomcat-service.3 tomcat:9.0.33 rancher-worker1 Running Running about a minute ago
33j1j47rk4pn \_ tomcat-service.3 tomcat:8.5.8 rancher-worker1 Shutdown Shutdown about a minute ago
Only see 3 history
> docker swarm update --task-history-limit 3
References:
https://yq.aliyun.com/articles/225511
https://outmanzzq.github.io/2019/06/14/portainer-for-docker-swarm/
https://note.qidong.name/2018/11/docker-swarm/
https://www.jianshu.com/p/df744c4e375e
https://github.com/jasonGeng88/blog/blob/master/201704/docker_swarm.md
https://stackoverflow.com/questions/41705134/how-can-i-remove-shutdown-docker-service-tasks-after-a-rolling-update
Maybe an useful tool
https://github.com/docker/machine
Check my Docker
> docker --version
Docker version 19.03.8, build afacb8b
Swarm Manager - rancher-home
Swarm Worker - rancher-worker1
Swarm Worker - rancher-worker2
Some useful ports:
2377 - cluster management
7946 - node to node
4789 - overlay network
On rancher-home
> docker swarm init --advertise-addr 192.168.56.110
Swarm initialized: current node (st1b4xuylrj6mm5oggsk6hp04) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
If I forget about the token information just in case
> docker swarm join-token worker
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
> docker info
Swarm: active
NodeID: st1b4xuylrj6mm5oggsk6hp04
Is Manager: true
ClusterID: linol1nuatvwjbvquh1fg7x8h
Managers: 1
Nodes: 1
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
Add the worker node to the swarm cluster
On rancher-worker1
> docker --version
Docker version 19.03.8, build afacb8b
Join the cluster
> docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
On rancher-worker2
> docker --version
Docker version 19.03.8, build afacb8b
> docker swarm join --token SWMTKN-1-3ak17tlxe1ljqv8pk7gn1kwrjbz9hzgkn48wh8vu27o39ypjf6-b4mxpq45n2y0i6dpel3hwjlyw 192.168.56.110:2377
On the manager machine, we can see all the nodes
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
ccr3520glvgpyg7dn1zbkr8zg rancher-worker2 Ready Active 19.03.8
Remove the node from cluster
> docker swarm leave
Node left the swarm.
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
ccr3520glvgpyg7dn1zbkr8zg rancher-worker2 Down Active 19.03.8
Remove it from the manager
> docker node rm --force ccr3520glvgpyg7dn1zbkr8zg
ccr3520glvgpyg7dn1zbkr8zg
> docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
st1b4xuylrj6mm5oggsk6hp04 * rancher-home Ready Active Leader 19.03.8
d85e6hmp2saf2xfyiq8nopvkp rancher-worker1 Ready Active 19.03.8
Manager and Deploy Service
Create a simple service
> docker service create --replicas 1 --name helloworld alpine ping docker.com
m45as37skje2gts6t6curew77
overall progress: 1 out of 1 tasks
1/1: running [==================================================>]
verify: Service converged
List the service
> docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
m45as37skje2 helloworld replicated 1/1 alpine:latest
Check the detail
> docker service inspect --pretty helloworld
ID: m45as37skje2gts6t6curew77
Name: helloworld
Service Mode: Replicated
Replicas: 1
Placement:
UpdateConfig:
Parallelism: 1
On failure: pause
Monitoring Period: 5s
Max failure ratio: 0
Update order: stop-first
List the server information
> docker service ps helloworld
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
vo5d6agsy1dw helloworld.1 alpine:latest rancher-home Running Running about a minute ago
Scale the service to 5
> docker service scale helloworld=5
List all the services
> docker service ps helloworld
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
30nlrg5uu4c8 helloworld.1 alpine:latest rancher-home Running Running 3 minutes ago
vo5d6agsy1dw \_ helloworld.1 alpine:latest rancher-home Shutdown Failed 3 minutes ago "task: non-zero exit (255)"
fa9e3qlmcm47 helloworld.2 alpine:latest rancher-worker2 Running Running 30 seconds ago
8mr4dyaga779 helloworld.3 alpine:latest rancher-worker1 Running Running 29 seconds ago
7hbk7w99fo8z helloworld.4 alpine:latest rancher-worker1 Running Running 29 seconds ago
0s7rbd9vwv3r helloworld.5 alpine:latest rancher-home Running Running 35 seconds ago
Remove the service
> docker service rm helloworld
Run and Update the Tomcat Service
> docker service create --replicas 1 --name tomcat-service tomcat:8.5.8
Scale up to 2
> docker service scale tomcat-service=2
Rolling update to tomcat:9.0.33
> docker service update --image tomcat:9.0.33 tomcat-service
Check status
> service ps tomcat-service
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
tei2ojnu7jxk tomcat-service.1 tomcat:9.0.33 rancher-worker2 Running Running 33 seconds ago
p6fg4k7l2jie \_ tomcat-service.1 tomcat:8.5.8 rancher-worker2 Shutdown Shutdown 53 seconds ago
q2it5kmfvois tomcat-service.2 tomcat:9.0.33 rancher-home Running Running 55 seconds ago
e3dnf70mx0km \_ tomcat-service.2 tomcat:8.5.8 rancher-home Shutdown Shutdown about a minute ago
r5kvdoruqdcf tomcat-service.3 tomcat:9.0.33 rancher-worker1 Running Running about a minute ago
33j1j47rk4pn \_ tomcat-service.3 tomcat:8.5.8 rancher-worker1 Shutdown Shutdown about a minute ago
Only see 3 history
> docker swarm update --task-history-limit 3
References:
https://yq.aliyun.com/articles/225511
https://outmanzzq.github.io/2019/06/14/portainer-for-docker-swarm/
https://note.qidong.name/2018/11/docker-swarm/
https://www.jianshu.com/p/df744c4e375e
https://github.com/jasonGeng88/blog/blob/master/201704/docker_swarm.md
https://stackoverflow.com/questions/41705134/how-can-i-remove-shutdown-docker-service-tasks-after-a-rolling-update
Maybe an useful tool
https://github.com/docker/machine
发表评论
-
Stop Update Here
2020-04-28 09:00 315I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 475NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 367Docker Swarm 2020(2)Docker Swar ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 335Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 429Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 435Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 373Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 454VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 384Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 475NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 421Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 336Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 246GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 450GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 326GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 312Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 317Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 292Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 311Serverless with NodeJS and Tenc ... -
Nginx Deal with OPTIONS in HTTP Protocol
2020-02-15 01:33 356Nginx Deal with OPTIONS in HTTP ...
相关推荐
在IT行业中,Python和Docker Swarm的结合是构建可扩展、高效且易于管理的微服务架构的关键技术之一。本文将深入探讨如何利用Python对Docker Swarm集群进行操作API的封装,以及如何创建一个Swarm UI的中间层应用,...
1. **Docker Swarm介绍** Docker Swarm是一种原生的集群管理器,它允许用户将多个Docker主机组成一个单一的虚拟系统,这被称为Swarm模式。在Swarm中,你可以创建服务,这些服务可以自动在可用的节点上扩展或收缩,...
在IT行业中,Docker Swarm、Portainer CE和Nginx是三个非常重要的工具,它们各自在容器编排、管理以及Web服务器领域发挥着关键作用。本文将深入探讨这些组件的功能、用途及其最新版本20.10.17、2.14.2和1.23.1的特点...
Docker Swarm 架构的特性与基本实践 Docker Swarm 架构是一种容器编排工具,提供了强大的集群管理和编排功能。 SwarmKit 是 Docker Engine 内置支持的一种默认实现,自 Docker 1.12 版本开始 unterstützt。通过 ...
1. **初始化集群**:在一台主机上执行 `docker swarm init` 命令,获取加入集群所需的 token。 2. **加入集群**:其他主机使用 `docker swarm join` 命令,用管理节点的 token 和 IP 加入集群。 3. **检查集群状态**...
Docker Swarm是一个强大的容器编排系统,它允许用户在多台主机上管理和部署容器化应用。在这个项目中,我们探讨的是一个使用Docker Remote API、Node.js和D3.js库来实现Docker Swarm集群可视化的工具。这个工具可以...
docker swarm join --token SWMTKN-1-0597678294436-9911783060115-6114479547251323120 192.168.249.130:2377 ``` 查看集群状态,确认所有 Manager 节点的状态。正常情况下,应该只有一个 Leader 节点,其他为 ...
### Docker Swarm 部署教程知识点详解 #### Docker Swarm 简介 Docker Swarm 是 Docker 官方提供的容器集群管理工具,它允许用户将多个 Docker 主机组织成一个集群,并通过一个统一的 API 来管理和调度容器。Swarm ...
将功能作为服务(在Docker Swarm之上)
**Docker Swarm 知识点详解** Docker Swarm 是 Docker 的一种集群管理工具,它允许用户将多个 Docker 主机组织成一个单一的虚拟系统,从而实现容器化应用的集群化部署和管理。以下是对 Docker Swarm 初始化和管理的...
1. **Docker Swarm**:Docker Swarm是Docker的集群管理工具,它将多个Docker宿主机转换为一个单一的虚拟系统,允许用户在一个分布式系统上进行服务部署和管理。在本场景中,Docker Swarm被用来部署Spring Cloud应用...
docker swarm部署分布式微服务编排文件示例
Linux运维-运维课程MP4频-05容器-69dockerswarm网络存储卷-nfs准备.mp4
ansible-dockerswarm, 基于"Swarm Mode" 和Ansible的Docker 引擎 Ansible角色:Docker 群 在 Docker/centos和 debian/ubuntu服务器上使用新的Docker"发动机模式群"( https://docs.docker.com/engine/swarm/ ) 建立集
使用单个命令,您可以将Mongos , Config和Data副本集部署到Docker Swarm上,形成一个高可用性的MongoDB集群,该集群能够在不中断服务的情况下承受多个节点的故障。 Docker堆栈由两个MongoDB副本集,两个Mongos实例...
本文介绍了docker swarm 集群故障与异常详解,分享给大家,具体如下: 在上次遭遇 docker swarm 集群故障后,我们将 docker 由 17.10.0-ce 升级为最新稳定版 docker 17.12.0-ce 。 前天晚上22:00之后集群中的2个...