溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

使用udev管理asmdisk執(zhí)行/sbin/scsi_id不顯示UUID解決方法

發(fā)布時(shí)間:2020-10-20 07:17:15 來源:網(wǎng)絡(luò) 閱讀:4182 作者:SEianG 欄目:關(guān)系型數(shù)據(jù)庫


    今天在搭建RAC的時(shí)候,使用udev方式來創(chuàng)建ASM磁盤,執(zhí)行/sbin/scsi_id命令不知道啥原因,死活獲取不到UUID,執(zhí)行結(jié)果啥也不顯示。

[root@seiang2 ~]# scsi_id -u -g/dev/sdb

    沒有UUID貌似沒法配置udevrules文件,通過查閱相關(guān)資料,通過如下兩種方式實(shí)現(xiàn)的,通過udevinfo6版本操作系統(tǒng)udevadm取代了udevinfo)命令獲取分區(qū)的信息,可以利用分區(qū)中的這2項(xiàng)信息SYSFS{start}=="63"SYSFS{size}=="16771797"6版本變?yōu)?/span>ATTR{start}=="4241160"ATTR{size}=="2120580")來代替uuid唯一標(biāo)識(shí)這個(gè)設(shè)備;

 

實(shí)驗(yàn)環(huán)境:

操作系統(tǒng):Redhat5.5  Hostnameseiang2.comsys.com

操作系統(tǒng):Redhat6.4  Hostnametest.comsys.com

 

一、使用udevinfo/udevadm獲取分區(qū)的唯一標(biāo)識(shí)

新增加一塊磁盤,并對(duì)它進(jìn)行分區(qū),分區(qū)之后通過udevinfo/udevadm命令來獲取分區(qū)的唯一標(biāo)識(shí);

 

Redhat5版本

[root@seiang2~]# ll /sbin/udev*

-rwxr-xr-x1 root root  15176 May  5  2009/sbin/udevcontrol

-rwxr-xr-x1 root root  61864 May  5  2009/sbin/udevd

-rwxr-xr-x1 root root 8×××8 May  5  2009 /sbin/udevd.static

-rwxr-xr-x1 root root  23680 May  5  2009/sbin/udevsettle

-rwxr-xr-x1 root root  24144 May  5  2009/sbin/udevtrigger

 

[root@seiang2~]# cd/sys/block/sdb

[root@seiang2~]# udevinfo -a-p /sys/block/sdb

 

Udevinfostarts with the device specified by the devpath and then

walksup the chain of parent devices. It prints for every device

found,all possible attributes in the udev rules key format.

Arule to match, can be composed by the attributes of the device

andthe attributes from one single parent device.

 

  looking at device '/block/sdb':

    KERNEL=="sdb"

    SUBSYSTEM=="block"

    SYSFS{stat}=="      63      93     1248       19       0        0        0       0        0       19      19"

    SYSFS{size}=="10485760"

    SYSFS{removable}=="0"

    SYSFS{range}=="16"

    SYSFS{dev}=="8:16"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host1/target1:0:0/1:0:0:0':

    ID=="1:0:0:0"

    BUS=="scsi"

    DRIVER=="sd"

    SYSFS{dh_state}=="detached"

    SYSFS{ioerr_cnt}=="0x0"

    SYSFS{iodone_cnt}=="0x51"

    SYSFS{iorequest_cnt}=="0x51"

    SYSFS{iocounterbits}=="32"

    SYSFS{timeout}=="60"

    SYSFS{state}=="running"

    SYSFS{rev}=="1.0 "

    SYSFS{model}=="VBOX HARDDISK   "

    SYSFS{vendor}=="ATA     "

    SYSFS{scsi_level}=="6"

    SYSFS{type}=="0"

    SYSFS{queue_type}=="simple"

    SYSFS{queue_depth}=="31"

    SYSFS{device_blocked}=="0"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host1/target1:0:0':

    ID=="target1:0:0"

    BUS==""

    DRIVER==""

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host1':

    ID=="host1"

    BUS==""

    DRIVER==""

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0':

    ID=="0000:00:0d.0"

    BUS=="pci"

    DRIVER=="ahci"

    SYSFS{broken_parity_status}=="0"

    SYSFS{enable}=="1"

   SYSFS{modalias}=="pci:v00008086d00002829sv00000000sd00000000bc01sc06i01"

   SYSFS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000"

    SYSFS{irq}=="177"

    SYSFS{class}=="0x010601"

    SYSFS{subsystem_device}=="0x0000"

    SYSFS{subsystem_vendor}=="0x0000"

    SYSFS{device}=="0x2829"

    SYSFS{vendor}=="0x8086"

 

  looking at parent device '/devices/pci0000:00':

    ID=="pci0000:00"

    BUS==""

    DRIVER==""

 

