我的OS是RHEL6.2,
需要对99块逻辑卷进行raw设备映射,使用udev来对raw进行管理
修改/etc/udev/rules.d/60-raw.rules:
ACTION=="add", KERNEL=="/dev/mapper/oracle_vg01-rlvoracle01", RUN+="/bin/raw /dev/raw/raw1 %N" ACTION=="add", ENV{MAJOR}=="253",ENV{MINOR}=="7", RUN+="/bin/raw /dev/raw/raw1 %M %m" //这两行是必须的。 ...... ACTION=="add", KERNEL=="/dev/mapper/oracle_vg01-rlvoracle98", RUN+="/bin/raw /dev/raw/raw98 %N" ACTION=="add", ENV{MAJOR}=="253",ENV{MINOR}=="104", RUN+="/bin/raw /dev/raw/raw98 %M %m" ACTION=="add", KERNEL=="/dev/mapper/oracle_vg01-rlvoracle99", RUN+="/bin/raw /dev/raw/raw99 %N" ACTION=="add", ENV{MAJOR}=="253",ENV{MINOR}=="105", RUN+="/bin/raw /dev/raw/raw99 %M %m"
配置完了之后start_udev重启udev。
发现实际只映射成功了94块逻辑卷:
[root@localhost ~]# raw -qa /dev/raw/raw1: bound to major 253, minor 7 /dev/raw/raw2: bound to major 253, minor 8 /dev/raw/raw3: bound to major 253, minor 9 /dev/raw/raw4: bound to major 253, minor 10 .... /dev/raw/raw90: bound to major 253, minor 96 /dev/raw/raw91: bound to major 253, minor 97 /dev/raw/raw92: bound to major 253, minor 98 /dev/raw/raw93: bound to major 253, minor 99 /dev/raw/raw94: bound to major 253, minor 100
剩余的几块逻辑卷(95,96,97,98,99)却没有映射工程。
手动进行映射:
[root@localhost ~]# raw /dev/raw/raw95 /dev/mapper/oracle_vg01-rlvoracle95 /dev/raw/raw95: bound to major 253, minor 96 [root@localhost ~]# raw /dev/raw/raw96 /dev/mapper/oracle_vg01-rlvoracle96 /dev/raw/raw96: bound to major 253, minor 97 [root@localhost ~]# raw /dev/raw/raw97 /dev/mapper/oracle_vg01-rlvoracle97 /dev/raw/raw97: bound to major 253, minor 98 [root@localhost ~]# raw /dev/raw/raw98 /dev/mapper/oracle_vg01-rlvoracle98 /dev/raw/raw98: bound to major 253, minor 99
发现新的设备的minor号与配置文件中的设备minor居然相同,显然这个是异常的。
那么问题出现在什么地方呢,首先的问题是手动映射的minor号是怎么的分配出来的呢?
我找了调查了2天,偶然发现设备的Block device与raw设备映射的信息一致
[root@localhost ~]# lvdisplay /dev/mapper/oracle_vg01-rlvoracle98 --- Logical volume --- LV Name /dev/oracle_vg01/rlvoracle98 VG Name oracle_vg01 LV UUID FH4b9q-jccY-6I74-G9CT-apYr-XSU7-RcIqaH LV Write Access read/write LV Status available # open 0 LV Size 12.00 MiB Current LE 3 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:99
多做了几次比对,得出的结论是:
手动映射的major与minor号就是根据这里的Block device生成的。
而我之前/etc/udev/rules.d/60-raw.rules中人为的指定的minor号与设备自身的Block device不一致,这就导致了udev在管理raw设备的时候出现了问题。
那么此类问题的解决方法:
1./etc/udev/rules.d/60-raw.rules中的要根据设备的Block device(lvdisplay /dev/mapper/oracle_vg01-rlvoracle98)来设置设备的major与minor号。
2.不用udev来管理raw,修改rc.local文件.
参考http://space.itpub.net/?uid-231499-action-viewspace-itemid-63884
需要说明的是,rc.local文件实际上就是raw /dev/raw/rawN /dev/mapper/oracle_vg01-rlvoracleN。
另外一点需要重点说明,
1.major与minor的这种异常,在建立基于raw设备的oracle数据库的表空间的时候,会导致莫名其妙的device busy错误,而这种device busy,即使你使用fuser 或者lsof也查看不到设备的使用者,google上根本就查不到,我也是偶然件发现这个异常以及原因。
SQL> alter tablespace test add datafile '/dev/raw/raw4' size 4090m; alter tablespace test add datafile '/dev/raw/raw4' size 4090m * ERROR at line 1: ORA-01119: error in creating database file '/dev/raw/raw4' ORA-27041: unable to open file Linux-x86_64 Error: 16: Device or resource busy Additional information: 1
2.使用dd if=/dev/raw/rawN of=/dev/raw/rawM也会出现莫名奇妙的device busy
我把这点宝贵的经验写出来,给自己提个醒,也给大家做个参考。