openshift上使用devicemapper
环境:openshift v3.6.173.0.5
openshift上devicemapper与官方文档中的描述略有不同,在官方文档的描述中,容器使用的lvm文件系统挂载在/var/lib/devicemapper下,因此可以在/var/lib/devicemapper/metadata中找到容器对应的devicemapper的配置信息,在/var/lib/devicemapper/mnt中可以看到容器的文件系统,描述如下:
The
/var/lib/docker/devicemapper/metadata/directory contains metadata about the Devicemapper configuration itself and about each image and container layer that exist. Thedevicemapperstorage driver uses snapshots, and this metadata include information about those snapshots. These files are in JSON format.The
/var/lib/devicemapper/mnt/directory contains a mount point for each image and container layer that exists. Image layer mount points are empty, but a container’s mount point shows the container’s filesystem as it appears from within the container.
在openshfit中使用docker inspect查看一个容器的devicemapper信息如下,使用的块设备为 docker-253:0-101504694-13339a03e1b2fc605c83e915a439d8f87131b9e01d599750298a5eada849ae5f
"GraphDriver": {
"Name": "devicemapper",
"Data": {
"DeviceId": "",
"DeviceName": "docker-253:0-101504694-13339a03e1b2fc605c83e915a439d8f87131b9e01d599750298a5eada849ae5f",
"DeviceSize": ""
}
},
但在/var/lib/docker/devicemapper/mnt中该容器对应的文件挂载为空,系统mount命令也查找不到该容器对应的块设备挂载信息
# pwd
/var/lib/docker/devicemapper
# du -d |grep 13339a03e1b2fc605c83e915a439d8f87131b9e01d599750298a5eada849ae5f
./mnt/13339a03e1b2fc605c83e915a439d8f87131b9e01d599750298a5eada849ae5f-init
./mnt/13339a03e1b2fc605c83e915a439d8f87131b9e01d599750298a5eada849ae5f
查看该容器对应的进程,pid为19422
# docker inspect 17ba06eb4578|grep Pid
"Pid": ,
"PidMode": "",
"PidsLimit": ,
在/proc/19422/ns中可以看到其命名空间相关的信息,对比pid 为1的mnt ns(mnt -> mnt:[4026531840]),可以看到该容器与根进程不属于同一个mount 命名空间,因此在根进程所在的mount命名空间中无法查看到该容器的挂载信息
# ll
total
lrwxrwxrwx. root Apr : ipc -> ipc:[]
lrwxrwxrwx. root Apr : mnt -> mnt:[]
lrwxrwxrwx. root Apr : net -> net:[]
lrwxrwxrwx. root Apr : pid -> pid:[]
lrwxrwxrwx. root Apr : user -> user:[]
lrwxrwxrwx. root Apr : uts -> uts:[]
使用nsenter -t 19422 -m mnt -u命令进入到进程所在的mount和uts命名空间,使用mount命令可以看到容器的块设备挂载到了该mount命名空间的根目录
/dev/mapper/docker-:--13339a03e1b2fc605c83e915a439d8f87131b9e01d599750298a5eada849ae5f on / type xfs (rw,relatime,context="system_u:object_r:container_file_t:s0:c2,c3",nouuid,attr2,inode64,sunit=,swidth=,noquota)
当然也可以在/proc/19422/mounts和/proc/19422/mountinfo中看到与该进程相关的mount信息,其中也包括容器的块设备挂载信息
使用lsns可以看系统中的命名空间与进程的对应关系,下面列出了pid为19422的相关命名空间,NPROCS表示该命名空间下面的进程数目,PID表示该命名空间下的最小PID值。可以看出19422与根进程属于同一个user命名空间。其中mnt命名空间中有2个进程,一个是19422,另一个是19422的父进程(此处为java)。因此在容器异常退出后,可以通过进入未退出进程的命名空间定位问题。
[root@lab-node1 proc]# lsns -p
NS TYPE NPROCS PID USER COMMAND
user root /usr/lib/systemd/systemd --switched-root --system --deserialize
ipc /usr/bin/pod
net /usr/bin/pod
mnt /bin/sh /opt/eap/bin/standalone.sh -Djavax.net.ssl.keyStore=/opt/hawkular/auth/hawkular-metrics.keystore -Djavax.net.ssl.tru
uts /bin/sh /opt/eap/bin/standalone.sh -Djavax.net.ssl.keyStore=/opt/hawkular/auth/hawkular-metrics.keystore -Djavax.net.ssl.tru
pid /bin/sh /opt/eap/bin/standalone.sh -Djavax.net.ssl.keyStore=/opt/hawkular/auth/hawkular-metrics.keystore -Djavax.net.ssl.tru
参考:
https://xuxinkun.github.io/2019/04/02/deviemapper-docker/
https://docs.docker.com/engine/reference/commandline/dockerd/
openshift上使用devicemapper的更多相关文章
- 在openshift上使用django+postgresql
openshift上用的是django 1.7,数据库选择的是postgresql 9.2 本地开发用的是sqlite3数据库,发布到openshift上后是没有数据的(本地的sqlite3数据库里的 ...
- 在OpenShift上托管web.py应用
一.背景 最近在学习web.py,跟随官网的cookbook和code examples一路敲敲打打,在本地访问了无数遍http://0.0.0.0:8080/,也算是对web.py有了基本的认识.为 ...
- OpenShift上部署Redis主从集群
客户有部署有状态服务的需求,单机部署模式相对简单,尝试一下集群部署. 关于Redis的master,slave 以及sentinal的架构和作用不提,有兴趣可以参考之前的博客 https://www. ...
- 使用Quarkus在Openshift上构建微服务的快速指南
在我的博客上,您有机会阅读了许多关于使用Spring Boot或Micronaut之类框架构建微服务的文章.这里将介绍另一个非常有趣的框架专门用于微服务体系结构,它越来越受到大家的关注– Quarku ...
- 【openshift】在Openshift上通过yaml部署应用
在Openshift上通过yaml部署应用 1.通过直接执行yaml 通过如下命令直接执行 oc create -f nginx.yml nginx.yml apiVersion: v1 items: ...
- 上一周,小白的我试着搭建了两个个人博客:在github和openshift上
上一周,突发奇想,想搭建个自己的博客. 由于是突发奇想,自然想先找免费的试试手.仔细搜索下,选定了目标Openshift和Github. Openshift 安装WordPress OpenShift ...
- 在openshift上自定义node.js的版本
https://github.com/ramr/nodejs-custom-version-openshift 由于是线上服务器,一步一步来: 先把上面的工程拉下来,覆盖到初始化的工程里,提交,让服务 ...
- openshift上传java web项目
下载当前客户端 OC(Openshift Client) https://mirror.openshift.com/pub/openshift-v3/clients/3.9.14/windows/oc ...
- OpenShift上的OpenvSwitch入门
前段时间参加openshift培训,通过产品部门的讲解,刷新了我对OpenShift一些的认识,今天先从最弱的环节网络做一些了解吧. Openvswitch是openshift sdn的核心组件,进入 ...
随机推荐
- 在python学习时间过程中,你会不断发现需要解决的问题,更多需要连接未知,这时候到哪里去查阅资料呢?
1.safari online book https://www.safaribooksonline.com 知乎上有人问,送程序员什么礼物好,其中一个答案就是safari online.编程的英文书 ...
- SQL 不常用的一些命令sp_OACreate,xp_cmdshell,sp_makewebtask
开启和关毕xp_cmdshell EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cm ...
- Android Studio开发环境搭建和HelloWorld
跟着教程做的,已经有了JDK,直接进行后面的步骤,下载安装Android SDK 没有FQ,教程里的网址打不开,就换了个.网址 http://tools.android-studio.org/inde ...
- centos7.2 下 nginx 开机启动
1.在系统服务目录里创建nginx.service文件 1 vi /lib/systemd/system/nginx.service 内容如下 1 2 3 4 5 6 7 8 9 10 11 12 1 ...
- ABP框架系列之四十八:(Specifications-规范)
Introduction Specification pattern is a particular software design pattern, whereby business rules c ...
- (21)The history of human emotions
https://www.ted.com/talks/tiffany_watt_smith_the_history_of_human_emotions/transcript00:12I would li ...
- suse下修改主机名
export HOSTNAME=主机名 echo $HOSTNAME>/etc/HOSTNAME /etc/rc.d/boot.localnet stop /etc/rc.d/boot.loca ...
- VsCode编写和调试.NET Core
本文转自:https://www.cnblogs.com/Leo_wl/p/6732242.html 阅读目录 使用VsCode编写和调试.NET Core项目 回到目录 使用VsCode编写和调试. ...
- SimpleCursorAdapter和ListView的结合使用
我们在用SQLite查数据的时候,经常会用到Cursor这个游标,我们希望能将游标指向的数据直接绑定到ListView中,这样就免去了将游标数据取出然后转换到SimpleAdapter中的麻烦.今天我 ...
- sublime将python的运行结果在命令行显示
sublime将python的运行结果在命令行显示 为什么这么折腾? 因为每次查看输出结果都要上下拖动窗口,很烦. 将build system修改为 { "cmd": [" ...