配置direct-lvm模式

1.  停止Docker

systemctl stop docker

2.  安装依赖包

device-mapper-persistent-data,lvm2, and all dependencies

3.  创建物理卷/dev/md123p1来替换块设备

[root@localhost ~]# pvcreate /dev/md123p1
WARNING: ext4 signature detected on /dev/md123p1 at offset 1080. Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/md123p1.
  Physical volume "/dev/md123p1" successfully created.

4.  用vgcreate命令在同一个设备上创建docker卷组

[root@localhost ~]# vgcreate docker /dev/md123p1
  Volume group "docker" successfully created

5.  用lvcreate命令创建thinpool(数据)和thinpoolmeta(元数据)两个逻辑卷

最后一个参数指定空闲空间的数量,以允许在空间运行低时自动扩展数据或元数据,作为临时的权宜之计。这些是推荐的值。

[root@localhost ~]# lvcreate --wipesignatures y -n thinpool docker -l 95%VG
  Logical volume "thinpool" created.
[root@localhost ~]# lvcreate --wipesignatures y -n thinpoolmeta docker -l 1%VG
  Logical volume "thinpoolmeta" created.

6.  用lvconvert命令把thinpool数据卷和thinpoolmeta元数据卷换为一个精简池,且此精简池使用原数据卷的名字

[root@localhost ~]# lvconvert -y --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta
  Thin pool volume with chunk size 512.00 KiB can address at most 126.50 TiB of data.
  WARNING: Maximum supported pool metadata size is 15.81 GiB.
  WARNING: Converting logical volume docker/thinpool and docker/thinpoolmeta to thin pool's data and metadata volumes with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
  Converted docker/thinpool_tdata to thin pool.

7.  通过lvm profile配置精简池的自动扩容

$ sudo vi/etc/lvm/profile/docker-thinpool.profile

8.  指定thin_pool_autoextend_threshold和thin_pool_autoextend_percent的值

thin_pool_autoextend_threshold:当达到使用空间的指定阈值(百分数)后,lvm就会试图尝试自动扩展可用的空间(100=禁用)。

thin_pool_autoextend_percent:当磁盘每次达到上面定义的阈值后,自动再扩展的百分比数(0=禁用)。

示例:

当磁盘使用达到80%时,再扩展当前容量的10%。更新/etc/lvm/profile/docker-thinpool.profile

activation {

thin_pool_autoextend_threshold=80

thin_pool_autoextend_percent=10

}

保存文件。

9.  用lvchange命令激活LVM profile

[root@localhost ~]# lvchange --metadataprofile docker-thinpool docker/thinpool
  Logical volume docker/thinpool changed.

10. 对主机上的逻辑卷启用监视

如果没有这个步骤,即使在LVM配置文件出现时也不会发生自动扩展。

[root@localhost ~]# lvs -o+seg_monitor
  LV       VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Monitor  
  thinpool docker twi-a-t--- 3.28t             0.00   0.02                             monitored

11. 备份Docker原有数据

如果曾经在这个主机上运行过Docker,或者如果/var/ lib/docker存在,那么将它移出后,Docker就可以使用新的LVM池来存储镜像和容器的内容了。

$ mkdir /var/lib/docker.bk

