网站首页 > 技术文章 正文
一、Device Mapper: loop-lvm
默认 CentOS7 下 Docker 使用的 Device Mapper 设备默认使用 loopback 设备,后端为自动生成的稀疏文件,data [存放数据] 和 metadata [存放元数据] 的大小从输出可以看出初始化默认为 100G 和 2G 大小,都是稀疏文件,使用多少占用多少。
Docker 在初始化的过程中,创建 data 和 metadata 这两个稀疏文件,并分别附加到回环设备/dev/loop0
和 /dev/loop1
上,然后基于回环设备创建 thin pool。 默认一个 container 最大存放数据不超过 10G[注:docker 1.8 之后默认的大小已经为 100G,建议生产环境针对 container pool 大小监控。],如果需要调整则需要修改 /etc/sysconfig/docker
配置文件添加相关选项 --storage-opt
调整即可(详细参考 man docker 查看 STORAGE DRIVER OPTIONS 具体参数说明)。
二、Device Mapper: direct-lvm
direct-lvm 也是使用 LVM, device mapper the dm-thinp 内核模块,使用 direct-lvm 不再使用 loopback 设备,直接使用 raw 分区(no filesystem),在中等负载和高密度环境下会有更好的性能优势,另外官方也是不建议生产环境系统使用默认的 LVM thin pool,至于两种类型具体的性能对比可以参考 Comprehensive Overview of Storage Scalability in Docker 这篇文章。
CentOS7 从
开始提供
docker-1.6.2-14.el7.centos.x86_64.rpmdocker-storage-setup
工具,方便配置 direct-lvm,所以推荐使用该工具配置。当然也可以手动配置 lvm,添加相关配置选项,不过过程较为繁琐一点,至于如何手动配置笔者没有尝试,不过本文附加了相关部署的参考文章,有需求的可以看看,这里只介绍使用 docker-storage-setup
配置 direct-lvm。
示例配置文件位置
,可以查看其中相关配置的详细说明,或者通过
/usr/lib/docker-storage-setup/docker-storage-setupman docker-storage-setup
获取帮助,以下介绍几个关键的选项:
DATA_SIZE=40%FREE
定义创建 DATA thin pool 的大小,默认为 VG 的 40%
MIN_DATA_SIZE=2G
定义 DATA pool 最小值,默认为 2G,如果 VG 小于 2G 则创建失败
CHUNK_SIZE=512K
定义 thin pool 的 CHUNK 大小,默认 512k
AUTO_EXTEND_POOL=yes
定义是否自动扩容 thin pool 大小,默认为自动扩容
POOL_AUTOEXTEND_THRESHOLD=60
定义自动扩容的百分比,默认为当前 pool 使用 60% 时自动扩容,100 表示 disable,最小为 50lvmthin — LVM thin provisioning
POOL_AUTOEXTEND_PERCENT=20
定义每次扩容的大小,默认为 20%,即当前 pool 大小为 100G,那么自动扩容 20G,扩容后大小为 120G, 100 表示 disable
docker-storage-setup 设置之后自动扩容的实际配置在 /etc/lvm/profile/
目录下:
因为测试的 LVM 卷组名为 docker-vg,因此 docker-storage-setup 自动生成配置文件为
/etc/lvm/profile/docker-vg--docker-pool-extend.profile
# cat /etc/lvm/profile/docker-vg--docker-pool-extend.profileactivation {
thin_pool_autoextend_threshold=60
thin_pool_autoextend_percent=20}
使用 lvs -o+seg_monitor
可验证监控状态。
三、参考
Docker 官方文档:
Docker and the Device Mapper storage driver
性能相关:
random I/O performance improves when increasing thinp chunksize
Comprehensive Overview of Storage Scalability in Docker
Performance Tuning of Docker and RHEL Atomic
部署相关:
Managing Storage with Docker Formatted Containers on Red Hat Enterprise Linux and Red Hat Enterprise Linux Atomic Host
Friends Don’t Let Friends Run Docker on Loopback in Production
docker-storage-setup
Docker and devicemapper`s thinpool in RHEL 7
Setting Up Storage
猜你喜欢
- 2025-03-29 深入解构LVM:从物理卷到逻辑卷(linux逻辑卷和物理卷)
- 2025-03-29 MyBatis接口绑定有几种实现方式,分别是怎么实现的?
- 2025-03-29 Sentinel上生产环境只差一步,监控数据持久化
- 2025-03-29 Spring Security在前后端分离项目中的使用
- 2025-03-29 开源微服务编排框架:Netflix Conductor
- 2025-03-29 Spring框架中的两大事务管理神器:声明式与编程式
- 2025-03-29 拒绝写重复代码,试试这套开源的 SpringBoot 组件
- 2025-03-29 MyBatis的三种分页方式,你学废了吗?
- 2025-03-29 refresh是什么?Spring refresh的12个步骤
- 2025-03-29 基于LOGBACK实现的分布式日志跟踪
- 最近发表
- 标签列表
-
- cmd/c (57)
- c++中::是什么意思 (57)
- sqlset (59)
- ps可以打开pdf格式吗 (58)
- phprequire_once (61)
- localstorage.removeitem (74)
- routermode (59)
- vector线程安全吗 (70)
- & (66)
- java (73)
- org.redisson (64)
- log.warn (60)
- cannotinstantiatethetype (62)
- js数组插入 (83)
- resttemplateokhttp (59)
- gormwherein (64)
- linux删除一个文件夹 (65)
- mac安装java (72)
- reader.onload (61)
- outofmemoryerror是什么意思 (64)
- flask文件上传 (63)
- eacces (67)
- 查看mysql是否启动 (70)
- java是值传递还是引用传递 (58)
- 无效的列索引 (74)