Linux扩容LV

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cyan_grey/article/details/81978869

第一步、添加硬盘,不重启主机识别新硬盘

生产系统在没有计划重启的情况下,不是随时都可以重启,Linux主机在扩容添加lun存储或者磁盘时,通常需要进行重启系统才能识别新添加的lun,本测试通过重置存储缓冲值的方式来发现新添加的存储,达到不重启系统也能发现新添加的磁盘存储的目的

1.当前操作系统环境实验环境

#cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.7 (Santiago)

#uname  -ar
Linux ASMdb01 2.6.32-573.el6.x86_64 #1 SMP Wed Jul 1 18:23:37 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

#dmidecode | grep -i vmware
        Manufacturer: VMware, Inc.
        Product Name: VMware Virtual Platform
        Serial Number: VMware-56 4d 8a c5 73 b5 c7 b6-22 cc 7c 33 8e 12 c8 38
        Description: VMware SVGA II

2.添加磁盘

新添加5块磁盘,一块50GB,430GB后

利用fdisk -l 查看当前磁盘状态,新添加磁盘并没有被识别出来

#fdisk -l 

Disk /dev/sda: 26.8 GB, 26843545600 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        3264    26008576   8e  Linux LVM

Disk /dev/mapper/VolGroup-LogVol01: 24.5 GB, 24482152448 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-LogVol00: 2147 MB, 2147483648 bytes
Disk identifier: 0x00000000

(注:此处省略fdisk -l 部分详细信息)

3.进入/sys/class/scsi_host目录,在/sys/class/scsi_host下找到符合指向本机iscsi设备主机符号链接表
# ls -al  /sys/class/scsi_host
total 0
drwxr-xr-x.  2 root root 0 Nov 12 15:31 .
drwxr-xr-x. 45 root root 0 Nov 12 15:31 ..
lrwxrwxrwx.  1 root root 0 Nov 12 15:31 host0 -> ../../devices/pci0000:00/0000:00:07.1/host0/scsi_host/host0
lrwxrwxrwx.  1 root root 0 Nov 12 15:31 host1 -> ../../devices/pci0000:00/0000:00:07.1/host1/scsi_host/host1
lrwxrwxrwx.  1 root root 0 Nov 12 15:31 host2 -> ../../devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2
本目录下有三个host,分别是host0,host1,host2,在这三个host中,需要确定本机是host0,host1还是host2,在确定host号后,通过重置相应的host存储缓存值就可以发现新添加的硬件了
4.确定需要重置的host号
利用grep命令,通过过滤smpspi模块的输出值来确定哪个host链接需要重置,分别查看host0,host1,host2,有mptspi模块值输出的,就是本机需要进行重置的host
# grep mpt /sys/class/scsi_host/host0/proc_name
# grep mpt /sys/class/scsi_host/host1/proc_name
host2的输出值是mptspi,最终确定host2是需要重置存储缓冲值的host
# grep mpt /sys/class/scsi_host/host2/proc_name
mptspi
5.确定host后,重置host2的存储缓存值
注:echo "- - -" > /sys/class/scsi_host/host2/scan  “ - - - ”定义了存储在host2中扫描内的三个值,本别是,通道号、SCSI目标ID、LUN值,该命令用通配符替换值,以便它可以检测附加到Linux主机上的新变化。
# echo "- - -" > /sys/class/scsi_host/host2/scan
6.再次查看fdisk,发现系统已经发现新添加的磁盘了,实验完成。
# fdisk -l 
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00066506
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        3264    26008576   8e  Linux LVM
Disk /dev/mapper/VolGroup-LogVol01: 24.5 GB, 24482152448 bytes

Disk /dev/mapper/VolGroup-LogVol00: 2147 MB, 2147483648 bytes

Disk /dev/sdb: 53.7 GB, 53687091200 bytes

Disk /dev/sdc: 32.2 GB, 32212254720 bytes

Disk /dev/sdd: 32.2 GB, 32212254720 bytes

Disk /dev/sde: 32.2 GB, 32212254720 bytes

Disk /dev/sdf: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

注:此处省略fdisk -l 详细输出信息

第二步、扩容LV

pvcreate /dev/sdc  ##创建新PV
vgextend centos /dev/sdc   ##将新的PV加入到现有的VG
lvextend -l +2559  /dev/centos/root  ##LV扩容lvresize或者lvextend

[root@node1 scsi_host]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        17G   17G  152K 100% /
##文件系统仍未扩容
##需要扩容的是xfs,则需要xfs_growfs命令
xfs_growfs /dev/centos/root   ##扩容xfs文件系统
##如果是ext3,ext4等,需要使用resizefs命令
##再次查看df
[root@node1 scsi_host]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        27G   17G   10G  63% /
##完成文件系统扩容

参考自https://jingyan.baidu.com/article/25648fc18f22b29191fd0011.html
转自https://blog.csdn.net/Evils798/article/details/78510187?locationNum=10&fps=1

猜你喜欢

转载自blog.csdn.net/cyan_grey/article/details/81978869
lv
今日推荐