当前位置:网站首页>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
边栏推荐
- 2020-08-20:GO语言中的协程与Python中的协程的区别?
- September 9, 2020: naked writing algorithm: two threads print numbers 1-100 in turn.
- August 18, 2020: introduce Mr process?
- DC-1 target
- 2020-08-15:什么情况下数据任务需要优化?
- Novice guidance and event management system in game development
- How to make characters move
- 汽车维修app开发的好处与功能
- Method of code refactoring -- Analysis of method refactoring
- List to map (split the list according to the key, and the value of the same key is a list)
猜你喜欢

Common mathematical basic formulas of recursive and backtracking algorithms

2020-08-20: the difference between go and python?

大佬们如何在nginx镜像里面增加模块?

Novice guidance and event management system in game development

Characteristics of magnetic memory chip STT-MRAM

September 3, 2020: naked writing algorithm: loop matrix traversal.

南京标志设计,logo设计公司

如何才能快速正确的部署甘特图

2020-08-17: how to solve data skew in detail?
![[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform](/img/3b/00bc81122d330c9d59909994e61027.jpg)
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
随机推荐
汽车维修app开发的好处与功能
The memorandum model of behavior model
Windows 10 蓝牙管理页面'添加蓝牙或其他设备'选项点击无响应的解决方案
The Interpreter pattern of behavior pattern
Characteristics of magnetic memory chip STT-MRAM
1万辆!理想汽车召回全部缺陷车:已发生事故97起,亏损将扩大
非易失性MRAM存储器应用于各级高速缓存
移动端像素适配方案
[learning] interface test case writing and testing concerns
Nonvolatile MRAM memory used in all levels of cache
STM32F030F4P6兼容灵动微MM32F031F4P6
win7 APPCRASH(解决方法)(转)
Stickinengine architecture 11 message queue
How to make characters move
10000! Ideal car recalls all defective cars: 97 accidents have occurred and losses will be expanded
List to map (split the list according to the key, and the value of the same key is a list)
How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?
To solve the problem that the data interface is not updated after WPF binding set
Countdown | 2020 PostgreSQL Asia Conference - agenda arrangement of Chinese sub Forum
Hdu3974 assign the task segment tree DFS order