首先来简要的介绍下什么是udev,udev是Linux kernel 2.6系列的通用内核设备管理器,以守护进程的方式运行于Linux系统,并监听在新设备初始化或设备从系统中移除时,内核(通过netlink socket)
首先来简要的介绍下什么是udev,udev是Linux kernel 2.6系列的通用内核设备管理器,以守护进程的方式运行于Linux系统,并监听在新设备初始化或设备从系统中移除时,内核(通过netlink socket)所发出的uevent;简单点讲就是当有多块磁盘的时候,可以用udev来固定磁盘对应的设备名;之前在部署11g rac的时候都偏好使用asmlib,在最近一次的部署中asmlib出现了问题,而又没有时间去排错,因而采用udev部署,故而简单记录下udev的配置过程!
一:模拟共享盘阵,这里采用先划分lvm,再通过iscsi共享的方式来模拟
[root@db1 ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created [root@db1 ~]# vgcreate data /dev/sdb /dev/hdc: open failed: Read-only file system /dev/cdrom: open failed: Read-only file system Attempt to close device '/dev/cdrom' which is not open. Volume group "data" successfully created [root@db1 ~]# lvcreate -n crs1 -L 2G data Logical volume "crs1" created [root@db1 ~]# lvcreate -n crs2 -L 2G data Logical volume "crs2" created [root@db1 ~]# lvcreate -n crs3 -L 2G data Logical volume "crs3" created [root@db1 ~]# lvcreate -n data -L 10G data Logical volume "data" created [root@db1 ~]# lvcreate -n fra -L 10G data Logical volume "fra" created [root@db1 ~]# lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert crs1 data -wi-a- 2.00G crs2 data -wi-a- 2.00G crs3 data -wi-a- 2.00G data data -wi-a- 10.00G fra data -wi-a- 10.00G [root@db1 ~]# service tgtd start Starting SCSI target daemon: [ OK ] [root@db1 ~]# cat iscsi.sh tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2012-07-04.com.yang.rac:crs1 tgtadm --lld iscsi --op new --mode target --tid 2 -T iqn.2012-07-04.com.yang.rac:crs2 tgtadm --lld iscsi --op new --mode target --tid 3 -T iqn.2012-07-04.com.yang.rac:crs3 tgtadm --lld iscsi --op new --mode target --tid 4 -T iqn.2012-07-04.com.yang.rac:data tgtadm --lld iscsi --op new --mode target --tid 5 -T iqn.2012-07-04.com.yang.rac:fra tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/data/crs1 tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 2 -b /dev/data/crs2 tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 3 -b /dev/data/crs3 tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 4 -b /dev/data/data tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 5 -b /dev/data/fra tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL tgtadm --lld iscsi --op bind --mode target --tid 2 -I ALL tgtadm --lld iscsi --op bind --mode target --tid 3 -I ALL tgtadm --lld iscsi --op bind --mode target --tid 4 -I ALL tgtadm --lld iscsi --op bind --mode target --tid 5 -I ALL [root@db1 ~]# tgtadm --lld iscsi -o show -m target [root@db1 ~]# sh iscsi.sh [root@db1 ~]# tgtadm --lld iscsi -o show -m target Target 1: iqn.2012-07-04.com.yang.rac:crs1 System information: Driver: iscsi State: ready I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf1:0 SCSI SN: beaf10 Size: 0 MB Online: Yes Removable media: No Backing store: No backing store LUN: 1 Type: disk SCSI ID: deadbeaf1:1 SCSI SN: beaf11 Size: 2147 MB Online: Yes Removable media: No Backing store: /dev/data/crs1 LUN: 2 Type: disk SCSI ID: deadbeaf1:2 SCSI SN: beaf12 Size: 2147 MB Online: Yes Removable media: No Backing store: /dev/data/crs2 LUN: 3 Type: disk SCSI ID: deadbeaf1:3 SCSI SN: beaf13 Size: 2147 MB Online: Yes Removable media: No Backing store: /dev/data/crs3 LUN: 4 Type: disk SCSI ID: deadbeaf1:4 SCSI SN: beaf14 Size: 10737 MB Online: Yes Removable media: No Backing store: /dev/data/data LUN: 5 Type: disk SCSI ID: deadbeaf1:5 SCSI SN: beaf15 Size: 10737 MB Online: Yes Removable media: No Backing store: /dev/data/fra Account information: ACL information: ALL Target 2: iqn.2012-07-04.com.yang.rac:crs2 System information: Driver: iscsi State: ready I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf2:0 SCSI SN: beaf20 Size: 0 MB Online: Yes Removable media: No Backing store: No backing store Account information: ACL information: Target 3: iqn.2012-07-04.com.yang.rac:crs3 System information: Driver: iscsi State: ready I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf3:0 SCSI SN: beaf30 Size: 0 MB Online: Yes Removable media: No Backing store: No backing store Account information: ACL information: Target 4: iqn.2012-07-04.com.yang.rac:data System information: Driver: iscsi State: ready I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf4:0 SCSI SN: beaf40 Size: 0 MB Online: Yes Removable media: No Backing store: No backing store Account information: ACL information: Target 5: iqn.2012-07-04.com.yang.rac:fra System information: Driver: iscsi State: ready I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf5:0 SCSI SN: beaf50 Size: 0 MB Online: Yes Removable media: No Backing store: No backing store Account information: ACL information:
二:在客户端上挂载前面模拟出的共享磁盘阵列
[root@db2 ~]# iscsiadm --mode discovery --type sendtargets --portal 192.168.123.10 192.168.123.10:3260,1 iqn.2012-07-04.com.yang.rac:fra 192.168.123.10:3260,1 iqn.2012-07-04.com.yang.rac:crs1 192.168.123.10:3260,1 iqn.2012-07-04.com.yang.rac:crs3 192.168.123.10:3260,1 iqn.2012-07-04.com.yang.rac:data 192.168.123.10:3260,1 iqn.2012-07-04.com.yang.rac:crs2 [root@db2 ~]# iscsiadm --mode node --targetname iqn.2012-07-04.com.yang.rac:crs1 --portal 192.168.123.10 --login [root@db2 ~]# iscsiadm --mode node --targetname iqn.2012-07-04.com.yang.rac:crs2 --portal 192.168.123.10 --login [root@db2 ~]# iscsiadm --mode node --targetname iqn.2012-07-04.com.yang.rac:crs3 --portal 192.168.123.10 --login [root@db2 ~]# iscsiadm --mode node --targetname iqn.2012-07-04.com.yang.rac:data --portal 192.168.123.10 --login [root@db2 ~]# iscsiadm --mode node --targetname iqn.2012-07-04.com.yang.rac:fra --portal 192.168.123.10 --login [root@db2 ~]# fdisk -l Disk /dev/sda: 85.8 GB, 85899345920 bytes 255 heads, 63 sectors/track, 10443 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 523 4096575 82 Linux swap / Solaris /dev/sda3 524 10443 79682400 83 Linux Disk /dev/sdb: 2147 MB, 2147483648 bytes 67 heads, 62 sectors/track, 1009 cylinders Units = cylinders of 4154 * 512 = 2126848 bytes Disk /dev/sdb doesn't contain a valid partition table Disk /dev/sdc: 2147 MB, 2147483648 bytes 67 heads, 62 sectors/track, 1009 cylinders Units = cylinders of 4154 * 512 = 2126848 bytes Disk /dev/sdc doesn't contain a valid partition table Disk /dev/sdd: 2147 MB, 2147483648 bytes 67 heads, 62 sectors/track, 1009 cylinders Units = cylinders of 4154 * 512 = 2126848 bytes Disk /dev/sdd doesn't contain a valid partition table Disk /dev/sde: 10.7 GB, 10737418240 bytes 64 heads, 32 sectors/track, 10240 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Disk /dev/sde doesn't contain a valid partition table Disk /dev/sdf: 10.7 GB, 10737418240 bytes 64 heads, 32 sectors/track, 10240 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Disk /dev/sdf doesn't contain a valid partition table
三:开始配置udev
[root@db2 ~]# uname -r //在本例中操作系统的版本位centos5.4 64bit 2.6.18-164.el5 [root@db2 ~]# lsb_release -a LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch Distributor ID: CentOS Description: CentOS release 5.4 (Final) Release: 5.4 Codename: Final [root@db2 ~]# rpm -qa |grep udev udev-095-14.21.el5 [root@db2 ~]# ps -ef |grep udev root 4646 1 0 10:14 ? 00:00:00 /sbin/udevd -d root 6023 3039 0 10:32 pts/0 00:00:00 grep udev [root@db2 ~]# grep -v ^# /etc/udev/udev.conf |grep -v ^$ udev_log="err" [root@db2 ~]# scsi_id -g -u -s /block/sdb S_beaf11 [root@db2 ~]# scsi_id -g -u -s /block/sdc S_beaf12 [root@db2 ~]# scsi_id -g -u -s /block/sdd S_beaf13 [root@db2 ~]# scsi_id -g -u -s /block/sde S_beaf14 [root@db2 ~]# scsi_id -g -u -s /block/sdf S_beaf15 [root@db2 ~]# cat /etc/udev/rules.d/99-raw.rules KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="S_beaf11", NAME="asmdisk1", OWNER="grid", GROUP="asmadmin", MODE="0660" KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="S_beaf12", NAME="asmdisk2", OWNER="grid", GROUP="asmadmin", MODE="0660" KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="S_beaf13", NAME="asmdisk3", OWNER="grid", GROUP="asmadmin", MODE="0660" KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="S_beaf14", NAME="asmdisk4", OWNER="grid", GROUP="asmadmin", MODE="0660" KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="S_beaf15", NAME="asmdisk5", OWNER="grid", GROUP="asmadmin", MODE="0660" [root@db2 ~]# ll /dev/asm* ls: /dev/asm*: No such file or directory [root@db2 ~]# /sbin/udevcontrol reload_rules [root@db2 ~]# /sbin/start_udev Starting udev: [ OK ] [root@db2 ~]# ll /dev/asm* brw-rw---- 1 grid asmadmin 8, 16 Jul 4 12:05 /dev/asmdisk1 brw-rw---- 1 grid asmadmin 8, 32 Jul 4 12:05 /dev/asmdisk2 brw-rw---- 1 grid asmadmin 8, 48 Jul 4 12:05 /dev/asmdisk3 brw-rw---- 1 grid asmadmin 8, 64 Jul 4 12:05 /dev/asmdisk4 brw-rw---- 1 grid asmadmin 8, 80 Jul 4 12:05 /dev/asmdisk5
备注:
1:在vmware中,scsi_id -g -u -s /block/sdb默认是不会出现uuid,需要修改vmx文件,添加disk.EnableUUID参数
2:/block/sdb实际上是个不存在的路径,实际绝对路径是/sys/block/sdb,但使用scsi_id命令的时候必须用/block/sdb路径
参考:
http://diznix.com/2011/05/21/the-case-of-vmware-and-the-missing-scsi-id/
http://space.itpub.net/14184018/viewspace-701675
【文章转自
韩国站群多ip服务器 http://www.558idc.com/krzq.html处的文章,转载请说明出处】