[root@seiang2~]# fdisk/dev/sdb

Devicecontains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Buildinga new DOS disklabel. Changes will remain in memory only,

untilyou decide to write them. After that, of course, the previous

contentwon't be recoverable.

 

Warning:invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 

Command(m for help): n

Commandaction

   e  extended

   p  primary partition (1-4)

p

Partitionnumber (1-4): 1

Firstcylinder (1-652, default 1):

Usingdefault value 1

Lastcylinder or +size or +sizeM or +sizeK (1-652, default 652): +1G

 

Command(m for help): n

Commandaction

   e  extended

   p  primary partition (1-4)

p

Partitionnumber (1-4): 2

Firstcylinder (124-652, default 124):

Usingdefault value 124

Lastcylinder or +size or +sizeM or +sizeK (124-652, default 652): +1G

 

Command(m for help): n

Commandaction

   e  extended

   p  primary partition (1-4)

p

Partitionnumber (1-4): 3

Firstcylinder (126-652, default 126):

Usingdefault value 126

Lastcylinder or +size or +sizeM or +sizeK (126-652, default 652): +1G

 

Command(m for help): p

 

Disk/dev/sdb: 5368 MB, 5368709120 bytes

255heads, 63 sectors/track, 652 cylinders

Units= cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               1         123      987966  83  Linux

/dev/sdb2             124         125       16065  83  Linux

/dev/sdb3             126         248      987997+ 83  Linux

 

Command(m for help): w

Thepartition table has been altered!

 

Callingioctl() to re-read partition table.

Syncingdisks.

 

[root@seiang2~]# ll /dev/sdb*

brw-r-----1 root disk 8, 16 Jul 20 02:57 /dev/sdb

brw-r-----1 root disk 8, 17 Jul 20 02:57 /dev/sdb1

brw-r-----1 root disk 8, 18 Jul 20 02:57 /dev/sdb2

brw-r-----1 root disk 8, 19 Jul 20 02:57 /dev/sdb3

 

使用udevinfo命令查看詳細(xì)的分區(qū)信息

[root@seiang2~]# udevinfo -a-p /sys/block/sdb/sdb1

 

Udevinfostarts with the device specified by the devpath and then

walksup the chain of parent devices. It prints for every device

found,all possible attributes in the udev rules key format.

Arule to match, can be composed by the attributes of the device

andthe attributes from one single parent device.

 

  looking at device '/block/sdb/sdb1':

    KERNEL=="sdb1"

    SUBSYSTEM=="block"

    SYSFS{stat}=="      31      67      392       19       0        0        0       0        0       17      19"

    SYSFS{size}=="1975932"

    SYSFS{start}=="63"

    SYSFS{dev}=="8:17"

 

  looking at parent device '/block/sdb':

    ID=="sdb"

    BUS=="block"

    DRIVER==""

    SYSFS{stat}=="     196     575     3152       94       1        0        8       2        0       71      96"

    SYSFS{size}=="10485760"

    SYSFS{removable}=="0"

   SYSFS{range}=="16"

    SYSFS{dev}=="8:16"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host1/target1:0:0/1:0:0:0':

    ID=="1:0:0:0"

    BUS=="scsi"

    DRIVER=="sd"

    SYSFS{dh_state}=="detached"

    SYSFS{ioerr_cnt}=="0x0"

    SYSFS{iodone_cnt}=="0xe1"

    SYSFS{iorequest_cnt}=="0xe1"

    SYSFS{iocounterbits}=="32"

    SYSFS{timeout}=="60"

    SYSFS{state}=="running"

    SYSFS{rev}=="1.0 "

    SYSFS{model}=="VBOX HARDDISK   "

    SYSFS{vendor}=="ATA     "

    SYSFS{scsi_level}=="6"

    SYSFS{type}=="0"

    SYSFS{queue_type}=="simple"

    SYSFS{queue_depth}=="31"

    SYSFS{device_blocked}=="0"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host1/target1:0:0':

    ID=="target1:0:0"

    BUS==""

    DRIVER==""

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host1':

    ID=="host1"

    BUS==""

    DRIVER==""

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0':

    ID=="0000:00:0d.0"

    BUS=="pci"

    DRIVER=="ahci"

    SYSFS{broken_parity_status}=="0"

    SYSFS{enable}=="1"

   SYSFS{modalias}=="pci:v00008086d00002829sv00000000sd00000000bc01sc06i01"

   SYSFS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000"

    SYSFS{irq}=="177"

    SYSFS{class}=="0x010601"

    SYSFS{subsystem_device}=="0x0000"

    SYSFS{subsystem_vendor}=="0x0000"

    SYSFS{device}=="0x2829"

    SYSFS{vendor}=="0x8086"

 

  looking at parent device'/devices/pci0000:00':

    ID=="pci0000:00"

    BUS==""

    DRIVER==""

 

[root@seiang2rules.d]#udevinfo -a -p /sys/block/sdb/sdb3/

 

Udevinfostarts with the device specified by the devpath and then

walksup the chain of parent devices. It prints for every device

found,all possible attributes in the udev rules key format.

Arule to match, can be composed by the attributes of the device

andthe attributes from one single parent device.

 

  lookingat device '/block/sdb/sdb3':

    KERNEL=="sdb3"

    SUBSYSTEM=="block"

    SYSFS{stat}=="      27     355      382       31       0        0        0       0        0       31      31"

    SYSFS{size}=="1975995"

    SYSFS{start}=="2008125"

    SYSFS{dev}=="8:19"

 

  looking at parent device '/block/sdb':

    ID=="sdb"

    BUS=="block"

    DRIVER==""

    SYSFS{stat}=="     395    1754     5700      383       2        0       16       8        0      242     391"

    SYSFS{size}=="10485760"

    SYSFS{removable}=="0"

    SYSFS{range}=="16"

    SYSFS{dev}=="8:16"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host1/target1:0:0/1:0:0:0':

    ID=="1:0:0:0"

    BUS=="scsi"

    DRIVER=="sd"

    SYSFS{dh_state}=="detached"

    SYSFS{ioerr_cnt}=="0x0"

    SYSFS{iodone_cnt}=="0x1b3"

    SYSFS{iorequest_cnt}=="0x1b3"

    SYSFS{iocounterbits}=="32"

    SYSFS{timeout}=="60"

    SYSFS{state}=="running"

    SYSFS{rev}=="1.0 "

    SYSFS{model}=="VBOX HARDDISK   "

    SYSFS{vendor}=="ATA     "

    SYSFS{scsi_level}=="6"

    SYSFS{type}=="0"

    SYSFS{queue_type}=="simple"

    SYSFS{queue_depth}=="31"

    SYSFS{device_blocked}=="0"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host1/target1:0:0':

    ID=="target1:0:0"

    BUS==""

    DRIVER==""

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host1':

    ID=="host1"

    BUS==""

    DRIVER==""

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0':

    ID=="0000:00:0d.0"

    BUS=="pci"

    DRIVER=="ahci"

    SYSFS{broken_parity_status}=="0"

    SYSFS{enable}=="1"

   SYSFS{modalias}=="pci:v00008086d00002829sv00000000sd00000000bc01sc06i01"

   SYSFS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000"

    SYSFS{irq}=="177"

    SYSFS{class}=="0x010601"

    SYSFS{subsystem_device}=="0x0000"

    SYSFS{subsystem_vendor}=="0x0000"

    SYSFS{device}=="0x2829"

    SYSFS{vendor}=="0x8086"

 

  looking at parent device'/devices/pci0000:00':

    ID=="pci0000:00"

    BUS==""

DRIVER==""

 

編輯udev的rule文件

[root@seiang2~]# cd/etc/udev/rules.d/

[root@seiang2rules.d]# vim99-oracle-asmdevices.rules

KERNEL=="sdb1",SUBSYSTEM=="block", SYSFS{size}=="1975932", SYSFS{start}=="63",OWNER="grid",NAME="asmdisk-data1",GROUP="asmadmin", MODE="0660"

KERNEL=="sdb3",SUBSYSTEM=="block", SYSFS{size}=="1975995", SYSFS{start}=="2008125",OWNER="grid",NAME="asmdisk-data2",GROUP="asmadmin", MODE="0660"

 

編輯rule文件之后可以使用udevtest測(cè)試udev對(duì)設(shè)備的管理,命名,鏈接以及權(quán)限的設(shè)置情況

[root@seiang2rules.d]# udevtest/block/sdb

main:looking at device '/block/sdb' from subsystem 'block'

run_program:'/lib/udev/usb_id -x'

run_program:'/lib/udev/usb_id' returned with status 1

run_program:'/lib/udev/scsi_id -g -x -s /block/sdb -d /dev/.tmp-8-16'

run_program:'/lib/udev/scsi_id' (stdout) 'ID_VENDOR=ATA'

run_program:'/lib/udev/scsi_id' (stdout) 'ID_MODEL=VBOX_HARDDISK'

run_program:'/lib/udev/scsi_id' (stdout) 'ID_REVISION=1.0'

run_program:'/lib/udev/scsi_id' (stdout) 'ID_SERIAL=SATA_VBOX_HARDDISK_VBda65d90d-e2055c6a'

run_program:'/lib/udev/scsi_id' (stdout) 'ID_TYPE=disk'

run_program:'/lib/udev/scsi_id' (stdout) 'ID_BUS=scsi'

run_program:'/lib/udev/scsi_id' returned with status 0

udev_rules_get_name:add symlink 'disk/by-id/scsi-SATA_VBOX_HARDDISK_VBda65d90d-e2055c6a'

run_program:'/lib/udev/path_id /block/sdb'

run_program:'/lib/udev/path_id' (stdout) 'ID_PATH=pci-0000:00:0d.0-scsi-1:0:0:0'

run_program:'/lib/udev/path_id' returned with status 0

udev_rules_get_name:add symlink 'disk/by-path/pci-0000:00:0d.0-scsi-1:0:0:0'

run_program:'/lib/udev/vol_id --export /dev/.tmp-8-16'

run_program:'/lib/udev/vol_id' returned with status 4

run_program:'/lib/udev/edd_id --export /dev/.tmp-8-16'

run_program:'/lib/udev/edd_id' (stderr) 'no kernel EDD support'

run_program:'/lib/udev/edd_id' returned with status 2

udev_rules_get_name:no node name set, will use kernel name 'sdb'

udev_device_event:device '/block/sdb' already in database, validate currently present symlinks

udev_node_add:creating device node '/dev/sdb', major = '8', minor = '16', mode = '0640', uid= '0', gid = '6'

udev_node_add:creating symlink '/dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBda65d90d-e2055c6a'to '../../sdb'

udev_node_add:creating symlink '/dev/disk/by-path/pci-0000:00:0d.0-scsi-1:0:0:0' to'../../sdb'

main:run: 'socket:/org/kernel/udev/monitor'

main:run: '/lib/udev/udev_run_devd'

main:run: 'socket:/org/freedesktop/hal/udev_event'

main:run: '/sbin/pam_console_apply /dev/sdb /dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBda65d90d-e2055c6a/dev/disk/by-path/pci-0000:00:0d.0-scsi-1:0:0:0'

 

重新啟動(dòng)udev,在啟動(dòng)之前首先使用命令udevcontrol重新裝載rules(此步驟可以省略)

[root@seiang2rules.d]# udevcontrolreload_rules

[root@seiang2rules.d]# start_udev

Startingudev:                                            [  OK  ]

 

[root@seiang2rules.d]# ll/dev/asm*

brw-rw----1 grid asmadmin 8, 17 Jul 20 03:09 /dev/asmdisk-data1

brw-rw----1 grid asmadmin 8, 19 Jul 20 03:09 /dev/asmdisk-data2

[root@seiang2rules.d]#

 

 

Redhat6版本

[root@testrules.d]# udevadminfo -a -p /sys/block/sdb/sdb2

 

Udevadminfo starts with the device specified by the devpath and then

walksup the chain of parent devices. It prints for every device

found,all possible attributes in the udev rules key format.

Arule to match, can be composed by the attributes of the device

andthe attributes from one single parent device.

 

  looking at device'/devices/pci0000:00/0000:00:0d.0/host3/target3:0:0/3:0:0:0/block/sdb/sdb2':

    KERNEL=="sdb2"

    SUBSYSTEM=="block"

    DRIVER==""

    ATTR{partition}=="2"

    ATTR{start}=="2120580"

    ATTR{size}=="2120580"

    ATTR{alignment_offset}=="0"

    ATTR{discard_alignment}=="0"

    ATTR{stat}=="     238      84     1288      247       0        0        0       0        0      232     247"

    ATTR{inflight}=="       0       0"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host3/target3:0:0/3:0:0:0/block/sdb':

    KERNELS=="sdb"

    SUBSYSTEMS=="block"

    DRIVERS==""

    ATTRS{range}=="16"

    ATTRS{ext_range}=="256"

    ATTRS{removable}=="0"

    ATTRS{ro}=="0"

    ATTRS{size}=="10485760"

    ATTRS{alignment_offset}=="0"

    ATTRS{discard_alignment}=="0"

    ATTRS{capability}=="52"

    ATTRS{stat}=="    2082    4734    15818     2580     640    98980    99628   48250        0     2549   50830"

    ATTRS{inflight}=="       0       0"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host3/target3:0:0/3:0:0:0':

    KERNELS=="3:0:0:0"

    SUBSYSTEMS=="scsi"

    DRIVERS=="sd"

    ATTRS{device_blocked}=="0"

    ATTRS{type}=="0"

    ATTRS{scsi_level}=="6"

    ATTRS{vendor}=="ATA     "

    ATTRS{model}=="VBOX HARDDISK   "

    ATTRS{rev}=="1.0 "

    ATTRS{state}=="running"

    ATTRS{timeout}=="30"

    ATTRS{iocounterbits}=="32"

    ATTRS{iorequest_cnt}=="0xb10"

    ATTRS{iodone_cnt}=="0xb0e"

    ATTRS{ioerr_cnt}=="0xf"

    ATTRS{modalias}=="scsi:t-0x00"

    ATTRS{evt_media_change}=="0"

    ATTRS{dh_state}=="detached"

    ATTRS{queue_depth}=="31"

   ATTRS{queue_ramp_up_period}=="120000"

    ATTRS{queue_type}=="simple"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host3/target3:0:0':

    KERNELS=="target3:0:0"

    SUBSYSTEMS=="scsi"

    DRIVERS==""

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host3':

    KERNELS=="host3"

    SUBSYSTEMS=="scsi"

    DRIVERS==""

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0':

    KERNELS=="0000:00:0d.0"

    SUBSYSTEMS=="pci"

    DRIVERS=="ahci"

    ATTRS{vendor}=="0x8086"

    ATTRS{device}=="0x2829"

    ATTRS{subsystem_vendor}=="0x0000"

    ATTRS{subsystem_device}=="0x0000"

    ATTRS{class}=="0x010601"

    ATTRS{irq}=="21"

    ATTRS{local_cpus}=="1"

    ATTRS{local_cpulist}=="0"

   ATTRS{modalias}=="pci:v00008086d00002829sv00000000sd00000000bc01sc06i01"

    ATTRS{numa_node}=="-1"

    ATTRS{enable}=="1"

    ATTRS{broken_parity_status}=="0"

    ATTRS{msi_bus}==""

 

  looking at parent device'/devices/pci0000:00':

    KERNELS=="pci0000:00"

    SUBSYSTEMS==""

DRIVERS==""

 

[root@testrules.d]# udevadminfo -a -p /sys/block/sdb/sdb3

 

Udevadminfo starts with the device specified by the devpath and then

walksup the chain of parent devices. It prints for every device

found,all possible attributes in the udev rules key format.

Arule to match, can be composed by the attributes of the device

