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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值