生产系统在没有计划重启的情况下,不是随时都可以重启,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,4块30GB后
利用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 详细输出信息
不重启Linux主机来识别新加的硬盘
最新推荐文章于 2024-07-31 13:23:32 发布