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設備詳細信息的命令
[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]
[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