今天在搭建RAC的时候,使用udev方式来创建ASM磁盘,执行/sbin/scsi_id命令不知道啥原因,死活获取不到UUID,执行结果啥也不显示。

[root@seiang2 ~]# scsi_id -u -g

/dev/sdb

没有uuid貌似没法配置udev

rules文件,通过查阅相关资料,通过如下两种方式实现的,通过udevinfo(6版本操作系统udevadm取代了udevinfo)命令获取分区的信息,可以利用分区中的这2项信息SYSFS{start}=="63"和SYSFS{size}=="16771797"(6版本变为ATTR{start}=="4241160"和ATTR{size}=="2120580")来代替uuid唯一标识这个设备;

实验环境:

操作系统:Redhat5.5Hostname:seiang2.comsys.com

操作系统:Redhat6.4Hostname:test.comsys.com

目录

一、使用udevinfo/udevadm获取分区的唯一标识

二、使用裸设备创建asm

一、使用udevinfo/udevadm获取分区的唯一标识

新增加一块磁盘,并对它进行分区,分区之后通过udevinfo/udevadm命令来获取分区的唯一标识;

Redhat5版本

[root@seiang2

~]# ll /sbin/udev*

-rwxr-xr-x

1 root root  15176 May  5  2009

/sbin/udevcontrol

-rwxr-xr-x

1 root root  61864 May  5  2009

/sbin/udevd

-rwxr-xr-x

1 root root 899928 May  5  2009 /sbin/udevd.static

-rwxr-xr-x

1 root root  23680 May  5  2009

/sbin/udevsettle

-rwxr-xr-x

1 root root  24144 May  5  2009

/sbin/udevtrigger

[root@seiang2

~]# cd

/sys/block/sdb

[root@seiang2

~]# udevinfo -a

-p /sys/block/sdb

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/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

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.

Warning:

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

Command

(m for help): n

Command

action

e

extended

p

primary partition (1-4)

p

Partition

number (1-4): 1

First

cylinder (1-652, default 1):

Using

default value 1

Last

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

Command

(m for help): n

Command

action

e

extended

p

primary partition (1-4)

p

Partition

number (1-4): 2

First

cylinder (124-652, default 124):

Using

default value 124

Last

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

Command

(m for help): n

Command

action

e

extended

p

primary partition (1-4)

p

Partition

number (1-4): 3

First

cylinder (126-652, default 126):

Using

default value 126

Last

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

Command

(m for help): p

Disk

/dev/sdb: 5368 MB, 5368709120 bytes

255

heads, 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

The

partition table has been altered!

Calling

ioctl() to re-read partition table.

Syncing

disks.

[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命令查看详细的分区信息

[root@seiang2

~]#udevinfo -a

-p /sys/block/sdb/sdb1

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/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@seiang2

rules.d]#udevinfo -a -p /sys/block/sdb/sdb3/

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/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@seiang2

rules.d]# vim

99-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测试udev对设备的管理,命名,链接以及权限的设置情况

[root@seiang2

rules.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'

重新启动udev,在启动之前首先使用命令udevcontrol重新装载rules(此步骤可以省略)

[root@seiang2

rules.d]# udevcontrol

reload_rules

[root@seiang2

rules.d]# start_udev

Starting

udev:

[  OK  ]

[root@seiang2

rules.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@seiang2

rules.d]#

Redhat6版本

[root@test

rules.d]# udevadm

info -a -p /sys/block/sdb/sdb2

Udevadm

info 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

'/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@test

rules.d]# udevadm

info -a -p /sys/block/sdb/sdb3

Udevadm

info 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

'/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@test

rules.d]# vim

99-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@test

rules.d]# start_udev

Starting

udev:

[  OK  ]

