如何在Linux中检查LUN或者SAN磁盘
时间:2020-03-05 15:27:00 来源:igfitidea点击:
当我们在存储环境中工作时,通常希望添加,删除或者重新大小存储设备。
分配存储后,我们需要扫描并验证分配的存储SAN磁盘。
在本文中,我将显示命令在Linux系统中检查/标识所附的LUN信息。
什么是LUN
LUN是逻辑单元号。
它可用于引用整个物理磁盘或者更大的物理磁盘或者磁盘卷的子集。
物理磁盘或者磁盘卷可以是整个单个磁盘驱动器,单个磁盘驱动器的分区(子集),或者来自RAID控制器的DiskVolume,包括多个磁盘驱动器聚合在一起,以实现更大的容量和冗余。
1)在Linux中查看添加的LUN或者SAN磁盘
要从Linux中的存储设备检查所附LUN,我们可以使用"/proc/scsi/scsi"文件内容",但它会给我们一些信息,我们无法将物理连接的驱动器区分为LUN。
显示如下所示的内容
# cat /proc/scsi/scsi Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi0 Channel: 00 Id: 01 Lun: 00 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi0 Channel: 00 Id: 02 Lun: 00 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 00 Lun: 00 Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00 Type: CD-ROM ANSI SCSI revision: 05 Host: scsi3 Channel: 00 Id: 00 Lun: 00 Vendor: LIO-ORG Model: block Rev: 4.0 Type: Direct-Access ANSI SCSI revision: 05 Host: scsi3 Channel: 00 Id: 00 Lun: 01 Vendor: LIO-ORG Model: block2 Rev: 4.0 Type: Direct-Access ANSI SCSI revision: 05 Host: scsi3 Channel: 00 Id: 00 Lun: 02 Vendor: LIO-ORG Model: rhelblock Rev: 4.0 Type: Direct-Access ANSI SCSI revision: 05
通常LUN将显示为"主机:SCSI3通道:00 ID:00 LUN:00"
下面是它使用不同的存储供应商的同一文件的另一个示例。
CAT/PROC/SCSI/SCSI
Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: HP 36.4G Model: MAN3367MC Rev: HP05 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 00 Lun: 00 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003 Type: Unknown ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 00 Lun: 02 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 00 Lun: 03 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 01 Lun: 00 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003 Type: Unknown ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 01 Lun: 02 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 01 Lun: 03 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003
我们可以使用iSCSIADM(仅使用iSCSI Target时的存储)命令获取有关连接LUN的信息。
# iscsiadm -m session -P 3 iSCSI Transport Class version 2.0-870 version 6.2.0.873-35 Target: iqn.2016-06.com.theitroad:target1 (non-flash) Current Portal: 172.16.20.139:3260,1 Persistent Portal: 172.16.20.139:3260,1 ** Interface: ** ............ ............ Attached SCSI devices: Host Number: 3 State: running scsi3 Channel 00 Id 0 Lun: 0 Attached scsi disk sdd State: running scsi3 Channel 00 Id 0 Lun: 1 Attached scsi disk sde State: running scsi3 Channel 00 Id 0 Lun: 2 Attached scsi disk sdf State: running
我们还可以查看以下LUN信息的以下路径。
# ls /dev/disk/by-path/ ip-172.16.20.139:3260-iscsi-iqn.2016-06.com.theitroad:target1-lun-0 ip-172.16.20.139:3260-iscsi-iqn.2016-06.com.theitroad:target1-lun-1 ip-172.16.20.139:3260-iscsi-iqn.2016-06.com.theitroad:target1-lun-2 pci-0000:00:07.1-ata-2.0 pci-0000:00:10.0-scsi-0:0:0:0 pci-0000:00:10.0-scsi-0:0:0:0-part1 pci-0000:00:10.0-scsi-0:0:0:0-part2 pci-0000:00:10.0-scsi-0:0:1:0 pci-0000:00:10.0-scsi-0:0:2:0
此外,请尝试使用dmesg命令
# dmesg | grep -i "attached " Attached scsi disk sda at scsi0, channel 0, id 0, lun 0 Attached scsi disk sdb at scsi2, channel 0, id 0, lun 2 Attached scsi disk sdc at scsi2, channel 0, id 0, lun 3 Attached scsi disk sdd at scsi2, channel 0, id 1, lun 2
2)使用MultiPath命令
Redhat默认多路径服务是MuliPathd守护程序。
下面的命令来自使用MultiPathd守护程序启用多路径的服务器,并且从其输出可以检查OS标识的LUN信息。
# multipath -v4 -ll Jun 21 04:58:40 | loading /lib64/multipath/libcheckdirectio.so checker Jun 21 04:58:40 | loading /lib64/multipath/libprioconst.so prioritizer Jun 21 04:58:40 | Discover device /sys/devices/pci0000:00/0000:00:07.1/ata2/host2/target2:0:0/2:0:0:0/block/sr0 Jun 21 04:58:40 | sr0: device node name blacklisted Jun 21 04:58:40 | Discover device /sys/devices/pci0000:00/0000:00:10.0/host0/target0:0:0/0:0:0:0/block/sda ................................ ................................ ===== paths list ===== uuid hcil dev dev_t pri dm_st chk_st vend/prod/rev dev_st 0:0:0:0 sda 8:0 -1 undef ready VMware, ,VMware Virtual S running 0:0:1:0 sdb 8:16 -1 undef ready VMware, ,VMware Virtual S running 0:0:2:0 sdc 8:32 -1 undef ready VMware, ,VMware Virtual S running 3:0:0:0 sdd 8:48 -1 undef ready LIO-ORG ,block running 3:0:0:1 sde 8:64 -1 undef ready LIO-ORG ,block2 running 3:0:0:2 sdf 8:80 -1 undef ready LIO-ORG ,rhelblock running Jun 21 04:58:40 | directio checker refcount 6 Jun 21 04:58:40 | directio checker refcount 5 Jun 21 04:58:40 | directio checker refcount 4 Jun 21 04:58:40 | directio checker refcount 3 Jun 21 04:58:40 | directio checker refcount 2 Jun 21 04:58:40 | directio checker refcount 1 Jun 21 04:58:40 | unloading const prioritizer Jun 21 04:58:40 | unloading directio checker