andthe attributes from one single parent device.

 

  looking at device'/devices/pci0000:00/0000:00:0d.0/host3/target3:0:0/3:0:0:0/block/sdb/sdb3':

    KERNEL=="sdb3"

    SUBSYSTEM=="block"

    DRIVER==""

    ATTR{partition}=="3"

    ATTR{start}=="4241160"

    ATTR{size}=="2120580"

    ATTR{alignment_offset}=="0"

    ATTR{discard_alignment}=="0"

    ATTR{stat}=="     200     122     1288      255       0        0        0       0        0      250     255"

    ATTR{inflight}=="       0       0"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host3/target3:0:0/3:0:0:0/block/sdb':

    KERNELS=="sdb"

    SUBSYSTEMS=="block"

    DRIVERS==""

    ATTRS{range}=="16"

    ATTRS{ext_range}=="256"

    ATTRS{removable}=="0"

    ATTRS{ro}=="0"

    ATTRS{size}=="10485760"

    ATTRS{alignment_offset}=="0"

    ATTRS{discard_alignment}=="0"

    ATTRS{capability}=="52"

    ATTRS{stat}=="    2082    4734    15818     2580     640    98980    99628   48250        0     2549   50830"

    ATTRS{inflight}=="       0       0"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host3/target3:0:0/3:0:0:0':

    KERNELS=="3:0:0:0"

    SUBSYSTEMS=="scsi"

    DRIVERS=="sd"

    ATTRS{device_blocked}=="0"

    ATTRS{type}=="0"

    ATTRS{scsi_level}=="6"

    ATTRS{vendor}=="ATA     "

    ATTRS{model}=="VBOX HARDDISK   "

    ATTRS{rev}=="1.0 "

    ATTRS{state}=="running"

    ATTRS{timeout}=="30"

    ATTRS{iocounterbits}=="32"

    ATTRS{iorequest_cnt}=="0xb10"

    ATTRS{iodone_cnt}=="0xb0e"

    ATTRS{ioerr_cnt}=="0xf"

    ATTRS{modalias}=="scsi:t-0x00"

    ATTRS{evt_media_change}=="0"

    ATTRS{dh_state}=="detached"

    ATTRS{queue_depth}=="31"

   ATTRS{queue_ramp_up_period}=="120000"

    ATTRS{queue_type}=="simple"

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host3/target3:0:0':

    KERNELS=="target3:0:0"

    SUBSYSTEMS=="scsi"

    DRIVERS==""

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0/host3':

    KERNELS=="host3"

    SUBSYSTEMS=="scsi"

    DRIVERS==""

 

  looking at parent device'/devices/pci0000:00/0000:00:0d.0':

    KERNELS=="0000:00:0d.0"

    SUBSYSTEMS=="pci"

    DRIVERS=="ahci"

    ATTRS{vendor}=="0x8086"

    ATTRS{device}=="0x2829"

    ATTRS{subsystem_vendor}=="0x0000"

    ATTRS{subsystem_device}=="0x0000"

    ATTRS{class}=="0x010601"

    ATTRS{irq}=="21"

    ATTRS{local_cpus}=="1"

    ATTRS{local_cpulist}=="0"

    ATTRS{modalias}=="pci:v00008086d00002829sv00000000sd00000000bc01sc06i01"

    ATTRS{numa_node}=="-1"

    ATTRS{enable}=="1"

    ATTRS{broken_parity_status}=="0"

    ATTRS{msi_bus}==""

 

  looking at parent device'/devices/pci0000:00':

    KERNELS=="pci0000:00"

   SUBSYSTEMS==""

    DRIVERS==""

 

[root@testrules.d]# vim99-oracle-asmdevices.rules

KERNEL=="sdb2",SUBSYSTEM=="block", ATTR{size}=="2120580", ATTR{start}=="2120580",OWNER="grid",NAME="asmdisk-data1",GROUP="asmadmin", MODE="0660"

KERNEL=="sdb3",SUBSYSTEM=="block", ATTR{size}=="2120580", ATTR{start}=="4241160",OWNER="grid",NAME="asmdisk-data2",GROUP="asmadmin", MODE="0660"

 

[root@testrules.d]# start_udev

Startingudev:                                            [  OK  ]

 

[root@testrules.d]# ll/dev/asm*

brw-rw----.1 grid asmadmin 8, 18 Jul 20 15:57 /dev/asmdisk-data1

brw-rw----.1 grid asmadmin 8, 19 Jul 20 15:57 /dev/asmdisk-data2

 

 

二、使用裸設(shè)備創(chuàng)建asm磁盤

新增加一塊磁盤,并對(duì)其進(jìn)行分區(qū);

[root@seiang2rules.d]# fdisk /dev/sdb

 

Command(m for help): n

Commandaction

   e  extended

   p  primary partition (1-4)

e

Selectedpartition 4

Firstcylinder (249-652, default 249):

Usingdefault value 249

Lastcylinder or +size or +sizeM or +sizeK (249-652, default 652):

Usingdefault value 652

 

Command(m for help): n

Firstcylinder (249-652, default 249):

Usingdefault value 249

Lastcylinder or +size or +sizeM or +sizeK (249-652, default 652): +1G

 

Command(m for help): n

Firstcylinder (372-652, default 372):

Usingdefault value 372

Lastcylinder or +size or +sizeM or +sizeK (372-652, default 652): +1G

 

Command(m for help): w

Thepartition table has been altered!

 

Callingioctl() to re-read partition table.

Syncingdisks.

 

[root@seiang2rules.d]# fdisk-l

 

Disk/dev/sda: 16.1 GB, 16106127360 bytes

255heads, 63 sectors/track, 1958 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        1958   15623212+  8e  Linux LVM

 

Disk/dev/sdb: 5368 MB, 5368709120 bytes

255heads, 63 sectors/track, 652 cylinders

Units= cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               1         123      987966  83  Linux

/dev/sdb2             124         125       16065  83  Linux

/dev/sdb3             126         248      987997+ 83  Linux

/dev/sdb4             249         652    3245130    5  Extended

/dev/sdb5             249         371      987966  83  Linux

/dev/sdb6             372         494      987966  83  Linux

 

