Linux multipath与SCSI ID
Scsi_id命令包含在udev程序包中,可以在multipath.conf中配置该程序来获取scsi设备的SCSI ID。通过SCSI ID,便可以判断多个路径对应了同一设备。这个是多路径实现的关键。scsi_id是通过sg驱动,向设备发送EVPD page80或page83 的inquery命令来查询scsi设备的标识。但一些设备并不支持EVPD 的inquery命令,所以他们无法被用来生成multipath设备。如果这样,据说可以手工改写scsi_id,为不能提供scsi设备标识的设备虚拟一个标识符,并输出到标准输出,但是改写SCSI ID的方法不详。
multipath程序在创建multipath设备时,会调用scsi_id,从其标准输出中获得该设备的scsi id。
1. 几个查看SCSI设备详细信息的命令
l cat /proc/scsi/scsi
[root@centos-i2lb]# cat /proc/scsi/scsi
Attacheddevices:
Host: scsi1Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev:1.00
Type: CD-ROM ANSI SCSI revision: 05
Host: scsi2Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi6Channel: 00 Id: 00 Lun: 00
Vendor: IET Model: Controller Rev: 0001
Type: RAID ANSI SCSI revision: 05
Host: scsi5Channel: 00 Id: 00 Lun: 00
Vendor: IET Model: Controller Rev: 0001
Type: RAID ANSI SCSI revision: 05
Host: scsi5Channel: 00 Id: 00 Lun: 01
Vendor: lb Model: lb_iscsi Rev: 01
Type: Direct-Access ANSI SCSI revision: 05
Host: scsi6Channel: 00 Id: 00 Lun: 01
Vendor: lb Model: lb_iscsi Rev: 01
Type: Direct-Access ANSI SCSI revision: 05
Lsscsi工具(需要安装)
[root@centos-i2lb]# lsscsi -v
[1:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0
dir: /sys/bus/scsi/devices/1:0:0:0 [/sys/devices/pci0000:00/0000:00:07.1/host1/target1:0:0/1:0:0:0]
[2:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda
dir: /sys/bus/scsi/devices/2:0:0:0 [/sys/devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0]
[5:0:0:0] storage IET Controller 0001 -
dir: /sys/bus/scsi/devices/5:0:0:0 [/sys/devices/platform/host5/session3/target5:0:0/5:0:0:0]
[5:0:0:1] disk lb lb_iscsi 01 /dev/sdb
dir: /sys/bus/scsi/devices/5:0:0:1 [/sys/devices/platform/host5/session3/target5:0:0/5:0:0:1]
[6:0:0:0] storage IET Controller 0001 -
dir: /sys/bus/scsi/devices/6:0:0:0 [/sys/devices/platform/host6/session4/target6:0:0/6:0:0:0]
[6:0:0:1] disk lb lb_iscsi 01 /dev/sdc
dir: /sys/bus/scsi/devices/6:0:0:1 [/sys/devices/platform/host6/session4/target6:0:0/6:0:0:1]
l ls –rtl /dev/disk/by-id
[root@centos-i2lb]# ls -rtl /dev/disk/by-id
total 0
lrwxrwxrwx. 1root root 9 Apr 7 13:16ata-VMware_Virtual_IDE_CDROM_Drive_10000000000000000001 -> ../../sr0
lrwxrwxrwx. 1root root 10 Apr 7 13:16lvm-pv-uuid-K3FudW-pVbU-3CxO-vYbz-JQgt-7cMD-trWZfc -> ../../sda2
lrwxrwxrwx. 1root root 10 Apr 7 13:16dm-uuid-LVM-6OQeAXlfx14VazFp21YfwgbtSE3P0IH1BMNhZdogpE93EoKvCxT3KZcCAqVmjG6M-> ../../dm-1
lrwxrwxrwx. 1root root 10 Apr 7 13:16dm-name-vg_centosi2-lv_swap -> ../../dm-1
lrwxrwxrwx. 1root root 10 Apr 7 13:16dm-uuid-LVM-6OQeAXlfx14VazFp21YfwgbtSE3P0IH129JpYlBs33F2gS64l2eNyeeIasmtvu2O-> ../../dm-0
lrwxrwxrwx. 1root root 10 Apr 7 13:16dm-name-vg_centosi2-lv_root -> ../../dm-0
lrwxrwxrwx. 1root root 9 Apr 7 13:28 scsi-1IET_00010001 -> ../../sdb
lrwxrwxrwx. 1root root 10 Apr 7 13:28dm-uuid-mpath-1IET\x20\x20\x20\x20\x2000010001 -> ../../dm-2
lrwxrwxrwx. 1root root 10 Apr 7 13:28 dm-name-yellow-> ../../dm-2
lrwxrwxrwx. 1root root 10 Apr 7 13:28dm-uuid-part1-mpath-1IET\x20\x20\x20\x20\x2000010001 -> ../../dm-3
lrwxrwxrwx. 1root root 10 Apr 7 13:28dm-name-yellowp1 -> ../../dm-3
ls –rtl /dev/disk/by-id
[root@centos-i2lb]# ls -rtl /dev/disk/by-path
total 0
lrwxrwxrwx. 1root root 9 Apr 7 13:16 pci-0000:00:10.0-scsi-0:0:0:0 ->../../sda
lrwxrwxrwx. 1root root 9 Apr 7 13:16 pci-0000:00:07.1-scsi-1:0:0:0 ->../../sr0
lrwxrwxrwx. 1root root 10 Apr 7 13:16pci-0000:00:10.0-scsi-0:0:0:0-part2 -> ../../sda2
lrwxrwxrwx. 1root root 10 Apr 7 13:16pci-0000:00:10.0-scsi-0:0:0:0-part1 -> ../../sda1
lrwxrwxrwx. 1root root 9 Apr 7 13:28ip-192.168.136.101:3260-iscsi-iqn.2017-03.centos-i1:target1-lun-1 ->../../sdc
lrwxrwxrwx. 1root root 9 Apr 7 13:28ip-192.168.20.101:3260-iscsi-iqn.2017-03.centos-i1:target1-lun-1 ->../../sdb
2. Linustorvalds关于使用scsiid的争论
http://yarchive.net/comp/linux/scsi_ids.html