multipath多路径,Linux系统底层存储扩容了,如何扩大文件系统?

  • A+
所属分类:体育平台

multipath多路径,Linux系统底层存储扩容了,如何扩大文件系统?

linux服务器通过multipath多路径连接到共享存储,那么当文件系统空间不足的时候,有几种方式可以扩展文件系统的大小:

1、pv不变,原lun存储扩大容量,扩大lv,扩大文件系统

2、新增pv,加入到vg中,扩大lv,扩大文件系统

下文是针对场景1的情况下如何操作(但是个人建议采取新建pv的方式2进行):

Environment

Red Hat Enterprise Linux 5, 6, 7 &8
Filesystem: Ext2/3/4/xfs
LVM Physical Volume (PV) is on whole disk (no partitions)

Issue

A LUN has been extended and we need to get the OS to recognize the new storage space
Both the block device and multipath devices need to be resized
We need to extend our pv, vg, and lv which are using the entire device, not partitions
We need to extend the filesystem
Underlying device of the PV has been extended from storage end. How to get the additional size reflected in the PV, VG.
LUN已扩展,我们需要让操作系统识别新的存储空间
块设备和多路径设备都需要调整大小
我们需要扩展pv、vg和lv,它们使用的是整个设备,而不是分区
我们需要扩展文件系统
PV的底层设备已从存储端扩展。如何获得PV、VG中反映的附加尺寸。

Resolution

If you have this specific scenario, you can use the following steps:

Note: if these lv's are part of a clustered vg, steps 1 and 2 need to be performed on all nodes.注意:集群模式下步骤1和步骤2两个节点都需要执行。

1) Update block devices

# echo 1 > /sys/block/sdX/device/rescan

Note: This step needs to be run against any sd devices mapping to that lun. When using multipath, there will be more than one. 通过multipath -ll命令查看每个聚合卷对应的路径。

2) Update multipath device

# multipathd -k'resize map mpathX'

例子:

where mpathX = the multipath device mapped to the lun, i.e. (gathered from pvs -av output):

 /dev/mpath/36001f93103630000002e000200000000  vg_name    lvm2 a-      1.37T     0     1.37T Pd2u39-f1aG-o2fl-lTtW-C8x0-HYt6-wHxMSz

would be:

 # multipathd -k'resize map 36001f93103630000002e000200000000'
Note: at this point, it is important to verify that the appropriate size is now shown for both sd devices and mpath devices. You can verify this with 'pvs -av' output

3) Resize the physical volume, which will also resize the volume group

# pvresize /dev/mapper/mpathx

4) Resize your logical volume (the below command takes all available space in the vg)

# lvresize -l +100%FREE /path/to/logical/volume

5) Resize your filesystem

For ext4 filesystem use resize2fs
# resize2fs /path/to/logical/volume
For xfs filesystem use xfs_growfs
# xfs_growfs /path/to/logical/volume

6) Verify vg, lv and filesystem extension has worked appropriately

# vgs
# lvs
# df -h

Root Cause

  • In this particular scenario, it is possible to update all applicable information on-line. When using partitions, it is necessary to either extend the partition (which can not be done online) or create new partitions (which should only be done online by those with advance storage and filesystem knowledge).
  • If you are adding a new LUN, please refer to the following articles, which cover adding a new SCSI device, and creating a new PV on that device:

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: