Docker学习(7)------配置Docker使用Devicemapper

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bobpen/article/details/68924208

操作环境

Centos7

Docker version 17.03.0-ce, build 60ccb22

操作步骤

docker devicemapper有两种配置模式loop-lvm和direct lvm,默认使用loop-lvm配置模式,但是在使用该模式的时候,通过docker info,信息提示 WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device,在生产环境中不推荐使用loop-lvm模式,推荐使用direct-lvm模式,下面就是direct-lvm模式的配置步骤。

1.创建pv

[root@localhost ~]# pvcreate /dev/sdc1

2.创建vg

[root@localhost ~]# vgcreate docker /dev/sdc1

3.创建lv

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

4.转换pool为thin pool

[root@localhost ~]lvconvert -y --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta

5.编辑针对docker/thinpool的profile文件如下

[root@localhost ~]# vi /etc/lvm/profile/docker-thinpool.profile 
activation {
thin_pool_autoextend_threshold=80
thin_pool_autoextend_percent=20
}

6.使用上述的profile文件

[root@localhost ~]# lvchange --metadataprofile docker-thinpool docker/thinpool

7.验证lv已经处于monitor状态

[root@localhost ~]# lvs -o+seg_monitor
  LV       VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Monitor  
  home     centos -wi-ao---- 141.62g                                                              
  root     centos -wi-ao----  50.00g                                                              
  swap     centos -wi-ao----   7.88g                                                              
  thinpool docker twi-aot--- 950.00g             1.08   0.02                             monitored

8.修改docker.service配置文件中的Execstart参数如下

ExecStart=/usr/bin/dockerd --storage-driver=devicemapper --storage-opt=dm.thinpooldev=/dev/mapper/docker-thinpool --storage-opt=dm.use_deferred_removal=true --storage-opt=dm.use_deferred_deletion=true

9.重启daemon以及docker

[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker

10.查看docker 信息

[root@localhost ~]# docker info
Containers: 4
 Running: 1
 Paused: 0
 Stopped: 3
Images: 1
Server Version: 17.03.0-ce
Storage Driver: devicemapper
 Pool Name: docker-thinpool
 Pool Blocksize: 524.3 kB
 Base Device Size: 118.1 GB
 Backing Filesystem: xfs
 Data file: 
 Metadata file: 
 Data Space Used: 10.97 GB
 Data Space Total: 1.02 TB
 Data Space Available: 1.009 TB
 Metadata Space Used: 1.946 MB
 Metadata Space Total: 10.73 GB
 Metadata Space Available: 10.73 GB
 Thin Pool Minimum Free Space: 102 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: true
 Deferred Deletion Enabled: true
 Deferred Deleted Device Count: 0
 Library Version: 1.02.135-RHEL7 (2016-11-16)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 977c511eda0925a723debdc94d09459af49d082a
runc version: a01dafd48bc1c7cc12bdb01206f9fea7dd6feb70
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-514.10.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.5 GiB
Name: localhost.localdomain
ID: OFSQ:L72F:BGO4:JQFT:66UZ:IJYF:RWRW:RYJF:O624:F3Z5:NNIE:HO3H
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Experimental: false
Insecure Registries:
 127.0.0.0/8
Registry Mirrors:
 https://wghlmi3i.mirror.aliyuncs.com
Live Restore Enabled: false


展开阅读全文

没有更多推荐了,返回首页