上一节我们成功将 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 ...
随机推荐
- 20165207 Exp9 Web安全基础
目录 20165207 Exp9 Web安全基础 一.实验过程 1.环境配置 2.代理工具burpsuite 2.1 Http proxies -> Use the intercept 3.sq ...
- python3笔记二十三:正则表达式之元字符
一:学习内容 匹配单个字符与数字:..[].^.\d.\D.\w.\W.\s.\S 匹配锚字符(边界字符):^.$.\A.\Z.\b.\B 匹配多个字符:(xyz) .x?.x*..*.x+.x{n} ...
- Linux 如何查看端口与进程占用情况
1 lsof -i:port 查看端口使用情况 lsof -i 如果出现 command not found,直接yum install lsof即可. (1) lsof -i lsof -i 用以 ...
- Mysql的exist与in的区别
如果查询的两个表大小相当,那么用in和exists差别不大. 如果两个表中一个较小,一个是大表,则子查询表大的用exists,子查询表小的用in: 例如:表A(小表),表B(大表) 1: s ...
- Delphi之TClientSocket和TServerSocket使用tcp keepalive心跳机制实现“断网”、"断电"检测
开发环境:Delphi7 测试环境:WinXP,Win7 32bit,Win7 64bit 使用TClientSocket和TServerSocket实现TCP长连接通讯,经常因为断电断网等原因导致 ...
- SSH开发中 使用超链接到action 其excute方法会被执行两次 actual row count: 0; expected: 1
由于执行两次excute,所以在做删除操作的时候会出现 Batch update returned unexpected row count from update [0]; actual row c ...
- (转)js控制窗口失去焦点(包括屏蔽Alt+Tab键切换页面)
本章内容转自:http://www.cnblogs.com/BoKeYuanVinson/articles/3360954.html 转载自网络贴吧: 页面脚本是无法截获alt键的,不过可以变通一下, ...
- springmvc+mybatis多数据源切换
前文:之前练习SSM时配置的都是单数据源,现在项目需求多数据源,所以自己查阅了以下资料,在controller中手动切换数据源成功,以下的配置细节. 实际上应该在dao层进行注解的方式切换,使用AOP ...
- nhibernate Stuty
https://blog.csdn.net/u010371458/article/details/8995166 翻译版 https://wenku.baidu.com/view/46fa56cea1 ...
- 整合Django的信息显示框架messages framework
##主要用在view.login函数,不管登录是否成功,都会设置message变量,然后在login.html显示 from django.contrib import messages#需要导的包 ...