当前位置:网站首页>8.Swarm创建维护和水平扩展Service
8.Swarm创建维护和水平扩展Service
2020-11-06 22:33:00 【太猪-YJ】
创建service
docker service create --name demo busybox sh -c "while true;do sleep 3600;done"
查看service,此时只有一个副本 replicas 1/1
docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
qbpicc7rvm49 demo replicated 1/1 busybox:latest
查看service详细信息
docker service ps demo
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
nlgymox7pt59 demo.1 busybox:latest localhost.localdomain Running Running about a minute ago
设置service副本数为5
docker service scale demo=5
再次查看service,次数副本数 replicas 5/5
docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
qbpicc7rvm49 demo replicated 5/5 busybox:latest
发现启动了5个service副本,分布在3个worker node上
docker service ps demo
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
nlgymox7pt59 demo.1 busybox:latest localhost.localdomain Running Running 6 minutes ago
wjnahehppsvu demo.2 busybox:latest localhost.localdomain Running Running 2 minutes ago
ogojxvke7t9b demo.3 busybox:latest localhost.localdomain Running Running 3 minutes ago
dweehxcozoku demo.4 busybox:latest localhost.localdomain Running Running 2 minutes ago
1ix2fdj39m03 demo.5 busybox:latest localhost.localdomain Running Running 2 minutes ago
我们去其中一个worker node上删除一个service副本
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a8661d168e78 busybox:latest "sh -c 'while true;d…" 4 minutes ago Up 4 minutes demo.3.ogojxvke7t9bza62haisw3as2
2f800599e183 busybox:latest "sh -c 'while true;d…" 8 minutes ago Up 8 minutes demo.1.nlgymox7pt59vrdj7lfjk8e4b
docker rm -f 2f800599e183
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a8661d168e78 busybox:latest "sh -c 'while true;d…" 38 minutes ago Up 38 minutes demo.3.ogojxvke7t9bza62haisw3as2
然后再回到swarm manager节点上,查看service副本数变成4个,但是短暂时间后,又变回5个
docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
qbpicc7rvm49 demo replicated 5/5 busybox:latest
再查看demo副本详细信息,demo.1确实是被删除过,但是在swarm manager的管理下,某个workder node又开启了一个service的副本,保证service的副本数是有效的。
docker service ps demo
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
z5vhrcrec1d4 demo.1 busybox:latest localhost.localdomain Running Running 6 minutes ago
nlgymox7pt59 \_ demo.1 busybox:latest localhost.localdomain Shutdown Failed 6 minutes ago "task: non-zero exit (137)"
wjnahehppsvu demo.2 busybox:latest localhost.localdomain Running Running 44 minutes ago
ogojxvke7t9b demo.3 busybox:latest localhost.localdomain Running Running 44 minutes ago
dweehxcozoku demo.4 busybox:latest localhost.localdomain Running Running 44 minutes ago
1ix2fdj39m03 demo.5 busybox:latest localhost.localdomain Running Running 44 minutes ago
我们要删除service,需要在swarm manager节点上
docker service rm demo
demo
docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
版权声明
本文为[太猪-YJ]所创,转载请带上原文链接,感谢
https://my.oschina.net/xiaoyoung/blog/4700188
边栏推荐
- Common mathematical basic formulas of recursive and backtracking algorithms
- Stm32f030c6t6 compatible to replace mm32spin05pf
- Two dimensional code location and alarm system of Expressway
- The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud
- ado.net and asp.net The relationship between
- In 2020, how can wechat seal numbers be quickly lifted?
- 2020-08-19: what mechanism does TCP ensure reliability?
- Application layer software development Godfather teaches you how to refactor, senior programmers must professional skills
- Git remote library rollback specified version
- August 30, 2020: naked write algorithm: the nearest common ancestor of two nodes in a binary tree.
猜你喜欢
图像处理工具包ImagXpress使用教程,如何查看事件
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
Exclusive interview of guests at | 2020 PostgreSQL Asia Conference: Wang Tao
Utility class functions (continuous update)
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?
Characteristics of magnetic memory chip STT-MRAM
The 4th China BIM (digital construction) manager Summit Forum will be held in Hangzhou in 2020
[self taught unity2d legendary game development] map editor
C and C / C + + mixed programming series 5 - GC collaboration of memory management
随机推荐
Git SSH bad permissions
How to deploy Gantt chart quickly and correctly
How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?
消防器材RFID固定资产管理系统
Google browser realizes video playback acceleration function
In 2020, how can wechat seal numbers be quickly lifted?
JVM class loading mechanism
条形码识别器Dynamsoft Barcode Reader v7.5全新上线!
2020-08-29: process thread differences, in addition to the inclusion relationship, the underlying details?
The essence of transaction and the principle of deadlock
The isolation level of transaction and its problems
Stm32f030k6t6 compatible replacement smart mm32f031k6t6
New features of vue3
2020-08-20: the difference between go and python?
Event monitoring problem
The method of local search port number occupation in Windows system
Common syntax corresponding table of mongodb and SQL
Code generator plug-in and creator preform file analysis
The Interpreter pattern of behavior pattern
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification