使用udev管理asmdisk常用的命令

使用udev管理asmdisk常用的几条命令,下面通过udev给asm增加一块disk来验证一下几条命令的作用:
[root@udev bin]# pwd
/usr/bin
[root@udev bin]# ls udev*
udevinfo  udevtest
[root@udev sbin]# pwd
/sbin
[root@udev sbin]# ls *udev*
start_udev  udevcontrol  udevd  udevd.static  udevsettle  udevtrigger
[root@udev sbin]#
--==================================
1.在vmware下增加一块disk
2.启动linux
3.fdisk -l 显示新加入的disk:

[root@udev ~]# fdisk -l /dev/sdf

Disk /dev/sdf: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdf doesn't contain a valid partition table
[root@udev ~]#
4.对新加入的disk分区:

[root@udev ~]# fdisk /dev/sdf
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdf: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): +100m  

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@udev ~]#
5.使用udevinfo显示分区信息:

[root@udev ~]#  udevinfo -a -p /sys/block/sdf/sdf1

Udevinfo 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 '/block/sdf/sdf1':
    KERNEL=="sdf1"
    SUBSYSTEM=="block"
    SYSFS{dev}=="8:81"
    SYSFS{partition}=="1"
    SYSFS{start}=="63"
    SYSFS{size}=="208782"
    SYSFS{ro}=="0"
    SYSFS{alignment_offset}=="0"
    SYSFS{discard_alignment}=="0"
    SYSFS{stat}=="      24      518     1084        4        0        0        0        0        0        3        4"
    SYSFS{inflight}=="       0        0"

  looking at parent device '/block/sdf':
    ID=="sdf"
    BUS=="block"
    DRIVER==""
    SYSFS{dev}=="8:80"
    SYSFS{range}=="16"
    SYSFS{ext_range}=="256"
    SYSFS{removable}=="0"
    SYSFS{ro}=="0"
    SYSFS{size}=="16777216"
    SYSFS{alignment_offset}=="0"
    SYSFS{discard_alignment}=="0"
    SYSFS{capability}=="50"
    SYSFS{stat}=="     122     1286     4760       28        1        0        8       59        0       85       87"
    SYSFS{inflight}=="       0        0"
    SYSFS{events}==""
    SYSFS{events_async}==""
    SYSFS{events_poll_msecs}=="-1"

  looking at parent device '/devices/pci0000:00/0000:00:10.0/host0/target0:0:5/0:0:5:0':
    ID=="0:0:5:0"
    BUS=="scsi"
    DRIVER=="sd"
    SYSFS{device_blocked}=="0"
    SYSFS{type}=="0"
    SYSFS{scsi_level}=="3"
    SYSFS{vendor}=="VMware, "
    SYSFS{model}=="VMware Virtual S"
    SYSFS{rev}=="1.0 "
    SYSFS{state}=="running"
    SYSFS{timeout}=="60"
    SYSFS{iocounterbits}=="32"
    SYSFS{iorequest_cnt}=="0xa4"
    SYSFS{iodone_cnt}=="0xa4"
    SYSFS{ioerr_cnt}=="0xa"
    SYSFS{modalias}=="scsi:t-0x00"
    SYSFS{evt_media_change}=="0"
    SYSFS{dh_state}=="detached"
    SYSFS{queue_depth}=="32"
    SYSFS{queue_ramp_up_period}=="120000"
    SYSFS{queue_type}=="simple"

  looking at parent device '/devices/pci0000:00/0000:00:10.0/host0/target0:0:5':
    ID=="target0:0:5"
    BUS=="scsi"
    DRIVER==""
    SYSFS{uevent}=="DEVTYPE=scsi_target"

  looking at parent device '/devices/pci0000:00/0000:00:10.0/host0':
    ID=="host0"
    BUS=="scsi"
    DRIVER==""
    SYSFS{uevent}=="DEVTYPE=scsi_host"

  looking at parent device '/devices/pci0000:00/0000:00:10.0':
    ID=="0000:00:10.0"
    BUS=="pci"
    DRIVER=="mptspi"
    SYSFS{vendor}=="0x1000"
    SYSFS{device}=="0x0030"
    SYSFS{subsystem_vendor}=="0x15ad"
    SYSFS{subsystem_device}=="0x1976"
    SYSFS{class}=="0x010000"
    SYSFS{irq}=="17"
    SYSFS{local_cpus}=="3"
    SYSFS{local_cpulist}=="0-1"
    SYSFS{modalias}=="pci:v00001000d00000030sv000015ADsd00001976bc01sc00i00"
    SYSFS{numa_node}=="-1"
    SYSFS{dma_mask_bits}=="64"
    SYSFS{consistent_dma_mask_bits}=="64"
    SYSFS{enable}=="1"
    SYSFS{broken_parity_status}=="0"
    SYSFS{msi_bus}==""
    SYSFS{msi_irqs}==""

  looking at parent device '/devices/pci0000:00':
    ID=="pci0000:00"
    BUS==""
    DRIVER==""
    SYSFS{uevent}==""

