上一节我们成功将 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
- 验证 Swarm 数据持久性 - 每天5分钟玩转 Docker 容器技术(104)
上一节我们成功将 Rex-Ray Volume 挂载到了 Service.本节验证 Failover 时,数据不会丢失. Scale Up 增加一个副本: docker service update ...
- 使用JSON Schema来验证接口数据
最近在做一些关于JSON Schema的基建,JSON Schema可以描述一个JSON结构,那么反过来他也可以来验证一个JSON是否符合期望的格式. 如果之前看我写的<使用joi来验证数据模型 ...
- PHP正则自动验证传入数据
本文出至:新太潮流网络博客 /** * [is_string_regular_type 正则自动验证传入数据] * @E-mial wuliqiang_aa@163.com * @TIME 2017- ...
- 04: Form 验证用户数据 & 生成html
目录:Django其他篇 01:Django基础篇 02:Django进阶篇 03:Django数据库操作--->Model 04: Form 验证用户数据 & 生成html 05:Mo ...
- vue学习记录:vue引入,validator验证,数据信息,vuex数据共享
最近在学习vue,关于学习过程中所遇到的问题进行记录,包含vue引入,validator验证,数据信息,vuex数据共享,传值问题记录 1.vue 引入vue vue的大致形式如下: <temp ...
- 基于Volley,Gson封装支持JWT无状态安全验证和数据防篡改的GsonRequest网络请求类
这段时间做新的Android项目的client和和REST API通讯框架架构设计.使用了非常多新技术,终于的方案也相当简洁优雅.client仅仅须要传Java对象,server端返回json字符串, ...
- Android Studio 之 SharedPrefences 数据持久性保存
SharedPreferences 会在应用包目录中生成一个xml文件,将数据保存在里面 可以实现数据持久性保存. 创建的数据,保存在 Data -> Data -> 包名 -> s ...
- Ruby Rails学习中:User 模型,验证用户数据
用户建模 一. User 模型 实现用户注册功能的第一步是,创建一个数据结构,用于存取用户的信息. 在 Rails 中,数据模型的默认数据结构叫模型(model,MVC 中的 M).Rails 为解决 ...
- 使用System.ComponentModel.DataAnnotations验证字段数据正确性
在.NET MVC 中,当页面提交model到Action的时候,自动填充ModelState.使用ModelState.IsValid进行方便快捷的数据验证,其验证也是调用命名空间System.Co ...
随机推荐
- 内置对象(Date String Math Array)
什么是对象 JavaScript 中的所有事物都是对象,如:字符串.数值.数组.函数等,每个对象带有属性和方法. 对象的属性:反映该对象某些特定的性质的,如:字符串的长度.图像的长宽等: 对象的方法: ...
- 6.HBase时髦谨慎财会会计
1.基本概念和原理 2.核心知识点 3.安装部署 4.Hbase开发
- 爬虫 lxml 模块
Xpath 在 XML 文档中查找信息的语言, 同样适用于 HTML 辅助工具 Xpath Helper Chrome插件 快捷键 Ctrl + shift + x XML Quire xpath ...
- PHP中获取当前页面的完整URL、PHP URL处理、获取不带扩展名的文件名
javascript实现: top.location.href 顶级窗口的地址this.location.href 当前窗口的地址 PHP实现 #测试网址: http://localhost/blog ...
- java 抽取 word,pdf 的四种武器
转自:https://www.ibm.com/developerworks/cn/java/l-java-tips/ 感谢作者发布的文章 用 jacob 其实 jacob 是一个 bridag ...
- 数据中心网络架构的问题与演进 — SDN
目录 文章目录 目录 前文列表 OpenFlow 源起 从 OpenFlow 衍生 SDN 前文列表 <数据中心网络架构的问题与演进 - 传统路由交换技术与三层网络架构> <数据中心 ...
- java:activiti(工作流简介 )
1.工作流:(workflow) 整个工作的流程 eg:请假工作流 (我)员工-->组长-->经理-->主管-->人事-->总经理(董事会) eg:出差(报账)工作流 ( ...
- Opencv实现的陷波滤波器
在本示例中,共设计了三个函数,分别是巴特沃斯滤波器BLPF().巴特沃斯陷波滤波器notchFilter_BTW().高斯陷波滤波器notchFilter_GAUSS() 巴特沃斯陷波滤波器参见书上6 ...
- 《Visual Studio程序员箴言》笔记
还记得刚工作时看到某前辈用快捷键操作Visual Studio,赞叹不已,才发觉原来快捷键熟练了效率可以如此之高.后来,我在为一个经常使用的命令添加快捷键的时候又发现Visual Studio的快捷键 ...
- Windows下的开发辅助神器——Chocolate Package Manager
Windows下的开发辅助神器——Chocolate Package Manager:https://juejin.im/post/5c6cb3acf265da2dc4537235 Windows上的 ...