LVM精简卷(Thinly-Provisioned Logical Volumes)的扩容解决方案

LVM精简卷(Thinly-Provisioned Logical Volumes)如果在生产中使用,紧急故障处理的时候,可以一下子给人干懵。并且在百度还不能搜索到完整可用的文档。LVM精简卷的存在增加了排错成本和运维复杂度。这篇文章将完整的记录lvm精简卷的创建和扩容。

LVM的精简逻辑卷,这可以创建大于可用盘区的逻辑卷。精简池可以在需要时进行动态扩展,存储管理员可以过量使用物理存储,以节省成本地分配存储空间。在标准的逻辑卷中磁盘空间在创建时就会占用卷组的空间,但是在精简卷中只有在写入时才会占用存储池”thin pool LV”中的空间。LVM精简卷(Thinly-Provisioned Logical Volumes)的扩容解决方案
在测试的服务器上新增了一块10G的磁盘,将这个磁盘创建为一个thinpool和2个5G的逻辑卷。它看起来应该这样做:

一、创建精简卷

1.创建pv

[root@shizhanxia.com ]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created.

2.创建vg

[root@shizhanxia.com ]# vgcreate data /dev/sdc
Volume group "data" successfully created

3.创建ThinPool

[root@shizhanxia.com ]# lvcreate -l +100%free --thinpool data_pool data
Thin pool volume with chunk size 64.00 KiB can address at most 15.81 TiB of data.
Logical volume "data_pool" created.

4.创建精简卷Thin volume

[root@shizhanxia.com ]# lvcreate -V 5G --thin -n thin_lv_data01 data/data_pool
Logical volume "thin_lv_data01" created.
[root@shizhanxia.com ]# lvcreate -V 5G --thin -n thin_lv_data02 data/data_pool
WARNING: Sum of all thin volume sizes (10.00 GiB) exceeds the size of thin pool data/data_pool and the size of whole volume group (<10.00 GiB).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "thin_lv_data02" created.

5.创建完成,查看效果。

[root@shizhanxia.com ]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
data_pool data twi-aotz-- 9.97g 0.00 0.68
thin_lv_data01 data Vwi-a-tz-- 5.00g data_pool 0.00
thin_lv_data02 data Vwi-a-tz-- 5.00g data_pool 0.00
root rhel -wi-ao---- 149.50g
swap00 swapvg -wi-ao---- <8.00g

二、lVM精简卷thin pool的自动扩容

1.默认自动扩展配置

默认情况下,自动扩展名设置为”100”

[root@shizhanxia.com ]# grep thin_pool_autoextend_threshold /etc/lvm/lvm.conf
# Configuration option activation/thin_pool_autoextend_threshold.
# thin_pool_autoextend_threshold = 70
thin_pool_autoextend_threshold = 100

设置为100将禁用自动扩展,默认设置表明该功能已被禁用。activation / thin_pool_autoextend_threshold表明当精简池的使用率超过此百分比时会自动扩展。

2.启用自动扩展

如果启用自动扩展请同时更改”thin_pool_autoextend_percent”和”thin_pool_autoextend_threshold”,如下所示:

[root@shizhanxia.com ]# grep thin_pool_autoextend_threshold /etc/lvm/lvm.conf
thin_pool_autoextend_threshold = 70
thin_pool_autoextend_percent = 20

这意味着,只要池使用率超过70%,它就会再扩展20%。

三、LVM精简卷thin volume手动扩容

LVM精简卷thin volume手动扩容,扩容步骤如下:

1.查看LVM状态

[root@shizhanxia.com ]# pvs
/dev/sdc data lvm2 a-- <15.00g 5.00g
[root@shizhanxia.com ]#vgs
VG #PV #LV #SN Attr VSize VFree
data 1 3 0 wz--n- <15.00g 5.00g
[root@shizhanxia.com ]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
data_pool data twi-aotz-- 9.97g 0.00 0.68
thin_lv_data01 data Vwi-a-tz-- 5.00g data_pool 0.00
thin_lv_data02 data Vwi-a-tz-- 5.00g data_pool 0.00
root rhel -wi-ao---- 149.50g
swap00 swapvg -wi-ao---- <8.00g

2.扩容thin pool

[root@shizhanxia.com ]# lvextend -L +2G data/data_pool
Size of logical volume data/data_pool_tdata changed from 9.97 GiB (2553 extents) to 11.97 GiB (3065 extents).
Logical volume data/data_pool_tdata successfully resized.

3.扩容thin volume

[root@shizhanxia.com ]# lvextend -L +2G data/thin_lv_data01
WARNING: Sum of all thin volume sizes (12.00 GiB) exceeds the size of thin pool data/data_pool and the amount of free space in volume group (3.00 GiB).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Size of logical volume data/thin_lv_data01 changed from 5.00 GiB (1280 extents) to 7.00 GiB (1792 extents).
Logical volume data/thin_lv_data01 successfully resized.

原创文章,作者:保哥,如若转载,请注明出处:https://www.shizhanxia.com/1584.html

(0)
上一篇 2023年5月25日 10:51
下一篇 2023年5月26日 18:11

相关推荐

发表回复

登录后才能评论