Docker Deep 2-storage-driven using Devicemapper (DIRECT-LVM) mode

Source: Internet
Author: User

Docker Deep 2-storage-driven using Devicemapper (DIRECT-LVM) mode

2016/12/9

First, the status quo 1, the default is to use  devicemapper (LOOP-LVM) [[email protected] lib]# docker info       (slightly)         server version: 1.12.3storage  driver: devicemapper pool name: docker-253:3-33517-pool pool blocksize:  65.54 kb base device size: 10.74 gb backing filesystem: xfs  data file: /dev/loop0 metadata file: /dev/loop1 data space used:  11.8 mb data space total: 107.4 gb data space available:  7.433 gb metadata space used: 581.6 kb metadata space total : 2.147 gb metadata space available: 2.147 gb thin pool  Minimum free space: 10.74 gb udev sync supported: true deferred  removal enabled: false deferred deletion enabled: false deferred deleted device  Count: 0 data loop file: /var/lib/docker/devicemapper/devicemapper/data warning:  usage of loopback devices is strongly discouraged for production  use. Use  '--storage-opt dm.thinpooldev '  to specify a custom  block storage device. metadata loop file: /var/lib/docker/devicemapper/ Devicemapper/metadata (slightly) docker root dir: /var/lib/docker (slightly) 2, corresponding equipment [[email protected]  lib]# lsblk -i 7name                       maj:min rm  size ro type  MOUNTPOINTloop0                        7:0    0  100g  0 loop └─docker-253 : 3-33517-POOL&NBSP;252:0&NBSP;&NBSP;&NBSP;&NBSP;0&NBSP;&NBSP;100G&NBSP;&NBSP;0&NBSP;DM&NBSP;&NBSP;&NBSP;LOOP1                         7:1    0    2g  0 loop  └─docker-253:3-33517-pool 252:0    0  100G  0 dm  Second, adjust to  devicemapper (DIRECT-LVM) 1, preparation work installation  lvm2[[email protected] ~]# yum install &NBSP;LVM2 add a disk [[Email protected] ~]# ls /dev/vdb/dev/vdb Stop  docker  Service [email  protected] ~]# systemctl stop docker2, configuration device 1) pv[[email protected] ~]#  PVCREATE&NBSP;/DEV/VDB2) Create a  vg [[email protected] ~]# vgcreate named  docker   docker /dev/vdB3) Create 2  lv, corresponding to  data  and  metadata  devices [[email protected] ~]# lvcreate  --wipesignatures y -n thinpool docker -l 95%vg[[email protected]  ~]# lvcreate --wipesignatures y -n thinpoolmeta docker -l 1% VG4) Convert  pool  to  thinpool  format [[email protected] ~]# lvconvert -y -- zero n -c 512k --thinpool docker/thinpool --poolmetadata docker/ THINPOOLMETA5) Adjustment  lvm  configuration the value should be the percentage of  Space used before lvm attempts to autoextend the available space   (100 = disabled). Defines a percentage threshold that indicates the amount of space used before triggering  lvm  automatic expansion. Thin_pool_autoextend_threshold = 80the value ' S setting is the percentage  of space to increase the thin pool  (100 = disabled) ratio of each expansion  thin pool  space Thin_pool_autoextend_percent = 20[[email  protected] ~]# cat /etc/lvm/profile/docker-thinpool.profileactivation {   &NBSP;&NBSP;THIN_POOL_AUTOEXTEND_THRESHOLD=80&NBSP;&NBSP;&NBSP;&NBSP;THIN_POOL_AUTOEXTEND_PERCENT=20} 6) lvchange  application configuration [[Email protected] ~]# lvchange --metadataprofile docker-thinpool &NBSP;DOCKER/THINPOOL7) lvs  View volume information, verify the status of  monitor  [[email protected] ~]# lvs  -o+seg_monitor  lv       vg     attr        lsize   pool origin data%  meta%   move log cpy%sync convert monitor    thinpool docker &NBSP;TWI-A-T--- 190.00g              0.00   0.01                    &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;MONITORED3, adjustment  docker  storage 1) Backup [[email  protected] ~]# mkdir /var/lib/docker.bk[[email protected] ~]# mv /var/lib/ DOCKER/*&NBSP;/VAR/LIB/DOCKER.BK If this  docker engine  has some  images  in use, and needs to be saved, please advance to your own Saved in  registry . 2) Adjust the service configuration A, the first way [[email protected] ~]# vim /lib/systemd/system/docker.service  Add parameter:--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 or:[[email  protected] ~]# sed -i  '/^execstart=/c\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 '  /lib/systemd/system/docker.service b, the 2nd Way of adjustment Configuration of  daemon.json :[[email protected] ~]# 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 "    ]}c, precautions Note: always set both dm.use_ Deferred_removal=true and dm.use_deferred_deletion=true to prevent unintentionally  leaking mount points. Enable the above 2 parameters to prevent potentially unintended mount point leaks 3) Restart service [[email protected] ~]#  SYSTEMCTL&NBSP;DAEMON-RELOAD[[EMAIL&NBSP;PROTECTED]&NBSP;~]#&NBSP;SYSTEMCTL&NBSP;START&NBSP;DOCKER4) Verify [[Email  protected] lib]# docker info      (slightly)   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.107-rhel7  (2016-06-09) (slightly)  5) can view the status of  lvm  volume by  lvs, lvdisplay, vgs  and other instructions 6) can view the log to understand  thin  pool  status [[email protected] ~]# journalctl -fu  when auto-scaling touches the threshold DM-EVENT.SERVICE7) corresponding device [[email protected] ~]# lsblk -i  ' 253 '  |grep -v  vdaname                     MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTvdb                      253:16    0  200G  0 disk ├─docker-thinpool_tmeta 252:0     0    2G  0 lvm  │ └─docker-thinpool      252:2    0  190G  0 lvm   └─docker-thinpool_tdata 252:1    0  190G  0 lvm    └─docker-thinpool    &NBSP;&NBSP;252:2&NBSP;&NBSP;&NBSP;&NBSP;0&NBSP;&NBSP;190G&NBSP;&NBSP;0&NBSP;LVM&NBSP;8), you can clean up the old data after confirming the error [email &NBSP;PROTECTED]&NBSP;~]#&NBSP;RM&NBSP;/VAR/LIB/DOCKER.BK&NBSP;-FR4, integrate into a small script to configure DIRECT-LVM storage [[email  protected] ~]# cat docker_direct_lvm_setup.sh    #!/bin/bash# #2016/12/8# v1.0.5  @PC ##  to allocate a separate disk for Docker use, this example uses  /dev/vdbdev_name= '/dev/vdb ' yum -y -q  install lvm2echo  ' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ' pvcreate  ${dev_name}vgcreate docker ${dev_name}lvcreate --wipesignatures y -n  thinpool docker -l 95%vglvcreate --wipesignatures y -n thinpoolmeta  docker -l 1%vglvconvert -y --zero n -c 512k --thinpool docker/ thinpool --poolmetadata docker/thinpoolmetacat << ' _eof '  >/etc/lvm/profile/docker-thinpool.profileactivation {     thin_pool_autoextend_threshold=80    thin_pool_autoextend_percent= 20}_eoflvchange --metadataprofile docker-thinpool docker/thinpoolecho  ' +++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ ' lvs -o+seg_monitorecho  ' +++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++ ' cat << ' _eof ' ++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++ Next Steps Example:[1]  if  docker  old data, first push to registry and then remove; # mkdir  /var/lib/docker.bk# mv /var/lib/docker/* /var/lib/docker.bk[2]  Update the configuration of the Docker service: (Mode one:   Adjustment  docker.service  configuration parameters) # sed -i  '/^execstart=/c\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 '  /lib/systemd/system/docker.service   (mode two:  configuration parameters in  daemon.json ) # 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 "    ]}[3]  Restart service # systemctl daemon-reload & & systemctl start docker[4]  Verify that the adjustment is complete # docker info+++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++_EOFZYXW, reference 1, docshttps://docs.docker.com/engine/userguide/ Storagedriver/device-mapper-driver/#/configure-direct-lvm-mode-for-production2, Docker Device Mapper   Using  direct-lvmhttp://www.cnblogs. COM/SZLLQ2000/P/5486834.HTML3, daemon.jsonhttps://docs.docker.com/engine/reference/commandline/dockerd/ 


Docker Deep 2-storage-driven using Devicemapper (DIRECT-LVM) mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.