关闭

docker 存储模式 aufs改device mapper

标签: dockeraufsdevicemappstorageopt
658人阅读 评论(0) 收藏 举报
分类:

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

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:56354次
    • 积分:1083
    • 等级:
    • 排名:千里之外
    • 原创:54篇
    • 转载:5篇
    • 译文:0篇
    • 评论:1条
    文章分类
    最新评论