背景CentOS 7已經(jīng)集成了Docker Engine, 并且提供了docker-storage-setup服務(wù)來幫助配置docker服務(wù)的devicemapper存儲驅(qū)動,如果該驅(qū)動自動配置失敗,則docker服務(wù)的存儲驅(qū)動會降級為lvm-loop驅(qū)動。由于loop設(shè)備的緩存問題,lvm-loop模式不適合生產(chǎn)環(huán)境。 CentOS 7的安裝程序默認(rèn)使用lvm模式管理磁盤,如果僅有一塊磁盤,安裝程序會在該物理卷(pv)上創(chuàng)建centos卷組(vg), 并同時使用所有空間創(chuàng)建home和root邏輯卷(lv)。 服務(wù)docker-storage-setup默認(rèn)會嘗試使用root文件系統(tǒng)所屬的vg, 即centos vg,但是由于該vg上已經(jīng)沒有剩余空間,從而導(dǎo)致devicemapper驅(qū)動配置失敗。 減小home lvm的大小創(chuàng)建docker lvmCentOS 7默認(rèn)安裝程序創(chuàng)建的home lv空間一般比較大,先減小其大小: lvresize -L -50G /dev/centos/home 重新創(chuàng)建并掛載home文件系統(tǒng) umount /home
mkfs.xfs /dev/centos/home
mount /home
使用docker-storage-setup配置devicemapper驅(qū)動, 執(zhí)行: servicedockerstop
rm -rf /var/lib/docker
servicedockerstart
添加新的存儲設(shè)備創(chuàng)建docker lvm停止docker服務(wù),并清除已有的docker storage: servicedockerstop
rm -rf /var/lib/docker
編輯/etc/sysconfig/docker-storage-setup: DEVS=/dev/sdb VG=docker 配置devicemapper驅(qū)動: [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服務(wù): servicedockerstart
確認(rèn)配置生效: 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./articles/UFJFRzN 參考 |
|