当前位置:网站首页>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
边栏推荐
- Cloudquery v1.2.0 release
- Empty test suite appears in JUnit test
- ImageMagick - 添加水印
- August 18, 2020: introduce Mr process?
- List to map (split the list according to the key, and the value of the same key is a list)
- The Interpreter pattern of behavior pattern
- VARCHART XGantt入门教程
- Common syntax corresponding table of mongodb and SQL
- #JVM 类加载机制
- Jenkins installation and deployment process
猜你喜欢

迅为iMX6开发板-设备树内核-menuconfig的使用

Stm32f030f4p6 compatible with smart micro mm32f031f4p6

JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M

RFID fixed assets management system for fire equipment

The method of local search port number occupation in Windows system

Git remote library rollback specified version

10000! Ideal car recalls all defective cars: 97 accidents have occurred and losses will be expanded

1万辆!理想汽车召回全部缺陷车:已发生事故97起,亏损将扩大

Using JSON webtoken (JWT) to generate token in nodejs
![What grammar is it? ]](/img/3b/00bc81122d330c9d59909994e61027.jpg)
What grammar is it? ]
随机推荐
小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
How to make characters move
RFID fixed assets management system for fire equipment
心理咨询app开发所具备的优点与功能
Stm32f030f4p6 compatible with smart micro mm32f031f4p6
Configuration of AP hotspot on xunwei-imx6ull development board
Stm32f030k6t6 compatible replacement smart mm32f031k6t6
汽车维修app开发的好处与功能
测试攻城狮必备技能点!一文带你解读DevOps下的测试技术
Detect certificate expiration script
Reserved battery interface, built-in charge and discharge circuit and electricity meter, quickly help easily handle hand-held applications
10000! Ideal car recalls all defective cars: 97 accidents have occurred and losses will be expanded
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
Application layer software development Godfather teaches you how to refactor, senior programmers must professional skills
Windows 10 蓝牙管理页面'添加蓝牙或其他设备'选项点击无响应的解决方案
2020 database technology conference helps technology upgrade
应用层软件开发教父教你如何重构,资深程序员必备专业技能
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification
Design of NAND flash interface control
C language I blog assignment 03