CentOS7中配置LVM精简卷(Thinly-Provisioned Logical Volumes)

LVM精简卷(Thinly-Provisioned Logical Volumes)的概念:

As of the Red Hat Enterprise Linux 6.4 release, logical volumes can be thinly provisioned. This allows you to create logical volumes that are larger than the available extents. Using thin provisioning, you can manage a storage pool of free space, known as a thin pool, which can be allocated to an arbitrary number of devices when needed by applications. You can then create devices that can be bound to the thin pool for later allocation when an application actually writes to the logical volume. The thin pool can be expanded dynamically when needed for cost-effective allocation of storage space.

By using thin provisioning, a storage administrator can over-commit the physical storage, often avoiding the need to purchase additional storage. For example, if ten users each request a 100GB file system for their application, the storage administrator can create what appears to be a 100GB file system for each user but which is backed by less actual storage that is used only when needed. When using thin provisioning, it is important that the storage administrator monitor the storage pool and add more capacity if it starts to become full.

To make sure that all available space can be used, LVM supports data discard. This allows for re-use of the space that was formerly used by a discarded file or other block range.

翻译如下:

从Red Hat Enterprise Linux 6.4版本开始,可以精简配置逻辑卷。这使您可以创建大于可用盘区的逻辑卷。使用精简配置,您可以管理可用空间的存储池(称为精简池),可以在应用程序需要时将其分配给任意数量的设备。然后,您可以创建可以绑定到精简池以供以后在应用程序实际写入逻辑卷时分配的设备。精简池可以在需要时进行动态扩展,以节省成本地分配存储空间。

通过使用自动精简配置,存储管理员可以过量使用物理存储,从而通常避免购买额外的存储。例如,如果十个用户各自为他们的应用程序请求一个100GB的文件系统,则存储管理员可以为每个用户创建一个看上去是100GB的文件系统,但由较少的实际存储作为后盾,仅在需要时才使用。使用精简配置时,重要的是,存储管理员监视存储池并在存储池开始变满时增加更多容量。

为了确保可以使用所有可用空间,LVM支持数据丢弃。这样可以重新使用以前由废弃文件或其他块范围使用的空间。

摘至RedHat官方文档,链接如下

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/thinprovisioned_volumes

如何创建精简卷,可以参考如下链接中的文档说明或者参考man帮助文档

1、https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/thinly_provisioned_volume_creation

2、在LVM中设置精简资源调配卷(第四部分)——Linux中国

https://linux.cn/article-4288-1.html

3、查看帮助文档man lvmthin

下面演示如何创建LVM精简卷

1、创建PV物理卷,创建VG卷组

pvcreate /dev/sda5

vgcreate VG_CentOS /dev/sda5

vgdisplay

2、创建ThinPoolLV

To create a thin volume, you perform the following tasks:

  1. Create a volume group with the vgcreate command.
  2. Create a thin pool with the lvcreate command.
  3. Create a thin volume in the thin pool with the lvcreate command.

lvcreate -L 20G --thinpool Data_Pool VG_CentOS

3、创建精简卷ThinLV

1)创建thin_LV_data01

lvcreate -V 10G --thin -n thin_LV_data01 VG_CentOS/Data_Pool

2)创建thin_LV_data02

lvcreate -V10G -T VG_CentOS/Data_Pool -n thin_LV_data02

3)假设现在再创建一个大小为10G的thin_LV_data03

lvcreate -V10G -T VG_CentOS/Data_Pool -n thin_LV_data03

这时会弹出告警提示,超出了Data_Pool精简池20G的大小

4)格式化并挂载

mkdir /data_01

mkdir /data_02

mkdir /data_03

mkfs.ext4 /dev/VG_CentOS/thin_LV_data01

mkfs.ext4 /dev/VG_CentOS/thin_LV_data02

mkfs.ext4 /dev/VG_CentOS/thin_LV_data03

mount /dev/VG_CentOS/thin_LV_data01 /data_01

mount /dev/VG_CentOS/thin_LV_data02 /data_02

mount /dev/VG_CentOS/thin_LV_data03 /data_03

5)测试写入

dd if=/dev/zero of=/data_01/data_01.iso bs=1M count=8000

dd if=/dev/zero of=/data_02/data_02.iso bs=1M count=8000

lvs查看可以看到Data_Pool已经使用80%

这时再dd if=/dev/zero of=/data_03/data_03.iso bs=1M count=8000

其实这时写入其实是有问题的,因为已经超额了,lvs可以看到Data%为100%了

不明白dd写入时为啥不报错,待求证

6)扩容精简卷池Data_Pool

lvextend -L +15G /dev/VG_CentOS/Data_Pool

这时精简卷池Data_Pool就不会溢出,可见精简卷这种配置方式比较灵活

本文分享自微信公众号 - WalkingCloud(WalkingCloud2018)

原文出处及转载信息见文内详细说明,如有侵权,请联系 yunjia_community@tencent.com 删除。

原始发表时间:2019-11-09

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券