104、验证Swarm数据持久性 (Swarm11)
2024-09-14 04:10:54
上一节我们成功将 nfs 的volume挂载到 Service上,本节验证 Failover时,数据会不会丢失。
Scale Up
增加副本,并验证数据是否能够同步到新启动的容器上
root@host03:~# docker service update --replicas 4 my_web
my_web
overall progress: 4 out of 4 tasks
1/4: running [==================================================>]
2/4: running [==================================================>]
3/4: running [==================================================>]
4/4: running [==================================================>]
verify: Service converged
root@host03:~# docker service ps my_web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
a2v73m955o9j my_web.1 httpd:latest host01 Running Running 13 minutes ago
uzdfouv3s2bz my_web.2 httpd:latest host02 Running Running 13 minutes ago
f4tg54ze3hgg my_web.3 httpd:latest host02 Running Running 14 seconds ago
znf4m0jpa0r5 my_web.4 httpd:latest host01 Running Running 14 seconds ago
root@host01:~# docker inspect my_web.4.znf4m0jpa0r5p3fklp1hgdwhu | jq .[0].Mounts
[
{
"Type": "volume",
"Name": "volume-nfs",
"Source": "/var/lib/docker/volumes/volume-nfs/_data",
"Destination": "/usr/local/apache2/htdocs",
"Driver": "local",
"Mode": "z",
"RW": true,
"Propagation": ""
}
]
root@host01:~# docker exec my_web.4.znf4m0jpa0r5p3fklp1hgdwhu cat /usr/local/apache2/htdocs/index.html
docker swarm nfs volume test
root@host02:~# docker inspect my_web.3.f4tg54ze3hggppy96jldhtdxs | jq .[0].Mounts
[
{
"Type": "volume",
"Name": "volume-nfs",
"Source": "/var/lib/docker/volumes/volume-nfs/_data",
"Destination": "/usr/local/apache2/htdocs",
"Driver": "local",
"Mode": "z",
"RW": true,
"Propagation": ""
}
]
root@host02:~# docker exec my_web.3.f4tg54ze3hggppy96jldhtdxs cat /usr/local/apache2/htdocs/index.html
docker swarm nfs volume test
更新Volume内容,并进行验证
root@host03:~# echo "add test str" >> /var/nfs/index.html
root@host03:~# cat /var/nfs/index.html
docker swarm nfs volume test
add test str
root@host03:~# curl http://10.12.31.211
docker swarm nfs volume test
add test str
root@host03:~# curl http://10.12.31.212
docker swarm nfs volume test
add test str
root@host03:~# curl http://10.12.31.213
docker swarm nfs volume test
add test str
root@host03:~# docker service ps my_web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
a2v73m955o9j my_web.1 httpd:latest host01 Running Running 17 minutes ago
uzdfouv3s2bz my_web.2 httpd:latest host02 Running Running 17 minutes ago
f4tg54ze3hgg my_web.3 httpd:latest host02 Running Running 4 minutes ago
znf4m0jpa0r5 my_web.4 httpd:latest host01 Running Running 4 minutes ago
root@host01:~# docker exec my_web.1.a2v73m955o9js3fbihf0dwei6 cat /usr/local/apache2/htdocs/index.html
docker swarm nfs volume test
add test str
root@host01:~# docker exec my_web.4.znf4m0jpa0r5p3fklp1hgdwhu cat /usr/local/apache2/htdocs/index.html
docker swarm nfs volume test
add test str
root@host02:~# docker exec my_web.2.uzdfouv3s2bz0ohyahjeeyqao cat /usr/local/apache2/htdocs/index.html
docker swarm nfs volume test
add test str
root@host02:~# docker exec my_web.3.f4tg54ze3hggppy96jldhtdxs cat /usr/local/apache2/htdocs/index.html
docker swarm nfs volume test
add test str
Failover 验证,host01关机
root@host03:~# docker service ps my_web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
a2v73m955o9j my_web.1 httpd:latest host01 Running Running 9 seconds ago
uzdfouv3s2bz my_web.2 httpd:latest host02 Running Running 21 minutes ago
f4tg54ze3hgg my_web.3 httpd:latest host02 Running Running 8 minutes ago
znf4m0jpa0r5 my_web.4 httpd:latest host01 Running Running 9 seconds ago
root@host03:~# docker service ps my_web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
i4j8tplkkq34 my_web.1 httpd:latest host02 Ready Ready less than a second ago
a2v73m955o9j \_ my_web.1 httpd:latest host01 Shutdown Running 10 seconds ago
uzdfouv3s2bz my_web.2 httpd:latest host02 Running Running 21 minutes ago
f4tg54ze3hgg my_web.3 httpd:latest host02 Running Running 8 minutes ago
ve0j4of1m1ao my_web.4 httpd:latest host02 Ready Ready less than a second ago
znf4m0jpa0r5 \_ my_web.4 httpd:latest host01 Shutdown Running 10 seconds ago
root@host03:~# docker service ps my_web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
i4j8tplkkq34 my_web.1 httpd:latest host02 Running Ready 4 seconds ago
a2v73m955o9j \_ my_web.1 httpd:latest host01 Shutdown Running 15 seconds ago
uzdfouv3s2bz my_web.2 httpd:latest host02 Running Running 21 minutes ago
f4tg54ze3hgg my_web.3 httpd:latest host02 Running Running 8 minutes ago
ve0j4of1m1ao my_web.4 httpd:latest host02 Running Ready 4 seconds ago
znf4m0jpa0r5 \_ my_web.4 httpd:latest host01 Shutdown Running 15 seconds ago
root@host02:~# docker ps | grep my_web
e46bd42b6fda httpd:latest "httpd-foreground" About a minute ago Up About a minute 80/tcp my_web.4.ve0j4of1m1aosbmpg9yew8dxr
5338df22fc68 httpd:latest "httpd-foreground" About a minute ago Up About a minute 80/tcp my_web.1.i4j8tplkkq348ae0tcdcrl38r
426a79228471 httpd:latest "httpd-foreground" 10 minutes ago Up 10 minutes 80/tcp my_web.3.f4tg54ze3hggppy96jldhtdxs
5c5fffec6de6 httpd:latest "httpd-foreground" 23 minutes ago Up 23 minutes 80/tcp my_web.2.uzdfouv3s2bz0ohyahjeeyqao
root@host02:~# docker exec my_web.1.i4j8tplkkq348ae0tcdcrl38r cat /usr/local/apache2/htdocs/index.html
docker swarm nfs volume test
add test str
root@host02:~# docker exec my_web.4.ve0j4of1m1aosbmpg9yew8dxr cat /usr/local/apache2/htdocs/index.html
docker swarm nfs volume test
add test str
root@host03:~# curl http://10.12.31.211 # 因为host01 关机了,所有host01的ip也访问不了了
curl: (7) Failed to connect to 10.12.31.211 port 80: No route to host
root@host03:~# curl http://10.12.31.212
docker swarm nfs volume test
add test str
root@host03:~# curl http://10.12.31.213
docker swarm nfs volume test
add test str
最新文章
- hzwer模拟赛 虫洞
- linux2.6.24内核源代码分析(2)——扒一扒网络数据包在链路层的流向路径之一
- 从Jetty、Tomcat和Mina中提炼NIO构架网络服务器的经典模式(一)
- 用JavaScript判断横屏竖屏问题。JavaScript代码如下【转】
- BZOJ1108: [POI2007]天然气管道Gaz
- SVN连接不上
- linux卸载rpm包
- Unity Singleton 单例类(Unity3D开发之二十)
- 022 包含min函数的栈
- Falsy Bouncer 过滤数组假值
- PS快速调出天蓝色清新外景
- 简单的TabLayout+Fragment选项卡
- [No0000FF]鸡蛋煮熟了蛋黄为什么发黑?
- 关于Oxygen版 Eclipse JSP或html 中<;option>;标签嵌入jstl 如<;c:if>;出现报错
- react native中的聊天气泡以及timer封装成的发送验证码倒计时
- DB-Engines Ranking
- java try catch 异常后还会继续执行吗
- python 拾遗
- c++重载>;>;和<;<;
- mxonline实战8,机构列表分页功能,以及按条件筛选功能
热门文章
- 纹身女孩 Tattooed girl 可爱动人 出水芙蓉 窈窕多姿
- 简单配置 docker swarm
- [译]AngularJS 1.3.0 开发者指南(一) -- 介绍 (转)
- [笔记] 使用frp从外网访问内网
- Python:Base1(数据类型,print语句,变量,定义字符串,raw字符串与多行字符串,Unicode字符串,整数和浮点数运算,布尔类型运算)
- XCTF (app1)
- “vmware 未能初始化监视器设备”的解决方法
- 【UVA - 1644 / POJ - 3518】Prime Gap(水题)
- 【AMAD】stackprint -- 为Python加入利于调试的traceback信息
- Linux 操作命令简