michael1983
作者michael19832019-01-06 21:30
技术总监, 某证券

Linux 下使用udev永久绑定带库设备方法

字数 7130阅读 2401评论 0赞 3

Linux 下使用udev永久绑定带库设备方法

在Linux 系统下配置带库设备,传统的方法是当安装完lin_tape驱动后会在/dev/路径下生成IBMtape,IBMchanger 这样的驱动设备,如果只接入一个带库,直接在TSM中绑定该设备名即可,但是当接入多个带库时,由于使用Linux 设备管理机制,当系统重启后SCSI ID顺序会发生变化,导致驱动设备文件对应的物理设备信息不准确。

故障现象
未使用UDEV绑定设备前
[root@LOCAL ~]# cat /proc/scsi/IBMt*
lin_tape version: 2.9.4
lin_tape major number: 244
Attached Tape Devices:
Number model SN HBA SCSI FO Path
0 ULT3580-TD6 00078B555F qla2xxx 0:0:2:0 NA
1 ULT3580-TD6 00078B5549 qla2xxx 0:0:3:0 NA
2 ULT3580-TD6 00078B5502 qla2xxx 0:0:4:0 NA
3 ULT3580-TD6 00078B555D qla2xxx 3:0:2:0 NA
4 ULT3580-TD6 00078B555E qla2xxx 3:0:3:0 NA

在系统重启后, 查看驱动器对应SCSI ID 如下:
[root@LOCAL~]# cat /proc/scsi/IBMt*
lin_tape version: 2.9.4
lin_tape major number: 244
Attached Tape Devices:
Number model SN HBA SCSI FO Path
0 ULTRIUM-TD4 9340370001 qla2xxx 0:0:0:1 NA
1 ULTRIUM-TD4 9340370002 qla2xxx 0:0:0:2 NA
2 ULTRIUM-TD4 9340370003 qla2xxx 0:0:0:3 NA
3 ULTRIUM-TD4 9340370004 qla2xxx 0:0:0:4 NA
4 ULTRIUM-TD4 9340370005 qla2xxx 0:0:0:5 NA

解决办法
1.查找设备序列号与drive对应关系
[root@LOCAL dev]# cat /proc/scsi/IBMt*
lin_tape version: 2.9.4
lin_tape major number: 244
Attached Tape Devices:
Number model SN HBA SCSI FO Path
0 ULTRIUM-TD4 9340370001 qla2xxx 0:0:1:1 NA
1 ULTRIUM-TD4 9340370002 qla2xxx 0:0:1:2 NA
2 ULTRIUM-TD4 9340370003 qla2xxx 0:0:1:3 NA
3 ULTRIUM-TD4 9340370004 qla2xxx 0:0:1:4 NA
4 ULTRIUM-TD4 9340370005 qla2xxx 0:0:1:5 NA
5 ULTRIUM-TD4 9340370006 qla2xxx 0:0:1:6 NA
2.创建绑定设备文件
cd /etc/udev/reles.d/
cp 70-persistent-cd.rules 100-persistent-lintape.rules
vi 100-persistent-lintape.rules

This file was automatically generated by the /lib/udev/write_cd_rules

program, run by the cd-aliases-generator.rules rules file.

You can modify it, as long as you keep each rule on a single

line, and set the $GENERATED variable.

DVDRAM_GTA0N (pci-0000:00:1f.2-scsi-0:0:0:0)

KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="9340370001",SYMLINK="lin_tape/by-id/DD_Drive01_9340370001"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="9340370002",SYMLINK="lin_tape/by-id/DD_Drive02_9340370002"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="9340370003",SYMLINK="lin_tape/by-id/DD_Drive03_9340370003"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="9340370004",SYMLINK="lin_tape/by-id/DD_Drive04_9340370004"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="9340370005",SYMLINK="lin_tape/by-id/DD_Drive05_9340370005"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="9340370006",SYMLINK="lin_tape/by-id/DD_Drive06_9340370006"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="9340370007",SYMLINK="lin_tape/by-id/DD_Drive07_9340370007"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="9340370008",SYMLINK="lin_tape/by-id/DD_Drive08_9340370008"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="9340370009",SYMLINK="lin_tape/by-id/DD_Drive09_9340370009"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="934037000A",SYMLINK="lin_tape/by-id/DD_Drive10_934037000A"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="934037000B",SYMLINK="lin_tape/by-id/DD_Drive11_934037000B"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="934037000C",SYMLINK="lin_tape/by-id/DD_Drive12_934037000C"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="934037000D",SYMLINK="lin_tape/by-id/DD_Drive13_934037000D"
KERNEL=="IBMtape*[!n]", ATTR{serial_num}=="934037000E",SYMLINK="lin_tape/by-id/DD_Drive14_934037000E"
KERNEL=="IBMtape*[!n]",

3.重启机器后查看对应的配置文件是否生成
ls -al /dev/lin_tape/by-id
total 0
drwxr-xr-x 2 root root 600 Jan 22 10:35 .
drwxr-xr-x 3 root root 60 Jan 22 10:35 ..
lrwxrwxrwx 1 root root 14 Jan 22 10:35 DD_Drive01_9340370001 -> ../../IBMtape0
lrwxrwxrwx 1 root root 14 Jan 22 10:35 DD_Drive02_9340370002 -> ../../IBMtape1
lrwxrwxrwx 1 root root 14 Jan 22 10:35 DD_Drive03_9340370003 -> ../../IBMtape2
lrwxrwxrwx 1 root root 14 Jan 22 10:35 DD_Drive04_9340370004 -> ../../IBMtape3
lrwxrwxrwx 1 root root 14 Jan 22 10:35 DD_Drive05_9340370005 -> ../../IBMtape4
lrwxrwxrwx 1 root root 14 Jan 22 10:35 DD_Drive06_9340370006 -> ../../IBMtape5
lrwxrwxrwx 1 root root 14 Jan 22 10:35 DD_Drive07_9340370007 -> ../../IBMtape6
lrwxrwxrwx 1 root root 14 Jan 22 10:35 DD_Drive08_9340370008 -> ../../IBMtape7
lrwxrwxrwx 1 root root 14 Jan 22 10:35 DD_Drive09_9340370009 -> ../../IBMtape8
lrwxrwxrwx 1 root root 14 Jan 22 10:35 DD_Drive10_934037000A -> ../../IBMtape9
lrwxrwxrwx 1 root root 15 Jan 22 10:35 DD_Drive11_934037000B -> ../../IBMtape12
lrwxrwxrwx 1 root root 15 Jan 22 10:35 DD_Drive12_934037000C -> ../../IBMtape13
lrwxrwxrwx 1 root root 15 Jan 22 10:35 DD_Drive13_934037000D -> ../../IBMtape14
lrwxrwxrwx 1 root root 15 Jan 22 10:35 DD_Drive14_934037000E -> ../../IBMtape15
lrwxrwxrwx 1 root root 15 Jan 22 10:35 DD_Drive15_934037000F -> ../../IBMtape16
lrwxrwxrwx 1 root root 15 Jan 22 10:35 DD_Drive16_9340370010 -> ../../IBMtape17
lrwxrwxrwx 1 root root 15 Jan 22 10:35 DD_Drive17_9340370011 -> ../../IBMtape18
4.查看绑定的设备对应是否正确:

[root@LOCAL dev]# udevadm info --attribute-walk --name /dev/IBMtape1

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

looking at device '/devices/pci0000:00/0000:00:03.0/0000:06:00.0/host0/rport-0:0-1/target0:0:1/0:0:1:2/lin_tape/IBMtape1':

KERNEL=="IBMtape1"
SUBSYSTEM=="lin_tape"
DRIVER==""
ATTR{serial_num}=="9340370002"
ATTR{ww_node_name}==""
ATTR{ww_port_name}==""
ATTR{primary_path}=="NA"
ATTR{sys_encryption_proxy}=="1"
ATTR{sys_encryption_write}=="2"

looking at parent device '/devices/pci0000:00/0000:00:03.0/0000:06:00.0/host0/rport-0:0-1/target0:0:1/0:0:1:2':

KERNELS=="0:0:1:2"
SUBSYSTEMS=="scsi"
DRIVERS=="lin_tape"

也可以使用命令modprobe -r lin_tape
modprobe lin_tape 替代重启操作,但是实际中提示设备在使用,没有实现

5.使用以下命令在TSM中定义drive
Define drive MLDD670 drive00 serial=autod element=autod online=yes cleanfreq=asneeded

define path KZX-MLTSM drive00 srctype=server desttype=drive library=MLDD670 device=/dev/lin_tape/by-id/DD_Drive01_9340370001 online=yes

经切换及重启测试,都能正常备份,设备使用正常

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

3

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广