docker stroage-driver devicemapper(direct-lvm mode for production)

Configure direct-lvm mode for production

  1. Log in to the Docker host you want to configure and stop the Docker daemon.

  2. Install the LVM2 package.

    The LVM2 package includes the userspace toolset that provides logical volume management facilities on linux.

  3. Create a physical volume replacing /dev/xvdf with your block device.

    $ pvcreate /dev/xvdf
    
  4. Create a ‘docker’ volume group.

    $ vgcreate docker /dev/xvdf
    
  5. Create a thin pool named thinpool.

    In this example, the data logical is 95% of the ‘docker’ volume group size. Leaving this free space allows for auto expanding of either the data or metadata if space runs low as a temporary stopgap.

    $ lvcreate --wipesignatures y -n thinpool docker -l 95%VG
    $ lvcreate --wipesignatures y -n thinpoolmeta docker -l 1%VG
    
  6. Convert the pool to a thin pool.

    $ lvconvert -y --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta
  7. Configure autoextension of thin pools via an lvm profile.

    $ vi /etc/lvm/profile/docker-thinpool.profile
    
  8. Specify thin_pool_autoextend_threshold value.

    The value should be the percentage of space used before lvm attempts to autoextend the available space (100 = disabled).

    thin_pool_autoextend_threshold = 80
  9. Modify the thin_pool_autoextend_percent for when thin pool autoextension occurs.

    The value’s setting is the percentage of space to increase the thin pool (100 = disabled)

    thin_pool_autoextend_percent = 20
  10. Check your work, your docker-thinpool.profile file should appear similar to the following:

    An example /etc/lvm/profile/docker-thinpool.profile file:

    activation {
        thin_pool_autoextend_threshold=80
        thin_pool_autoextend_percent=20
    }
    
  11. Apply your new lvm profile

    $ lvchange --metadataprofile docker-thinpool docker/thinpool
  12. Verify the lv is monitored.

    $ lvs -o+seg_monitor
    
  13. If the Docker daemon was previously started, move your existing graph driver directory out of the way.

    Moving the graph driver removes any images, containers, and volumes in your Docker installation. These commands move the contents of the /var/lib/docker directory to a new directory named /var/lib/docker.bk. If any of the following steps fail and you need to restore, you can remove /var/lib/docker and replace it with /var/lib/docker.bk.

    $ mkdir /var/lib/docker.bk
    $ mv /var/lib/docker/* /var/lib/docker.bk
    
  14. Configure the Docker daemon with specific devicemapper options.

    Now that your storage is configured, configure the Docker daemon to use it. There are two ways to do this. You can set options on the command line if you start the daemon there:

    --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

    You can also set them for startup in the daemon.json configuration, for example:

    {"storage-driver": "devicemapper","storage-opts": ["dm.thinpooldev=/dev/mapper/docker-thinpool","dm.use_deferred_removal=true","dm.use_deferred_deletion=true"]}

    Note: Always set both dm.use_deferred_removal=true and dm.use_deferred_deletion=true to prevent unintentionally leaking mount points.

  15. If using systemd and modifying the daemon configuration via unit or drop-in file, reload systemd to scan for changes.

    $ systemctl daemon-reload
  16. Start the Docker daemon.

    $ systemctl start docker
    

After you start the Docker daemon, ensure you monitor your thin pool and volume group free space. While the volume group will auto-extend, it can still fill up. To monitor logical volumes, use lvs without options or lvs -a to see tha data and metadata sizes. To monitor volume group free space, use the vgs command.



========================================================================

F&Q
1、error initializing graphdriver: devmapper: Unable to take ownership of thin-pool (centos-docker--pool) that already has used data blocks

IF you are using device mapper (instead of loopback) /var/lib/docker contains metadata informing docker about the contents of the device mapper storage area. If you delete /var/lib/docker that metadata is lost. Docker is then able to detect that the thin pool has data but docker is unable to make use of that information. The only solution is to delete the thin pool and recreate it so that both the thin pool and the metadata in /var/lib/docker will be empty.
ex:
lvremove /dev/centos/docker-pool 

Pingbacks已打开。

引用地址

评论
  1. we buy junk cars katy no title we buy junk cars katy no title 发布于 2021年4月18日 13:48 #

    http://h-und-s-dachbau.com/index.php?title=User:MeganF1163361778 katy junk car buyer http://www.healthcare-industry.sbm.pw/user/daneramer8/ we buy cars katy https://hospitality.wiki/index.php?title=User:ZitaLeeson811 we buy junk cars no title katy tx
    http://vape.cannabisbiz.org/blogs/viewstory/304 we buy junk cars no title
    katy tx https://hospitality.wiki/index.php?title=Can_You_Junk_A_Automobile_With_A_Lien_On_The_Title we buy junk cars no title
    katy tx https://hospitality.wiki/index.php?title=Recycling_Old_And_Junk_Vehicles_To_Avoid_Wasting_The_Planet_Here_s_How junk car buyer near me
    https://ganeshaubud.com/out/6782/ extreme cash
    for junk cars katy tx https://gematodiatrofi.hua.gr/wiki/index.php/Easy_Methods_To_Promote_Old_Automobile_In_Overland_Park_With_Out_Encountering_Any_Trouble we buy junk cars
    no title katy tx https://aarth-codex.com/index.php/Junk_Car_Buyer_And_Scrapping_A_Automobile junk car
    buyer katy
    https://xiv.wiki/ff/Wherever_A_Scrap_Automotive_Is_Positioned we buy junk cars katy tx https://thpswiki.com/index.php?title=Request_A_Quote_To_Your_Junk_Automobile_Truck_Or_Van we buy junk cars katy tx https://thpswiki.com/index.php?title=MyJunkCarBuyer.com_-_Residence we buy junk cars katy tx

  2. we buy junk cars katy no title we buy junk cars katy no title 发布于 2021年4月18日 13:48 #

    http://h-und-s-dachbau.com/index.php?title=User:MeganF1163361778 katy junk car buyer http://www.healthcare-industry.sbm.pw/user/daneramer8/ we buy cars katy https://hospitality.wiki/index.php?title=User:ZitaLeeson811 we buy junk cars
    no title katy tx
    http://vape.cannabisbiz.org/blogs/viewstory/304 we buy junk cars no title katy tx https://hospitality.wiki/index.php?title=Can_You_Junk_A_Automobile_With_A_Lien_On_The_Title we buy junk cars no
    title katy tx https://hospitality.wiki/index.php?title=Recycling_Old_And_Junk_Vehicles_To_Avoid_Wasting_The_Planet_Here_s_How junk car buyer
    near me
    https://ganeshaubud.com/out/6782/ extreme cash for junk cars
    katy tx https://gematodiatrofi.hua.gr/wiki/index.php/Easy_Methods_To_Promote_Old_Automobile_In_Overland_Park_With_Out_Encountering_Any_Trouble we buy junk
    cars no title katy tx https://aarth-codex.com/index.php/Junk_Car_Buyer_And_Scrapping_A_Automobile junk car buyer
    katy
    https://xiv.wiki/ff/Wherever_A_Scrap_Automotive_Is_Positioned we buy junk cars katy tx https://thpswiki.com/index.php?title=Request_A_Quote_To_Your_Junk_Automobile_Truck_Or_Van we buy junk cars katy tx https://thpswiki.com/index.php?title=MyJunkCarBuyer.com_-_Residence we buy junk cars katy tx

发表评论