docker 存儲模式 aufs改device mapper

1.保存文件並關閉docker守護進程

2.安裝 LVM2 包,該包中包含邏輯分區所需的依賴文件

$ sudo apt-get install lvm2

3.選擇一塊空閒磁盤,並創建邏輯分區

$ sudo pvcreate /dev/xvdf

4.創建docker 分區組

$ sudo vgcreate docker /dev/xvdf

5.創建一個 thin pool 並命名爲 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.將該池轉化爲thinpool

$ lvconvert -y --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta

7.配置自動擴容文件

$ vim /etc/lvm/profile/docker-thinpool.profile

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

Modify the thin_pool_autoextend_percent for when thin pool autoextension occurs.

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

thin_pool_autoextend_percent = 20

8.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
}
9.提交lvm配置文件

$ sudo lvchange --metadataprofile docker-thinpool docker/thinpool

10.確認邏輯分區已經被顯示

$ sudo lvs -o+seg_monitor

11.清理docker文件夾

$ rm -rf /var/lib/docker/*

12.將以下命令加入/etc/default/docker
–storage-driver=devicemapper –storage-opt=dm.thinpooldev=/dev/mapper/docker-thinpool –storage-opt dm.use_deferred_removal=true

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

$ sudo systemctl daemon-reload

14.開啓docker守護進程

$ sudo systemctl start docker

15.use lvs without options or lvs -a to see tha data and metadata sizes. To monitor volume group free space, use the vgs command.

16.查看自動擴容的日誌

$ journalctl -fu dm-event.service

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章