为Docker配置direct-lvm

版权声明: https://blog.csdn.net/Andriy_dangli/article/details/79279954

Docker 中direct-lvm配置:

#分配设备
[root@k8s-slave ~]# fdisk -l
Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x73fcd4fb

   Device Boot      Start         End      Blocks   Id  System
   
-----------------------------------------------------
#创建PV
[root@k8s-slave ~]# pvcreate /dev/vdb
  Physical volume "/dev/vdb" successfully created.
[root@k8s-slave ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree  
  /dev/vda2  cl     lvm2 a--   49.00g      0 
  /dev/vdb   docker lvm2 a--  200.00g 200.00g
[root@k8s-slave ~]# pvdisplay 
  --- Physical volume ---
  PV Name               /dev/vdb
  VG Name               docker
  PV Size               200.00 GiB / not usable 4.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              51199
  Free PE               51199
  Allocated PE          0
  PV UUID               7pvAKx-kbEL-DKGL-VT5P-hz30-S6KF-MYHaHU
-----------------------------------------------------
#创建VG
[root@k8s-slave ~]# vgcreate docker /dev/vdb
  Volume group "docker" successfully created
[root@k8s-slave ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  cl       1   2   0 wz--n-  49.00g      0 
  docker   1   0   0 wz--n- 200.00g 200.00g
[root@k8s-slave ~]# vgdisplay docker
  --- Volume group ---
  VG Name               docker
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               200.00 GiB
  PE Size               4.00 MiB
  Total PE              51199
  Alloc PE / Size       0 / 0   
  Free  PE / Size       51199 / 200.00 GiB
  VG UUID               pasYCH-DcL1-ZYRd-GuVH-dXFZ-p2c2-ksLBLQ
-----------------------------------------------------
#创建thinpool
创建pool
[root@k8s-slave ~]# lvcreate --wipesignatures y -n thinpool docker -l 95%VG
  Logical volume "thinpool" created.
[root@k8s-slave ~]# lvcreate --wipesignatures y -n thinpoolmeta docker -l 1%VG
  Logical volume "thinpoolmeta" created.
    === 数据LV大小为VG的95%,元数据为1%,剩余用来自动扩展 ===
将pool转换为thinpool
[root@k8s-slave ~]# lvconvert -y --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta
  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 to thin pool.
------------------------------------------------------
#配置thinpool
[root@k8s-slave ~]# cat /etc/lvm/profile/docker-thinpool.profile
activation {
  thin_pool_autoextend_threshold=80
  thin_pool_autoextend_percent=20
}
------------------------------------------------------
#使配置生效
[root@k8s-slave ~]# lvchange --metadataprofile docker-thinpool docker/thinpool
  Logical volume docker/thinpool changed.
------------------------------------------------------
#状态监控检查
[root@k8s-slave ~]# lvs -o+seg_monitor
  LV       VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Monitor                             
  thinpool docker twi-a-t--- 190.00g             0.00   0.01                             monitored
------------------------------------------------------
#配置docker
[root@k8s-slave ~]# cat /etc/docker/daemon.json
{
    "storage-driver": "devicemapper",
    "storage-opts": [
    "dm.thinpooldev=/dev/mapper/docker-thinpool",
    "dm.use_deferred_removal=true",
    "dm.use_deferred_deletion=true"
    ]
}
#重启docker
#查看docker info
[root@sjt-test5-t6 alauda]# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.12.6
Storage Driver: devicemapper
 Pool Name: docker-thinpool
 Pool Blocksize: 524.3 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: 
 Metadata file: 
 Data Space Used: 20.45 MB
 Data Space Total: 204 GB
 Data Space Available: 204 GB
 Metadata Space Used: 266.2 kB
 Metadata Space Total: 2.143 GB
 Metadata Space Available: 2.143 GB
 Thin Pool Minimum Free Space: 20.4 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: journald
Cgroup Driver: systemd
Plugins:
 Volume: local
 Network: host bridge null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Security Options: seccomp selinux
Kernel Version: 3.10.0-514.26.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 4
Total Memory: 13.69 GiB
Name: sjt-test5-t6
ID: CLHX:NWJH:MWKW:GTW3:SAQ6:CYIA:7WPC:DTID:VYZQ:THH6:UQW2:RLR5
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Insecure Registries:
 127.0.0.0/8
Registries: docker.io (secure)


猜你喜欢

转载自blog.csdn.net/Andriy_dangli/article/details/79279954