[root@test

rules.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

注意:从这里可以看到通过配置99-oracle-asmdevices.rules文件,创建出来的是块类型的设备

可以对比观察下面通过裸设备创建出来的设备类型

二、使用裸设备创建asm磁盘

新增加一块磁盘,并对其进行分区;

[root@seiang2

rules.d]# fdisk /dev/sdb

Command

(m for help): n

Command

action

e

extended

p

primary partition (1-4)

e

Selected

partition 4

First

cylinder (249-652, default 249):

Using

default value 249

Last

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

Using

default value 652

Command

(m for help): n

First

cylinder (249-652, default 249):

Using

default value 249

Last

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

Command

(m for help): n

First

cylinder (372-652, default 372):

Using

default value 372

Last

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

Command

(m for help): w

The

partition table has been altered!

Calling

ioctl() to re-read partition table.

Syncing

disks.

[root@seiang2

rules.d]# fdisk

-l

Disk

/dev/sda: 16.1 GB, 16106127360 bytes

255

heads, 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

255

heads, 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

配置裸设备映射,修改/etc/udev/rules.d/60-raw.rules文件

[root@seiang2

rules.d]# vim

60-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服务,并查询raw

[root@seiang2

rules.d]# start_udev

Starting

udev:

[  OK  ]

[root@seiang2

rules.d]#raw

-qa

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

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

[root@seiang2

rules.d]# ll

/dev/raw*

crw-------

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

/dev/raw:

total

0

crw-rw---- 1 grid

asmadmin 162, 5 Jul 20 03:31 raw5

crw-rw---- 1 grid

asmadmin 162, 6 Jul 20 03:31 raw6

注意:从这里可以看到通过配置60-raw.rules文件,创建出来的是字符类型的设备

这样配置之后,裸设备文件会自动映射到相应的分区设备文件,并设置正确的用户和组。

裸设备:也叫裸分区(原始分区),是一种没有经过格式化,不被Unix/Linux通过文件系统来读取的特殊字符设备。裸设备可以绑定一个分区,也可以绑定一个磁盘。

字符设备:对字符设备的读写不需要通过OS的buffer。它不可被文件系统mount。

块设备:对块设备的读写需要通过OS的buffer,它可以被mount到文件系统中。

这个与linux的版本相关,在旧版本中,最多只可以有256个裸设备,Linux 4下做多可以绑定81Array2个裸设备。但是在linux下,最多只能有255个分区,所以,如果用裸设备绑定分区,最多只能绑定255个裸设备。如果是用lvm,则没有这个限制。

Linux下单个磁盘最多可以有15个分区。3个主分区 + 1个扩展分区 + 11个逻辑分区。

建议的分区方法是:先分3个主分区,第四个分区为扩展分区,然后在扩展分区中再分成11个逻辑分区。

注意:裸设备不要绑定在扩展分区上。linux下如果需要使用裸设备,则需要手工进行绑定,unix下则不用。

major和minor device

number

在unix/linux系统中,一切都是文件。所有硬盘、键盘等设备都用文件来代表,对应着/dev下面的文件。对于应用程序来说,可以像对待普通文件一样打开,关闭、读写这些设备文件。但是这种文件名,比如/dev/sda、/dev /raw/raw1都是用户空间名称,OS Kernel根本不知道这个名称指的是什么。在内核空间是通过major、minor device

number 来区分设备的。

major device number可以看作是设备驱动程序,被同一设备驱动程序管理的设备有相同的major device

number。这个数字实际是Kernel中device driver

table 的索引,这个表保存着不同设备驱动程序。而minor device

number用来代表被访问的具体设备。也就是说Kernel根据major device

number 找到设备驱动程序,然后再从minor device

number 获得设备位置等属性。所有这些major device

number 是已经预先分配好的。比如裸设备是162,scsi块设备是8

Redhat平台对raw设备的配置在redhat 5之后有了变化。在redhat 5之前,直接配置/etc/sysconfig/rawdevices件,通过/etc/init.d/rawdevices来管理raw设备的启动和关闭。在Redhat 5之后,原来的raw设备接口已经取消了,redhat 5中通过udev规则进行配置。 要配置,需要编辑/etc/udev/rules.d/60-raw.rules这个文件。

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"

配置设备名称,用你需要绑定的设备名称替换 (如:/dev/sda1),X为裸设备号

主/次号码:

ACTION=="add", ENV{MAJOR}="A",

ENV{MINOR}="B", RUN+="raw /dev/raw/rawX %M %m"

"A" 和 "B" 是设备的主/次号码,X是系统使用的raw设备号码。

个人对redhat管理raw的过程理解为:在redhat 5中,是通过udev来管理raw设备的,而udev是通过 MAJOR和MINOR来识别 raw设备。故需要将设备号和裸设备号进行绑定,而主设备号和次设备号可以自行指定或者由系统自动分配。 根据red hat的官方文档中关于raw.rule的示例中说KERNEL==..或ENV{MAJOR}...只需要任意配置一个就可以,但有些网友经过试验,验证必须二者同时配置才可以。

如果有多个raw设备,可以写成:

ACTION=="add", KERNEL=="raw[1-4]",

OWNER="dave", GROUP="tianlesoftware", MODE="0660"

注意:在内核2.6.9-89.5AXS2之前使用/etc/sysconfig/rawdevices和/etc/udev/permissions.d/50-udev.permissions进行raw设备的配置和权限管理。在内核 2.6.18-128.7AXS3以后则使用了本文介绍的 /etc/udev/rules.d/60-raw.rules进行raw设备的管理

使用裸设备作为Oracle的数据文件的注意事项

1、一个裸设备只能放置一个数据文件

2、数据文件的大小不能超过裸设备的大小

如果是日志文件,则裸设备最大可用大小=裸设备对应分区大小 - 1 * 512 (保留一个redo lock)

如果是数据文件,则裸设备最大可用大小=裸设备对应分区大小 - 2 *

db_block_size(保留两个block)

为了简单起见,对所有的文件设置称比裸设备小1M即可。

3、数据文件最好不要设置称自动扩展,如果设置称自动扩展,一定要把maxsize设置设置为比裸设备小

4、linux下oracle不能直接把逻辑卷作为裸设备,也要进行绑定。unix下就不需要。

相关链接:

作者:SEian.G(苦练七十二变,笑对八十一难)

ITPUB:http://blog.itpub.net/31015730/

51CTO:http://seiang.blog.51cto.com/

linux vbox 不能使用scsi_id 查看uuid,使用udev管理asmdisk执行/sbin/scsi_id不显示UUID的解决方法...相关推荐

  1. Linux 2.6.32-279.el6.x86_64 ANDROID SDK碰到”LIBC.SO.6: VERSION `GLIBC_2.14′ NOT FOUND”的解决方法(1)

    1.执行locate libc.so.6找到库的位置;      /lib64/libc.so.6 2.查看系统已支持的版本: strings /lib64/libc.so.6 | grep GLIB ...

  2. Linux上 Can‘t connect to X11 window server using XX as the value of the DISPLAY 错误解决方法

    Linux上 Can't connect to X11 window server using XX as the value of the DISPLAY 错误解决方法 参考文章: (1)Linux ...

  3. linux shell 提示符消失 终端提示符显示-bash-4.1# 解决方法

    昨晚对服务器自带Python升级后,终端就不是以前root@主机+路径的显示方式了 如下图: 查了很多资料,有人说是root目录下.bash_profile和.bashrc两个文件缺失,但我的这两个文 ...

  4. linux 图标显示 异常,在Ubuntu 18.04系统中VSCode图标显示异常的解决方法

    以下介绍在Ubuntu 18.04系统中VSCode图标显示异常的解决方法,同时附上在Ubuntu 18.04系统中安装Anaconda3-5.3.0方法.VSCode是一款全平台开发的编辑器,它具有 ...

  5. Linux下通过rm -f删除大量文件时提示-bash: /bin/rm: Argument list too long的解决方法...

    Linux下通过rm -f删除/var/spool/postfix/maildrop/中大量的小文件时提示: "-bash: /bin/rm: Argument list too long& ...

  6. linux云服务终端提示符显示-bash-4.2#解决方法

    今天连接到云服务器突然发现输入命令无效 出现这种情况 尝试使用Ctrl+C 退出 结果变成-bash-4.2# 网上查了半天 很多人多说是误删了两个文件 但我查看发现这两个文件都存在 输入命令: l. ...

  7. linux中ftp怎么进不去,FTP进不去怎么办?FTP老进不去解决方法

    之前就听很多朋友反映过FTP进不去这个问题,最近自己也遇到这个问题了,今天突然发现ftp访问一直进不去,检查用户名,密码正确,检查服务器的FTP服务器的21端口是监听状态,但是就是突然不能上FTP了. ...

  8. linux oracle查询乱码问题,Linux环境Oracle显示乱码的解决方法

    Linux环境Oracle所有出现汉字的地方,都以?替代,或者是直接乱码.有时候报错提示也出现乱码. 故障现象: Linux环境Oracle所有出现汉字的地方,都以?替代,或者是直接乱码.有时候报错提 ...

  9. Linux显示中文乱码解决方法

    http://sumit.blog.51cto.com/162317/206698 经常使用linux终端,有人上传中文命名的文件显示出中文乱码,下面是解决方法. 默认显示的字符编码 # echo $ ...

最新文章

  1. 硬链接和软链接使用,以及区别
  2. oracle网络公开课《存储技术》课件和视频共享下载
  3. 利用Servlet实现用户永久登录
  4. SAP FI新手常用代码
  5. 深度学习总结:continuous actions和asyncronous advanteage actor-critic
  6. 在运行时更新代码(已Spring解密)
  7. Mysql 插入中文错误:Incorrect string value: '...' for column 'xx' at row 1
  8. 终于有人把SaaS讲明白了
  9. 如何得知mysql表结构发生变化了呢?
  10. java制作网站的原理_代码生成器原理
  11. cesium 知乎_Cesium 源码笔记[2] CesiumWidget模块的实例化过程 ver1.67
  12. python︱写markdown一样写网页,代码快速生成web工具:streamlit 重要组件介绍(二)
  13. java求一元二次方程:ax2+bx+c=0的根
  14. matplotlib.pyplot.hist参数详解
  15. linux默认安装gdk目录,安装GDK
  16. 在微信小程序中制作的登录功能一定要考虑不同的入口问题
  17. Redis(4)优惠券秒杀
  18. pytorch官网预训练模型百度云下载 VGG16,Densnet169,inception_v3
  19. CodeVS4416 FFF 团卧底的后宫
  20. 尺寸有点太大了吧,我已经受不鸟了

热门文章

  1. java 文件io操作_java文件IO操作。
  2. solidworks 2011无法启动
  3. 【手机】欧陆词典安装词典包
  4. 北京Unity3d外包团队(长年承接Unity3d项目外包)
  5. 视频合并工具哪个比较好用?我只推荐这3个工具
  6. 1小时撸一套原型,你敢信?
  7. 讯飞语音转文字_科大讯飞发布新一代语音转文字录音笔,开启个人高效记录时代...
  8. 定义雇员类,包含雇员的编号、姓名、年龄、职位、部门信息。
  9. 纯 python 开发批量读取照片 Exif 信息的小程序
  10. 服务器软件配置文件,服务器多开软件配置文件