CentOS 7已經(jīng)集成了Docker Engine, 并且提供了docker-storage-setup服務來幫助配置docker服務的devicemapper存儲驅(qū)動,如果該驅(qū)動自動配置失敗,則docker服務的存儲驅(qū)動會降級為lvm-loop驅(qū)動。由于loop設備的緩存問題,lvm-loop模式不適合生產(chǎn)環(huán)境。
CentOS 7的安裝程序默認使用lvm模式管理磁盤,如果僅有一塊磁盤,安裝程序會在該物理卷(pv)上創(chuàng)建centos卷組(vg), 并同時使用所有空間創(chuàng)建home和root邏輯卷(lv)。
服務docker-storage-setup默認會嘗試使用root文件系統(tǒng)所屬的vg, 即centos vg,但是由于該vg上已經(jīng)沒有剩余空間,從而導致devicemapper驅(qū)動配置失敗。
CentOS 7默認安裝程序創(chuàng)建的home lv空間一般比較大,先減小其大小:
lvresize -L -50G /dev/centos/home
重新創(chuàng)建并掛載home文件系統(tǒng)
umount /homemkfs.xfs /dev/centos/homemount /home
使用docker-storage-setup配置devicemapper驅(qū)動, 執(zhí)行:
servicedockerstoprm -rf /var/lib/dockerservicedockerstart
停止docker服務,并清除已有的docker storage:
servicedockerstoprm -rf /var/lib/docker
編輯/etc/sysconfig/docker-storage-setup:
DEVS=/dev/sdbVG=docker
配置devicemapper驅(qū)動:
[root@localhost ~]# docker-storage-setupINFO: Volumegroupbackingrootfilesystemcouldnot bedeterminedINFO: 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 infoContainers: 0 Running: 0 Paused: 0 Stopped: 0Images: 0ServerVersion: 1.10.3StorageDriver: 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.2LoggingDriver: json-filePlugins: Volume: local Network: bridgenull hostKernelVersion: 3.10.0-327.22.2.el7.x86_64OperatingSystem: CentOSLinux 7 (Core)OSType: linuxArchitecture: x86_64NumberofDockerHooks: 2CPUs: 2TotalMemory: 1.782 GiBName: localhost.localdomainID: AY7O:H2RJ:33J5:62FY:GHZE:AGFH:F42E:AH3J:WY7N:JXQK:LHBS:BDKYWARNING: bridge-nf-call-iptablesis disabledWARNING: bridge-nf-call-ip6tablesis disabledRegistries: 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
聯(lián)系客服