$ mv /var/lib/docker/*/var/lib/docker.bk

12. 编辑/etc/docker/daemon.json

配置devicemapper存储驱动程序所需的选项。如果该文件以前是空的,那么现在应该包含以下内容:

[root@localhost ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://vaflkxbk.mirror.aliyun.com"],
"storage-driver":"devicemapper",

"storage-opts": [

"dm.thinpooldev=/dev/mapper/docker-thinpool",

"dm.use_deferred_removal=true",

"dm.use_deferred_deletion=true"

]
}

注意:

延迟删除选项,dm.use_deferred_deletion=true,在使用默认内核版本3.18时还不支持RHEL、CentOS或Ubuntu 14.04。

13. 启动Docker

systemd:

$ sudo systemctl start docker

service:

$ sudo service docker start

14. 查看Docker启动信息

$ docker info

[root@localhost ~]# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.12.0-ce
Storage Driver: devicemapper
 Pool Name: docker-thinpool
 Pool Blocksize: 524.3kB
 Base Device Size: 10.74GB
 Backing Filesystem: xfs
 Udev Sync Supported: true
 Data Space Used: 20.45MB
 Data Space Total: 3.611TB
 Data Space Available: 3.611TB
 Metadata Space Used: 2.822MB
 Metadata Space Total: 16.98GB
 Metadata Space Available: 16.98GB
 Thin Pool Minimum Free Space: 361.1GB
 Deferred Removal Enabled: true
 Deferred Deletion Enabled: true
 Deferred Deleted Device Count: 0
 Library Version: 1.02.140-RHEL7 (2017-05-03)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-327.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 24
Total Memory: 125.7GiB
Name: localhost.localdomain
ID: J3U3:BRQF:4WTY:S725:ALZ4:DJPR:IF5I:JRRP:CYLU:LMNG:LT56:EIGM
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8

15. 验证配置正确后,就可以删除/var/lib/docker.bk目录了

$ rm -rf /var/lib/docker.bk

16.参考文档:

https://docs.docker.com/engine/userguide/storagedriver/device-mapper-driver/#configure-direct-lvm-mode-for-production

docker 存储定义成direct-lvm 模式的更多相关文章

  1. 理解Docker(7):Docker 存储 - AUFS

    (1)Docker 安装及基本用法 (2)Docker 镜像 (3)Docker 容器的隔离性 - 使用 Linux namespace 隔离容器的运行环境 (4)Docker 容器的隔离性 - 使用 ...

  2. Docker存储方式选型建议

    转自:https://segmentfault.com/a/1190000007168476 第一部分 问题诊断 事情从一次实施项目说起,我们需要帮助客户将他们的应用容器化并在数人云平台上发布此应用. ...

  3. Docker存储驱动之Device Mapper简介

    Device Mapper是一个基于kernel的框架,它增强了很多Linux上的高级卷管理技术.Docker的devicemapper驱动在镜像和容器管理上,利用了该框架的超配和快照功能.为了区别, ...

  4. Docker存储和网络

    Docker存储资源类型 docker两种存储资源类型 用户在使用 Docker 的过程中,势必需要查看容器内应用产生的数据,或者需要将容器内数据进行备份,甚至多个容器之间进行数据共享,这必然会涉及到 ...

  5. C#使用RabbitMq队列(Sample,Work,Fanout,Direct等模式的简单使用)

    1:RabbitMQ是个啥?(专业术语参考自网络) RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件). RabbitMQ服务器是用Erlang语言编写的, ...

  6. Docker 部署 RocketMQ Dledger 集群模式( 版本v4.7.0)

    文章转载自:http://www.mydlq.club/article/97/ 系统环境: 系统版本:CentOS 7.8 RocketMQ 版本:4.7.0 Docker 版本:19.03.13 一 ...

  7. Docker存储驱动之OverlayFS简介

    简介 OverlayFS是一种和AUFS很类似的文件系统,与AUFS相比,OverlayFS有以下特性: 1) 更简单地设计: 2) 从3.18开始,就进入了Linux内核主线: 3) 可能更快一些. ...

  8. Docker存储驱动之总览

    简介 本文会介绍Docker存储驱动的特性,别列出现在已经支持的存储驱动,最后,会介绍如果选型适合你的存储驱动. 可插拔的存储驱动架构 Docker的存储驱动架构是可插拔的,可以让你很方便的将适合你环 ...

  9. Docker存储

    前言 上一篇文章中简单总结了一下docke的基础使用方法,这次我来总结一下有关docker存储方面的相关知识.本文同样建立在CloudMan的系列教程之上,有兴趣的可以直接移步. 有些人可能觉得这个很 ...

随机推荐

  1. iOS 通用button 上图下字

    UIButton *first = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kHeight(80), kHeight(80))]; [firs ...

  2. vi 替换操作

    举例一: ,$s/// 从第一行到最后一行 147都替换为150 举例二: 例:替换当前文件中所有old为new :%s/old/new/g #%表示替换说有行,g表示替换一行中所有匹配点. 举例三: ...

  3. Android应用程序开发以及背后的设计思想深度剖析

    1 http://www.uml.org.cn/mobiledev/201211063.asp 2 ...

  4. IBM Rational AppScan使用详细说明

    转自:http://www.nxadmin.com/tools/675.html 本文将详细介绍Appscan功能选项设置的细节,适合E文一般,初次接触Appscan的童鞋参考阅读. Appscan是 ...

  5. 在CentOS 5下安装中文五笔

    由于习惯使用五笔,需要在CentOS5 下安装中文五笔输入法. 刚装好的 CentOS 5默认是没有中文输入 法的.只能显示英文,有中文字符的文件名呈现乱码. 首先挂载CentOS的系统安装盘,在安装 ...

  6. js 元素Dom新建并插入页面createElement

    纯js var o = document.createElement('script'); o.type = 'text/template'; o.id = 'demo'; document.docu ...

  7. StringUtils工具类详解

    StringUtils判断字符串大概有四种方法: 下面是 StringUtils 判断是否为空的示例: 判断是否为空,但是要注意,空格不算空,这个最好能不用则不用. StringUtils.isEmp ...

  8. eclipse编写scala应用运行在spark集群上

    代码 package spark_1 import org.apache.spark.SparkConf import org.apache.spark.SparkContext class Work ...

  9. oracle索引的理解

    1.当查询表时where条件中有多个索引时,优先使用主键索引,其它索引会失效. 2.当查询的返回的数据占总量数据的百分比小于20%时,建索引才有效果 3.不是主键的索引值可以为空,主键索引不能为空. ...

  10. oracle查看用户有哪些权限和角色

    select * from dba_sys_privs t where t.grantee='HR';select * from dba_role_privs t where t.grantee='H ...