如何在 CentOS 7 中扩展 SAN 存储

如何在 CentOS 7 中扩展 SAN 存储

我有一台 CentOS 7 服务器,使用 LUN 存储数据。最近存储团队扩展了 LUN 空间。这是 multipath -ll 的输出

~ # multipath -ll                                                                                    
   mpathc (3600601606cb04000a0eb35b80750eb11) dm-5 DGC     ,VRAID           
   **size=27T** features='2 queue_if_no_path retain_attached_hw_handler' hwhandler='1 alua' wp=rw
   |-+- policy='service-time 0' prio=50 status=active
   | |- 1:0:0:2 sdl 8:176 active ready running
   | `- 4:0:0:2 sdn 8:208 active ready running
   `-+- policy='service-time 0' prio=10 status=enabled
     |- 1:0:1:2 sdm 8:192 active ready running
     `- 4:0:2:2 sdo 8:224 active ready running

之前的容量为 20TB,现在已经扩展到 27TB。

这是 fdisk 命令的输出

fdisk -l /dev/mapper/mpathc
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/mapper/mpathc: 29686.8 GB, 29686813949952 bytes, 57982058496 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes
Disk label type: gpt
Disk identifier: 843A6F7E-581A-455E-822F-2CE4306394BF

#         Start          End    Size  Type            Name
1         8192  42949672926     20T  Linux filesyste 

您可以看到 LUN 的大小和扇区增加了。这是 kpartx 命令的输出

kpartx -l /dev/mapper/mpathc
GPT:Primary header thinks Alt. header is not at the end of the disk.
GPT:Alternate GPT header not at the end of the disk.
GPT: Use GNU Parted to correct GPT errors.
mpathc1 : 0 42949664735 /dev/mapper/mpathc 8192

这是 df 命令的输出

df -h /dev/mapper/mpathc1
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/mpathc1   20T   17T  4.0T  81% /Splunk-Storage/COLD

所以我不知道如何扩展 /dev/mapper/mpathc1 的空间而不丢失我的数据。我非常感谢任何建议,提前致谢

答案1

步骤1:尝试重新扫描存储设备以告知内核大小已更改。我不确定是否必须对多路径的所有四个组件都执行此操作,但这不会有什么坏处。您可以通过将任何内容写入其rescan文件来重新扫描存储设备:

echo > /sys/class/block/sdl/device/rescan
echo > /sys/class/block/sdm/device/rescan
echo > /sys/class/block/sdn/device/rescan
echo > /sys/class/block/sdo/device/rescan

扫描 HBA 也应该有效。SCSI HBA 有一个scan文件;您将三个十进制数字控制器、目标和 LUN 写入其中以扫描该 LUN。或者使用通配符“-”代替数字。以下扫描两个 HBA 上控制器 0 上的所有设备:

echo "0 - -" > /sys/class/scsi_host/host1/scan
echo "0 - -" > /sys/class/scsi_host/host4/scan

第2步:此时,内核知道这/dev/mapper/mpathc是 27TB。现在您必须增加分区 1 的大小。该parted命令可用于调整分区大小,但我相信 Centos 7 版本parted没有该功能。因此,我将卸载文件系统,删除分区(我知道这很可怕),然后再次创建分区,这次使用正确的大小。检查其参数是否正确。

umount /dev/mapper/mpathc1
parted /dev/mapper/mpathc1 rm 1 mkpart primary 0% 100% print

您可能需要首先在不包含有价值数据的磁盘上进行测试。

我不知道是否可以安装一个parted有该resizepart命令的版本。这将使第二步更容易。

RHEL 7 存储手册包含类似的程序使用fdisk,但它假设 LVM,并且没有多路径。完成此fdisk过程后,您可能必须使用 来kpartx通知内核有关磁盘上的更改。因此,parted 方法似乎更简单,因此对我来说更安全。

步骤3:增加文件系统。首先,重新挂载它。如果是 XFS,则必须挂载它,然后运行xfs_growfs

mount /dev/mapper/mpathc1 /Splunk-Storage/COLD
xfs_growfs /Splunk-Storage/COLD

如果是 ext[234],则运行resize2fs。 可以挂载或卸载。

resize2fs /dev/mapper/mpathc1
mount /dev/mapper/mpathc1 /Splunk-Storage/COLD

你已经完成了。

答案2

感谢您的时间。
在第 2 步中我使用了resizepart,但得到了这个:
Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system believes the disk is smaller. Fix, by moving the backup to the end (and removing the old backup)? Fix/Ignore/Cancel?
我应该修复它吗?

这是完整的输出

~ # parted /dev/mapper/mpathc                                                                                                   
 GNU Parted 3.1
 Using /dev/mapper/mpathc
 Welcome to GNU Parted! Type 'help' to view a list of commands.
 (parted) p                                                                
 Error: The backup GPT table is not at the end of the disk, as it should  be.  This might mean that another operating system believes the
 disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?
 Fix/Ignore/Cancel? I                                                      
 Warning: Not all of the space available to /dev/mapper/mpathc appears to be used, you can fix the GPT to use all of the space (an extra
 15032385536 blocks) or continue with the current setting? 
 Fix/Ignore? I                                                             
 Model: Linux device-mapper (multipath) (dm)
 Disk /dev/mapper/mpathc: 29.7TB
 Sector size (logical/physical): 512B/512B
 Partition Table: gpt
 Disk Flags: 

 Number  Start   End     Size    File system  Name  Flags
 1      4194kB  22.0TB  22.0TB  xfs

(parted) resizepart                                                       
Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system believes the
disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? C

相关内容