配置裸設(shè)備映射,修改/etc/udev/rules.d/60-raw.rules文件

[root@seiang2rules.d]# vim60-raw.rules

ACTION=="add",KERNEL=="/dev/sdb5", RUN+="/bin/raw /dev/raw/raw5 %N"

ACTION=="add",ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw/dev/raw/raw5 %M %m"

 

ACTION=="add",KERNEL=="/dev/sdb6", RUN+="/bin/raw /dev/raw/raw6 %N"

ACTION=="add",ENV{MAJOR}=="8", ENV{MINOR}=="2", RUN+="/bin/raw/dev/raw/raw6 %M %m"

 

ACTION=="add",KERNEL=="raw5", OWNER="grid", GROUP="asmadmin",MODE="0660"

ACTION=="add",KERNEL=="raw6", OWNER="grid", GROUP="asmadmin",MODE="0660"

            

重啟udev服務(wù),并查詢r(jià)aw                                                      

[root@seiang2rules.d]# start_udev

Startingudev:                                            [  OK  ]

 

[root@seiang2rules.d]# raw-qa

/dev/raw/raw5:  bound to major 8, minor 1

/dev/raw/raw6:  bound to major 8, minor 2

 

[root@seiang2rules.d]# ll/dev/raw*

crw-------1 root root 162, 0 Jul 20 02:53 /dev/rawctl

 

/dev/raw:

total0

crw-rw---- 1 gridasmadmin 162, 5 Jul 20 03:31 raw5

crw-rw---- 1 gridasmadmin 162, 6 Jul 20 03:31 raw6

 

裸設(shè)備介紹 (來自http://blog.itpub.net/26736162/viewspace-1401193/)

裸設(shè)備:也叫裸分區(qū)(原始分區(qū)),是一種沒有經(jīng)過格式化,不被Unix/Linux通過文件系統(tǒng)來讀取的特殊字符設(shè)備。裸設(shè)備可以綁定一個(gè)分區(qū),也可以綁定一個(gè)磁盤。
字符設(shè)備:對(duì)字符設(shè)備的讀寫不需要通過OSbuffer。它不可被文件系統(tǒng)mount。
塊設(shè)備:對(duì)塊設(shè)備的讀寫需要通過OSbuffer,它可以被mount到文件系統(tǒng)中。

    這個(gè)與linux的版本相關(guān),在舊版本中,最多只可以有256個(gè)裸設(shè)備,Linux 4下做多可以綁定81Array2個(gè)裸設(shè)備。但是在linux下,最多只能有255個(gè)分區(qū),所以,如果用裸設(shè)備綁定分區(qū),最多只能綁定255個(gè)裸設(shè)備。如果是用lvm,則沒有這個(gè)限制。

Linux下單個(gè)磁盤最多可以有15個(gè)分區(qū)。3個(gè)主分區(qū) + 1個(gè)擴(kuò)展分區(qū) + 11個(gè)邏輯分區(qū)。
建議的分區(qū)方法是:先分3個(gè)主分區(qū),第四個(gè)分區(qū)為擴(kuò)展分區(qū),然后在擴(kuò)展分區(qū)中再分成11個(gè)邏輯分區(qū)。

注意:裸設(shè)備不要綁定在擴(kuò)展分區(qū)上。 linux下如果需要使用裸設(shè)備,則需要手工進(jìn)行綁定,unix下則不用。

majorminor devicenumber 

unix/linux系統(tǒng)中,一切都是文件。所有硬盤、鍵盤等設(shè)備都用文件來代表,對(duì)應(yīng)著/dev下面的文件。對(duì)于應(yīng)用程序來說,可以像對(duì)待普通文件一樣打開,關(guān)閉、讀寫這些設(shè)備文件。但是這種文件名,比如/dev/sda、/dev /raw/raw1都是用戶空間名稱,OS Kernel根本不知道這個(gè)名稱指的是什么。在內(nèi)核空間是通過major、minor devicenumber 來區(qū)分設(shè)備的。
major device number
可以看作是設(shè)備驅(qū)動(dòng)程序,被同一設(shè)備驅(qū)動(dòng)程序管理的設(shè)備有相同的major devicenumber。這個(gè)數(shù)字實(shí)際是Kerneldevice drivertable 的索引,這個(gè)表保存著不同設(shè)備驅(qū)動(dòng)程序。而minor devicenumber用來代表被訪問的具體設(shè)備。也就是說Kernel根據(jù)major devicenumber 找到設(shè)備驅(qū)動(dòng)程序,然后再?gòu)?/span>minor devicenumber 獲得設(shè)備位置等屬性。所有這些major devicenumber 是已經(jīng)預(yù)先分配好的。比如裸設(shè)備是162,scsi塊設(shè)備是8

