background
CentOS 7 has integrated Docker Engine, and provides the docker-storage-setup service to help configure the devicemapper storage driver of the docker service. If the automatic configuration of the driver fails, the storage driver of the docker service will be downgraded to the lvm-loop driver. The lvm-loop mode is not suitable for production environments due to cache issues on the loop device.
The installer of CentOS 7 uses lvm mode to manage disks by default. If there is only one disk, the installer will create a centos volume group (vg) on the physical volume (pv), and use all the space to create home and root logical volumes (lv). ).
The service docker-storage-setup will try to use the vg to which the root file system belongs by default, that is, the centos vg, but because there is no remaining space on the vg, the devicemapper driver configuration fails.
Reduce the size of home lvm to create docker lvm
The home lv space created by the default installation program of CentOS 7 is generally large, so reduce its size first:
lvresize -L -50G /dev/centos/home
Recreate and mount the home filesystem
umount /home
mkfs.xfs /dev/centos/home
mount /home
To configure the devicemapper driver using docker-storage-setup, execute:
servicedockerstop
rm -rf /var/lib/docker
servicedockerstart
Add new storage device create docker lvm
Stop the docker service and clear the existing docker storage:
servicedockerstop
rm -rf /var/lib/docker
编辑/etc/sysconfig/docker-storage-setup:
DEVS=/dev/sdb
VG=docker
配置devicemapper驱动:
[root@localhost ~]# docker-storage-setup
INFO: Volumegroupbackingrootfilesystemcouldnot bedetermined
INFO: Device /dev/sdbis alreadypartitionedand is partofvolumegroupdocker
Roundingupsizeto fullphysicalextent 12.00 MiB
Logicalvolume "docker-poolmeta" created.
Logicalvolume "docker-pool" created.
WARNING: Convertinglogicalvolumedocker/docker-pooland docker/docker-poolmetato pool's dataand metadatavolumes.
THIS WILLDESTROYCONTENTOFLOGICALVOLUME (filesystemetc.)
Converteddocker/docker-poolto thinpool.
Logicalvolume "docker-pool" changed.
重启docker服务:
servicedockerstart
确认配置生效: a) vg信息:
[root@localhost ~]# vgdisplay
--- Volumegroup ---
VGName docker
SystemID
Format lvm2
MetadataAreas 1
MetadataSequenceNo 6
VGAccess read/write
VGStatus resizable
MAXLV 0
CurLV 1
OpenLV 0
MaxPV 0
CurPV 1
ActPV 1
VGSize 10.00 GiB
PESize 4.00 MiB
TotalPE 2559
AllocPE / Size 1028 / 4.02 GiB
Free PE / Size 1531 / 5.98 GiB
VGUUID v1eiA1-P7CS-pUx9-D0uS-eVwZ-41pA-SKdlef
b) docker info:
[root@localhost ~]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
ServerVersion: 1.10.3
StorageDriver: devicemapper
PoolName: docker-docker--pool
PoolBlocksize: 524.3 kB
BaseDeviceSize: 10.74 GB
BackingFilesystem: xfs
Datafile:
Metadatafile:
DataSpaceUsed: 20.45 MB
DataSpaceTotal: 4.287 GB
DataSpaceAvailable: 4.266 GB
MetadataSpaceUsed: 40.96 kB
MetadataSpaceTotal: 12.58 MB
MetadataSpaceAvailable: 12.54 MB
UdevSyncSupported: true
DeferredRemovalEnabled: true
DeferredDeletionEnabled: true
DeferredDeletedDeviceCount: 0
LibraryVersion: 1.02.107-RHEL7 (2016-06-09)
ExecutionDriver: native-0.2
LoggingDriver: json-file
Plugins:
Volume: local
Network: bridgenull host
KernelVersion: 3.10.0-327.22.2.el7.x86_64
OperatingSystem: CentOSLinux 7 (Core)
OSType: linux
Architecture: x86_64
NumberofDockerHooks: 2
CPUs: 2
TotalMemory: 1.782 GiB
Name: localhost.localdomain
ID: AY7O:H2RJ:33J5:62FY:GHZE:AGFH:F42E:AH3J:WY7N:JXQK:LHBS:BDKY
WARNING: bridge-nf-call-iptablesis disabled
WARNING: bridge-nf-call-ip6tablesis disabled
Registries: docker.io (secure)
3) Docker Storage配置选项,查看/etc/sysconfig/docker-storage:
DOCKER_STORAGE_OPTIONS="--storage-driver devicemapper --storage-opt dm.fs=xfs --storage-opt dm.thinpooldev=/dev/mapper/centos-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true "
http://www.tuicool.com/articles/UFJFRzN