[root@udev ~]#
6.编辑udev的rule文件,增加下面一行到/etc/udev/rules.d/99-oracle-asmdevices.rules里面:
KERNEL=="sdf1", SUBSYSTEM=="block", SYSFS{size}=="208782", SYSFS{start}=="63", NAME="asmdisk4-data1", OWNER="grid", GROUP="asmadmin", MODE="0660"
7.增加上面一行之后/etc/udev/rules.d/99-oracle-asmdevices.rules的内容如下:
[root@udev rules.d]# more 99-oracle-asmdevices.rules
KERNEL=="sdc1", SUBSYSTEM=="block", SYSFS{size}=="16771797", SYSFS{start}=="63", NAME="asmdisk1-crs",
 OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sdd1", SUBSYSTEM=="block", SYSFS{size}=="16771797", SYSFS{start}=="63", NAME="asmdisk2-data"
, OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sde1", SUBSYSTEM=="block", SYSFS{size}=="16771797", SYSFS{start}=="63", NAME="asmdisk3-fra",
 OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sdf1", SUBSYSTEM=="block", SYSFS{size}=="208782", SYSFS{start}=="63", NAME="asmdisk4-data1",
 OWNER="grid", GROUP="asmadmin", MODE="0660"
[root@udev rules.d]#
8.编辑rule文件之后可以使用udevtest测试udev对设备的管理,命名,链接以及权限的设置情况
udevtest /block/sdf
9.重新启动udev,在启动之前首先使用命令udevcontrol重新装载rules:
[root@udev rules.d]# udevcontrol reload_rules
[root@udev rules.d]#
[root@udev rules.d]#
10.重启udev:
[root@udev rules.d]# cd /dev
[root@udev dev]# ls -l asm*
brw-rw---- 1 grid asmadmin 8, 33 May 30 14:28 asmdisk1-crs
brw-rw---- 1 grid asmadmin 8, 49 May 30 14:28 asmdisk2-data
brw-rw---- 1 grid asmadmin 8, 65 May 30 14:28 asmdisk3-fra

[root@udev dev]# start_udev
Starting udev: [  OK  ]
[root@udev dev]# ls -l asm*
brw-rw---- 1 grid asmadmin 8, 33 May 30 14:29 asmdisk1-crs
brw-rw---- 1 grid asmadmin 8, 49 May 30 14:29 asmdisk2-data
brw-rw---- 1 grid asmadmin 8, 65 May 30 14:29 asmdisk3-fra
brw-rw---- 1 grid asmadmin 8, 81 May 30 14:29 asmdisk4-data1
[root@udev dev]#
很显然,装载rule之后重启udev以后asmdisk4-data1出现了,接下来正常创建asm diskgroup使用asmdisk4-data1就可以了.
11.udev是否启动了我们直接在os上查找和udev相关的进程就可以了:
ps -ef|grep udev
12.有关udev的排错我们可以使用udevmonitor,不过udevmonitor我没有做更深入的研究,大家感兴趣可以研究.
[root@udev ~]# which udevmonitor
/usr/sbin/udevmonitor
[root@udev ~]# cd /usr/sbin
[root@udev sbin]# ls *udev*
udevmonitor

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/19602/viewspace-1173071/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/19602/viewspace-1173071/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值