Redhat平臺(tái)對(duì)raw設(shè)備的配置在redhat 5之后有了變化。在redhat 5之前,直接配置/etc/sysconfig/rawdevices件,通過/etc/init.d/rawdevices來管理raw設(shè)備的啟動(dòng)和關(guān)閉。在Redhat 5之后,原來的raw設(shè)備接口已經(jīng)取消了,redhat 5中通過udev規(guī)則進(jìn)行配置。要配置,需要編輯/etc/udev/rules.d/60-raw.rules這個(gè)文件。

cat/etc/udev/rules.d/60-raw.rules 
# Enter raw device bindings here.
#
# An example would be:
#   ACTION=="add", KERNEL=="sda",RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
#   ACTION=="add", ENV{MAJOR}=="8",ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1. 

其中
ACTION=="add", KERNEL="", RUN+="raw /dev/raw/rawX%N" 

配置設(shè)備名稱,用你需要綁定的設(shè)備名稱替換(如:/dev/sda1),X為裸設(shè)備號(hào)
/次號(hào)碼:
ACTION=="add", ENV{MAJOR}="A",ENV{MINOR}="B", RUN+="raw /dev/raw/rawX %M %m" 
"A"
"B" 是設(shè)備的主/次號(hào)碼,X是系統(tǒng)使用的raw設(shè)備號(hào)碼。

個(gè)人對(duì)redhat管理raw的過程理解為:在redhat 5中,是通過udev來管理raw設(shè)備的,而udev是通過 MAJORMINOR來識(shí)別 raw設(shè)備。故需要將設(shè)備號(hào)和裸設(shè)備號(hào)進(jìn)行綁定,而主設(shè)備號(hào)和次設(shè)備號(hào)可以自行指定或者由系統(tǒng)自動(dòng)分配。根據(jù)red hat的官方文檔中關(guān)于raw.rule的示例中說KERNEL==..ENV{MAJOR}...只需要任意配置一個(gè)就可以,但有些網(wǎng)友經(jīng)過試驗(yàn),驗(yàn)證必須二者同時(shí)配置才可以。


如果有多個(gè)raw設(shè)備,可以寫成:
ACTION=="add", KERNEL=="raw[1-4]",OWNER="dave", GROUP="tianlesoftware", MODE="0660"  
注意:在內(nèi)核2.6.9-89.5AXS2之前使用/etc/sysconfig/rawdevices/etc/udev/permissions.d/50-udev.permissions進(jìn)行raw設(shè)備的配置和權(quán)限管理。在內(nèi)核 2.6.18-128.7AXS3以后則使用了本文介紹的 /etc/udev/rules.d/60-raw.rules進(jìn)行raw設(shè)備的管理 

 

使用裸設(shè)備作為Oracle的數(shù)據(jù)文件的注意事項(xiàng) 
1
、一個(gè)裸設(shè)備只能放置一個(gè)數(shù)據(jù)文件
2
、數(shù)據(jù)文件的大小不能超過裸設(shè)備的大小
如果是日志文件,則裸設(shè)備最大可用大小=裸設(shè)備對(duì)應(yīng)分區(qū)大小 - 1 * 512 (保留一個(gè)redo lock
如果是數(shù)據(jù)文件,則裸設(shè)備最大可用大小=裸設(shè)備對(duì)應(yīng)分區(qū)大小 - 2 *db_block_size(保留兩個(gè)block
為了簡(jiǎn)單起見,對(duì)所有的文件設(shè)置稱比裸設(shè)備小1M即可。
3
、數(shù)據(jù)文件最好不要設(shè)置稱自動(dòng)擴(kuò)展,如果設(shè)置稱自動(dòng)擴(kuò)展,一定要把maxsize設(shè)置設(shè)置為比裸設(shè)備小
4
linuxoracle不能直接把邏輯卷作為裸設(shè)備,也要進(jìn)行綁定。unix下就不需要。

 

 

相關(guān)鏈接:

http://blog.itpub.net/14184018/viewspace-701675/

http://blog.itpub.net/14184018/viewspace-1364944/

 

作者:SEian.G(苦練七十二變,笑對(duì)八十一難)

ITPUBhttp://blog.itpub.net/31015730/

51CTOhttp://seiang.blog.51cto.com/


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI