LVM精简卷扩容实战:从自动到手动扩容全解析

LVM(Logical Volume Manager)的精简卷(Thinly-Provisioned Logical Volumes)是一种高效的存储管理技术,它允许存储管理员创建逻辑卷,这些逻辑卷的大小可以远超过底层物理存储的实际容量。这种技术通过“精简池”(Thin Pool)来实现,精简池是一个特殊的逻辑卷,用于动态地管理分配给精简卷的空间。
在测试的服务器上新增了一块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/1537.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
保哥的头像保哥
上一篇 2024年8月13日 10:53
下一篇 2024年8月14日 11:47

相关推荐

发表回复

登录后才能评论
近期VMware公司在广泛地发律师函。本站也并非专门提供ISO镜像下载服务的站点,经慎重考虑,决定停止向各位赞助者提供该镜像的下载服务。由此带来的不便,我们深表歉意。