使用udev管理asmdisk常用的命令

kakaxi9521發表於2016-12-01
使用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/21374452/viewspace-2129494/,如需轉載,請註明出處,否則將追究法律責任。

相關文章