Linux udev 动态管理Oracle ASM磁盘-实验

  • 来源:网络
  • 更新日期:2020-08-10

摘要:建站服务器 1 概述 在Red Hat Enterprise Linux (RHEL) 6以前,Oracle都是采用ASMLib包来管理ASM磁盘。但是2011年5月甲骨文发表了一

建站服务器 1       概述

在Red Hat Enterprise Linux (RHEL) 6以前,Oracle都是采用ASMLib包来管理ASM磁盘。但是2011年5月甲骨文发表了一份声明,声明中称Oracle将不再提供Red Hat Enterprise Linux (RHEL) 6的ASMLib包和相关更新。

甲骨文在这份声明中表示,ASMLib更新将通过Unbreakable Linux Network(ULN)来发布,并仅对Oracle Linux客户开放。ULN虽然为甲骨文和红帽的客户服务,但如果客户想要使用ASMLib,就必须使用Oracle的kernel来替换掉红帽的kernel。

 

本实验部署Oracle+ASM,不再采用ASMLib,而是采用udev动态管理ASM磁盘。

 

注意:Linux 内核 2.6以上才支持udev

 

虚拟机:VMware Workstation 9

操作系统:Red Hat Enterprise Linux Server release 5.6

系统内核:2.6.18-238.el5

数据库:Oracle Database 11.2.0.1

 

2       实验步骤

之前已经基于udev的方式创建过ASM磁盘,而且已经安装好Oracle Grid 、Oracle Database,并创建好了数据库,接下来将添加4块1G磁盘,分别扩展现有ASM磁盘组DG_DATA,新建ASM磁盘组DG_NEW_DATA。

 

查看新添加的磁盘,分别为/dev/sdb、/dev/sdg、/dev/sdh、/dev/sdi。

 

[root@ora32 dev]# fdisk -l

 

Disk /dev/sda: 23.6 GB, 23622320128 bytes

255 heads, 63 sectors/track, 2871 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          65      522081   83  Linux

/dev/sda2              66         457     3148740   82  Linux swap / Solaris

/dev/sda3             458        2871    19390455   8e  Linux LVM

 

Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdb doesn\'t contain a valid partition table

 

Disk /dev/sdc: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1         261     2096451   83  Linux

 

Disk /dev/sdd: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdd1               1         261     2096451   83  Linux

 

Disk /dev/sde: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sde1               1         261     2096451   83  Linux

 

Disk /dev/sdf: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdf1               1         261     2096451   83  Linux

 

Disk /dev/sdg: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdg doesn\'t contain a valid partition table

 

Disk /dev/sdh: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdh doesn\'t contain a valid partition table

 

Disk /dev/sdi: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdi doesn\'t contain a valid partition table

 

 

 

分别对4块磁盘进行分区,每块磁盘分1个区即可。

[root@ora32 dev]# fdisk -l

 

Disk /dev/sda: 23.6 GB, 23622320128 bytes

255 heads, 63 sectors/track, 2871 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          65      522081   83  Linux

/dev/sda2              66         457     3148740   82  Linux swap / Solaris

/dev/sda3             458        2871    19390455   8e  Linux LVM

 

Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         130     1044193+  83  Linux

 

Disk /dev/sdc: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1         261     2096451   83  Linux

 

Disk /dev/sdd: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdd1               1         261     2096451   83  Linux

 

Disk /dev/sde: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sde1               1         261     2096451   83  Linux

 

Disk /dev/sdf: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdf1               1         261     2096451   83  Linux

 

Disk /dev/sdg: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdg1               1         130     1044193+  83  Linux

 

Disk /dev/sdh: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdh2               1         130     1044193+  83  Linux

 

Disk /dev/sdi: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdi1               1         130     1044193+  83  Linux

 

现在需要通过udev来管理这几个磁盘设备文件,通过规则文件将磁盘映射为固定名称,并赋予所属用户,用户组,操作权限等。

查看udev规则文件

[root@ora32 dev]# cd /etc/udev/rules.d

[root@ora32 rules.d]# ll

total 248

-rw-r--r-- 1 root root   515 Nov 25  2010 05-udev-early.rules

-rw-r--r-- 1 root root   948 Dec  8  2010 40-multipath.rules

-rw-r--r-- 1 root root 16153 Nov 25  2010 50-udev.rules

-rw-r--r-- 1 root root   163 Dec 11  2010 51-dlm.rules

-rw-r--r-- 1 root root   471 Nov 25  2010 51-hotplug.rules

-rw-r--r-- 1 root root   138 May 10 17:28 55-usm.rules

-rw-r--r-- 1 root root 58016 Oct 13  2006 60-libsane.rules

-rw-r--r-- 1 root root   143 Oct 13  2010 60-net.rules

-rw-r--r-- 1 root root  1088 Jul 18  2006 60-pcmcia.rules

-rw-r--r-- 1 root root   316 Sep 22  2010 60-raw.rules

-rw-r--r-- 1 root root  9175 Nov 13  2010 60-wacom.rules

-rw-r--r-- 1 root root   129 Nov 30  2010 61-uinput-stddev.rules

-rw-r--r-- 1 root root   214 Nov 30  2010 61-uinput-wacom.rules

-rw-r--r-- 1 root root  1823 Sep 19  2008 85-pcscd_ccid.rules

-rw-r--r-- 1 root root   114 Aug 29  2008 90-alsa.rules

-rw-r--r-- 1 root root    61 Nov 25  2010 90-dm.rules

-rw-r--r-- 1 root root    82 Nov  4  2010 90-hal.rules

-rw-r--r-- 1 root root   107 Nov 25  2010 95-pam-console.rules

-rw-r--r-- 1 root root   292 Nov 30  2010 98-kexec.rules

-rw-r--r-- 1 root root   669 May 13 13:51 99-oracle-asmdevices.rules

-rw-r--r-- 1 root root    60 Sep 16  2012 99-oracle.rules

-rw-r--r-- 1 root root   334 Sep 15  2012 99-vmware-scsi-udev.rules

-rw-r--r-- 1 root root  2319 Jul  9  2008 bluetooth.rules

 

udev规则文件“99-oracle-asmdevices.rules”之前已经创建好,看一下当前的映射规则和ASM磁盘情况。

[root@ora32 rules.d]# cat 99-oracle-asmdevices.rules

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c29c9a269653c7cd04ea2edb0c71, NAME=ASM_DISK_2G_1, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c29861258ebc95eded634a1f36fd, NAME=ASM_DISK_2G_2, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c296fd09d9ed213df1999820ca89, NAME=ASM_DISK_2G_3, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c2934ae12fd4af0dd366d85b42f5,  NAME=ASM_DISK_2G_4, WNER=grid, GROUP=asmadmin, MODE=0660

 

规则解释,以第一条为例。

系统启动时,udev根据系统总线scsi(BUS==scsi)和内核设备文件名sd?1(KERNEL==sd?1),过滤出需要动态映射的设备,然后再利用/sbin/scsi_id(PROGRAM==/sbin/scsi_id)命令输出的SCSI磁盘id,输出结果中匹配上36000c29c9a269653c7cd04ea2edb0c71的SCSI磁盘,则会应用后续的命名、授权等操作(NAME=ASM_DISK_2G_1, WNER=grid, GROUP=asmadmin, MODE=0660),SCSI磁盘ID可以通过/sbin/scsi_id命令获取。

 

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdc/sdc1

36000c29c9a269653c7cd04ea2edb0c71

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdd/sdd1

36000c29861258ebc95eded634a1f36fd

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sde/sde1

36000c296fd09d9ed213df1999820ca89

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdf/sdf1

36000c2934ae12fd4af0dd366d85b42f5

 

从上述结果可以看出,udev已经做了如下映射关系。

/block/sdc/sdc1 => ASM_DISK_2G_1

/block/sdd/sdd1 => ASM_DISK_2G_2

/block/sde/sde1 => ASM_DISK_2G_3

/block/sdf/sdf1 => ASM_DISK_2G_4

 

[grid@ora32 dev]$ ll ASM*

brw-rw---- 1 grid asmadmin 8, 33 May 13 14:57 ASM_DISK_2G_1

brw-rw---- 1 grid asmadmin 8, 49 May 13 14:57 ASM_DISK_2G_2

brw-rw---- 1 grid asmadmin 8, 65 May 13 14:54 ASM_DISK_2G_3

brw-rw---- 1 grid asmadmin 8, 81 May 13 14:57 ASM_DISK_2G_4

 

通过Oracle视图看一下当前磁盘组、磁盘的使用情况。

[grid@ora32 ~]$ sqlplus / as sysasm

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon May 13 14:54:01 2013

 

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Automatic Storage Management option

 

SQL>

SQL>

SQL> col name for a10

SQL> SELECT group_number,name,type,state,total_mb,free_mb,offline_disks FROM V$ASM_diskgroup;

 

GROUP_NUMBER NAME       TYPE   STATE         TOTAL_MB    FREE_MB OFFLINE_DISKS

------------ ---------- ------ ----------- ---------- ---------- -------------

           1 DG_DATA    EXTERN MOUNTED           8188       6448             0

 

 

SQL> col group# for 99

SQL> col disk# for 99

SQL> col name for a5

SQL> col path for a11

SQL> col LABEL for a7

SQL> col FAILGROUP for a10

SQL> select GROUP_NUMBER group#,DISK_NUMBER disk#,LABEL,STATE,FAILGROUP,name,path,TOTAL_MB,FREE_MB from v$asm_disk;

 

GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB    FREE_MB

------ ----- ------- -------- ---------- ----- ----------- ---------- ----------

     1     2         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1612

                              02         TA_00 SK_2G_3

                                         02

 

     1     3         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1611

                              03         TA_00 SK_2G_4

                                         03

 

     1     1         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1613

                              01         TA_00 SK_2G_2

                                         01

 

GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB    FREE_MB

------ ----- ------- -------- ---------- ----- ----------- ---------- ----------

 

     1     0         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1612

                              00         TA_00 SK_2G_1

                                         00

 

现将新增的4块硬盘通过udev映射为需要的设备文件,然后将其中2块增加到ASM磁盘组DG_DATA中,另外2块则新建一个ASM磁盘组DG_NEW_DATA。

 

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdb/sdb1

36000c2968513d97eb7cdd25bdbd10600

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdg/sdg1

36000c29682ba5ec7a4c8a189499a89bb

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdh/sdh2

36000c292aa4a4ebbb25d15d2084c01ca

[root@ora32 rules.d]# /sbin/scsi_id -g -s /blokc/sdi/sdi1

 

新增设备映射规则

[root@ora32 rules.d]# vi 99-oracle-asmdevices.rules

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c29c9a269653c7cd04ea2edb0c71, NAME=ASM_DISK_2G_1, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c29861258ebc95eded634a1f36fd, NAME=ASM_DISK_2G_2, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c296fd09d9ed213df1999820ca89, NAME=ASM_DISK_2G_3, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c2934ae12fd4af0dd366d85b42f5,  NAME=ASM_DISK_2G_4, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c2968513d97eb7cdd25bdbd10600,  NAME=ASM_DISK_1G_1, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c29682ba5ec7a4c8a189499a89bb,  NAME=ASM_DISK_1G_2, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c292aa4a4ebbb25d15d2084c01ca,  NAME=ASM_DISK_1G_3, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c29a98ca1bd8a0012e99f992a19d,  NAME=ASM_DISK_1G_4, WNER=grid, GROUP=asmadmin, MODE=0660

 

 

如果是第一次配置udev映射关系,需要如下操作。

1、  在目录/etc/udev/rules.d/中新建99-oracle-asmdevices.rules文件。

2、配置SCSI 设备为可信任设备,配置/etc/scsi_id.config文件,添加options=-g配置项。

[root@ora32 rules.d]# cat /etc/scsi_id.config

#

# scsi_id configuration

#

# lower or upper case has no affect on the left side. Quotes () are

# required for spaces in values. Model is the same as the SCSI

# INQUIRY product identification field. Per the SCSI INQUIRY, the vendor

# is limited to 8 bytes, model to 16 bytes.

#

# The first matching line found is used. Short matches match longer ones,

# if you do not want such a match space fill the extra bytes. If no model

# is specified, only the vendor string need match.

#

# ptions=<any scsi_id command line options>

# vendor=string[,model=string],options=<per-device scsi_id options>

 

# some libata drives require vpd page 0x80

vendor=ATA,options=-p 0x80

options=-g

 

测试udev能否正确映射

[root@ora32 ~]# testudev /block/sdg/sdg1

-bash: testudev: command not found

[root@ora32 ~]# udevtest /block/sdb/sdb1

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

udev_rules_get_name: add symlink \'disk/by-id/scsi-36000c2968513d97eb7cdd25bdbd10600-part1\'

udev_rules_get_name: add symlink \'disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1\'

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

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

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c2968513d97eb7cdd25bdbd10600\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c2968513d97eb7cdd25bdbd10600\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c2968513d97eb7cdd25bdbd10600\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c2968513d97eb7cdd25bdbd10600\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c2968513d97eb7cdd25bdbd10600\'

run_program: \'/sbin/scsi_id\' returned with status 0

udev_rules_get_name: rule applied, \'sdb1\' becomes \'ASM_DISK_1G_1\'

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c2968513d97eb7cdd25bdbd10600\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c2968513d97eb7cdd25bdbd10600\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c2968513d97eb7cdd25bdbd10600\'

run_program: \'/sbin/scsi_id\' returned with status 0

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

udev_node_add: creating device node \'/dev/ASM_DISK_1G_1\', major = \'8\', minor = \'17\', mode = \'0660\', uid = \'503\', gid = \'504\'

udev_node_add: creating symlink \'/dev/disk/by-id/scsi-36000c2968513d97eb7cdd25bdbd10600-part1\' to \'../../ASM_DISK_1G_1\'

udev_node_add: creating symlink \'/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1\' to \'../../ASM_DISK_1G_1\'

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/ASM_DISK_1G_1 /dev/disk/by-id/scsi-36000c2968513d97eb7cdd25bdbd10600-part1 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1\'

main: run: \'/bin/sh -c \'echo 180 >/sys/block/sdb/sdb1/timeout\'\'

 

 

 

[root@ora32 ~]# udevtest /block/sdg/sdg1

main: looking at device \'/block/sdg/sdg1\' from subsystem \'block\'

udev_rules_get_name: add symlink \'disk/by-id/scsi-36000c29682ba5ec7a4c8a189499a89bb-part1\'

udev_rules_get_name: add symlink \'disk/by-path/pci-0000:00:10.0-scsi-0:0:6:0-part1\'

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

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

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29682ba5ec7a4c8a189499a89bb\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29682ba5ec7a4c8a189499a89bb\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29682ba5ec7a4c8a189499a89bb\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29682ba5ec7a4c8a189499a89bb\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29682ba5ec7a4c8a189499a89bb\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29682ba5ec7a4c8a189499a89bb\'

run_program: \'/sbin/scsi_id\' returned with status 0

udev_rules_get_name: rule applied, \'sdg1\' becomes \'ASM_DISK_1G_2\'

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29682ba5ec7a4c8a189499a89bb\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29682ba5ec7a4c8a189499a89bb\'

run_program: \'/sbin/scsi_id\' returned with status 0

udev_device_event: device \'/block/sdg/sdg1\' already in database, validate currently present symlinks

udev_node_add: creating device node \'/dev/ASM_DISK_1G_2\', major = \'8\', minor = \'97\', mode = \'0660\', uid = \'503\', gid = \'504\'

udev_node_add: creating symlink \'/dev/disk/by-id/scsi-36000c29682ba5ec7a4c8a189499a89bb-part1\' to \'../../ASM_DISK_1G_2\'

udev_node_add: creating symlink \'/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:6:0-part1\' to \'../../ASM_DISK_1G_2\'

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/ASM_DISK_1G_2 /dev/disk/by-id/scsi-36000c29682ba5ec7a4c8a189499a89bb-part1 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:6:0-part1\'

main: run: \'/bin/sh -c \'echo 180 >/sys/block/sdg/sdg1/timeout\'\'

 

 

 

[root@ora32 ~]# udevtest /block/sdh/sdh2

main: looking at device \'/block/sdh/sdh2\' from subsystem \'block\'

udev_rules_get_name: add symlink \'disk/by-id/scsi-36000c292aa4a4ebbb25d15d2084c01ca-part1\'

udev_rules_get_name: add symlink \'disk/by-path/pci-0000:00:10.0-scsi-0:0:8:0-part1\'

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

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

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c292aa4a4ebbb25d15d2084c01ca\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c292aa4a4ebbb25d15d2084c01ca\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c292aa4a4ebbb25d15d2084c01ca\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c292aa4a4ebbb25d15d2084c01ca\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c292aa4a4ebbb25d15d2084c01ca\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c292aa4a4ebbb25d15d2084c01ca\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c292aa4a4ebbb25d15d2084c01ca\'

run_program: \'/sbin/scsi_id\' returned with status 0

udev_rules_get_name: rule applied, \'sdh2\' becomes \'ASM_DISK_1G_3\'

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c292aa4a4ebbb25d15d2084c01ca\'

run_program: \'/sbin/scsi_id\' returned with status 0

udev_device_event: device \'/block/sdh/sdh2\' already in database, validate currently present symlinks

udev_node_add: creating device node \'/dev/ASM_DISK_1G_3\', major = \'8\', minor = \'113\', mode = \'0660\', uid = \'503\', gid = \'504\'

udev_node_add: creating symlink \'/dev/disk/by-id/scsi-36000c292aa4a4ebbb25d15d2084c01ca-part1\' to \'../../ASM_DISK_1G_3\'

udev_node_add: creating symlink \'/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:8:0-part1\' to \'../../ASM_DISK_1G_3\'

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/ASM_DISK_1G_3 /dev/disk/by-id/scsi-36000c292aa4a4ebbb25d15d2084c01ca-part1 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:8:0-part1\'

main: run: \'/bin/sh -c \'echo 180 >/sys/block/sdh/sdh2/timeout\'\'

[root@ora32 ~]# udevtest /block/sdi/sdi1

main: looking at device \'/block/sdi/sdi1\' from subsystem \'block\'

udev_rules_get_name: add symlink \'disk/by-id/scsi-36000c29a98ca1bd8a0012e99f992a19d-part1\'

udev_rules_get_name: add symlink \'disk/by-path/pci-0000:00:10.0-scsi-0:0:9:0-part1\'

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

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

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29a98ca1bd8a0012e99f992a19d\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29a98ca1bd8a0012e99f992a19d\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29a98ca1bd8a0012e99f992a19d\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29a98ca1bd8a0012e99f992a19d\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29a98ca1bd8a0012e99f992a19d\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29a98ca1bd8a0012e99f992a19d\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29a98ca1bd8a0012e99f992a19d\'

run_program: \'/sbin/scsi_id\' returned with status 0

run_program: \'/sbin/scsi_id\'

run_program: \'/sbin/scsi_id\' (stdout) \'36000c29a98ca1bd8a0012e99f992a19d\'

run_program: \'/sbin/scsi_id\' returned with status 0

udev_rules_get_name: rule applied, \'sdi1\' becomes \'ASM_DISK_1G_4\'

udev_device_event: device \'/block/sdi/sdi1\' already in database, validate currently present symlinks

udev_node_add: creating device node \'/dev/ASM_DISK_1G_4\', major = \'8\', minor = \'129\', mode = \'0660\', uid = \'503\', gid = \'504\'

udev_node_add: creating symlink \'/dev/disk/by-id/scsi-36000c29a98ca1bd8a0012e99f992a19d-part1\' to \'../../ASM_DISK_1G_4\'

udev_node_add: creating symlink \'/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:9:0-part1\' to \'../../ASM_DISK_1G_4\'

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/ASM_DISK_1G_4 /dev/disk/by-id/scsi-36000c29a98ca1bd8a0012e99f992a19d-part1 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:9:0-part1\'

main: run: \'/bin/sh -c \'echo 180 >/sys/block/sdi/sdi1/timeout\'\'

 

 

重新启动udev服务

[root@ora32 ~]# /sbin/udevcontrol reload_rules

[root@ora32 ~]# /sbin/start_udev

Starting udev: [  OK  ]

 

查看一下新映射的磁盘

[root@ora32 ~]# ll /dev/ASM*

brw-rw---- 1 grid asmadmin 8,  17 May 13 15:40 /dev/ASM_DISK_1G_1

brw-rw---- 1 grid asmadmin 8,  97 May 13 15:40 /dev/ASM_DISK_1G_2

brw-rw---- 1 grid asmadmin 8, 113 May 13 15:40 /dev/ASM_DISK_1G_3

brw-rw---- 1 grid asmadmin 8, 129 May 13 15:40 /dev/ASM_DISK_1G_4

brw-rw---- 1 grid asmadmin 8,  33 May 13 15:43 /dev/ASM_DISK_2G_1

brw-rw---- 1 grid asmadmin 8,  49 May 13 15:43 /dev/ASM_DISK_2G_2

brw-rw---- 1 grid asmadmin 8,  65 May 13 15:42 /dev/ASM_DISK_2G_3

brw-rw---- 1 grid asmadmin 8,  81 May 13 15:43 /dev/ASM_DISK_2G_4

 

通过Oracle视图查看一下ASM磁盘情况

[grid@ora32 ~]$ sqlplus / as sysasm

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon May 13 15:42:05 2013

 

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Automatic Storage Management option

 

SQL>

SQL> col group# for 99

SQL> col disk# for 99

SQL> col name for a5

SQL> col path for a11

SQL> col LABEL for a7

SQL> col FAILGROUP for a10

SQL> select GROUP_NUMBER group#,DISK_NUMBER disk#,LABEL,STATE,FAILGROUP,name,path,TOTAL_MB,FREE_MB from v$asm_disk;

 

GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB    FREE_MB

------ ----- ------- -------- ---------- ----- ----------- ---------- ----------

     0     0         NORMAL                    /dev/ASM_DI          0          0

                                               SK_1G_3

 

     0     1         NORMAL                    /dev/ASM_DI          0          0

                                               SK_1G_2

 

     0     2         NORMAL                    /dev/ASM_DI          0          0

                                               SK_1G_1

 

     0     3         NORMAL                    /dev/ASM_DI          0          0

                                               SK_1G_4

 

GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB    FREE_MB

------ ----- ------- -------- ---------- ----- ----------- ---------- ----------

 

     1     2         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1612

                              02         TA_00 SK_2G_3

                                         02

 

     1     3         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1611

                              03         TA_00 SK_2G_4

                                         03

 

     1     1         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1613

                              01         TA_00 SK_2G_2

 

GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB    FREE_MB

------ ----- ------- -------- ---------- ----- ----------- ---------- ----------

                                         01

 

     1     0         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1612

                              00         TA_00 SK_2G_1

                                         00

 

 

8 rows selected.

此时发现新添加的4块硬盘,已经可以通过视图进行查询,但是FAILGROUP、NAME等属性为空,因为磁盘还没有加到ASM磁盘组。ASM是怎么认到新增加的磁盘?其实它是根据参数文件中的属性asm_diskstring自动扫描到的,这个参数是在安装GRID同时配置ASM时设置的。

SQL> show parameter ASM

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

asm_diskgroups                       string

asm_diskstring                       string      /dev/ASM*

asm_power_limit                      integer     1

asm_preferred_read_failure_groups    string

 

 

 

将磁盘ASM_DISK_1G_1、ASM_DISK_1G_2添加到磁盘组DG_DATA中。

SQL> ALTER DISKGROUP DG_DATA ADD disk \'/dev/ASM_DISK_1G_1\';

 

Diskgroup altered.

 

SQL> ALTER DISKGROUP DG_DATA ADD disk \'/dev/ASM_DISK_1G_2\';

 

Diskgroup altered.

 

新建磁盘组DG_NEW_DATA,将ASM_DISK_1G_3、ASM_DISK_1G_4添加到磁盘组中。

SQL> CREATE DISKGROUP DG_NEW_DATA external REDUNDANCY DISK \'/dev/ASM_DISK_1G_3\',\'/dev/ASM_DISK_1G_4\';

 

Diskgroup created.

 

通过Oracle 视图查看一下新增ASM磁盘组、ASM磁盘的情况

SQL> col name for a10

SQL> SELECT group_number,name,type,state,total_mb,free_mb,offline_disks FROM V$ASM_diskgroup;

 

GROUP_NUMBER NAME       TYPE   STATE         TOTAL_MB    FREE_MB OFFLINE_DISKS

------------ ---------- ------ ----------- ---------- ---------- -------------

           1 DG_DATA    EXTERN MOUNTED          10226       8482             0

           2 DG_NEW_DAT EXTERN MOUNTED           2038       1986             0

             A

 

SQL> select GROUP_NUMBER group#,DISK_NUMBER disk#,LABEL,STATE,FAILGROUP,name,path,TOTAL_MB,FREE_MB from v$asm_disk;

 

    GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB

---------- ----- ------- -------- ---------- ----- ----------- ----------

   FREE_MB

----------

         1     2         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047

                                  02         TA_00 SK_2G_3

                                             02

      1697

 

         1     3         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047

                                  03         TA_00 SK_2G_4

                                             03

      1697

 

    GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB

---------- ----- ------- -------- ---------- ----- ----------- ----------

   FREE_MB

----------

 

         1     1         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047

                                  01         TA_00 SK_2G_2

                                             01

      1699

 

         1     0         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047

                                  00         TA_00 SK_2G_1

                                             00

 

    GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB

---------- ----- ------- -------- ---------- ----- ----------- ----------

   FREE_MB

----------

      1697

 

         2     0         NORMAL   DG_NEW_DAT DG_NE /dev/ASM_DI       1019

                                  A_0000     W_DAT SK_1G_3

                                             A_000

                                             0

       994

 

         1     5         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       1019

 

    GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB

---------- ----- ------- -------- ---------- ----- ----------- ----------

   FREE_MB

----------

                                  05         TA_00 SK_1G_2

                                             05

       846

 

         1     4         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       1019

                                  04         TA_00 SK_1G_1

                                             04

       846

 

 

    GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB

---------- ----- ------- -------- ---------- ----- ----------- ----------

   FREE_MB

----------

         2     1         NORMAL   DG_NEW_DAT DG_NE /dev/ASM_DI       1019

                                  A_0001     W_DAT SK_1G_4

                                             A_000

                                             1

       992

 

 

8 rows selected.

 

 

根据实验要求4块硬盘添加完毕,接下来将硬盘ASM_DISK_1G_1、ASM_DISK_1G_2从ASM磁盘组DG_DATA中删除,然后将udev映射规则删除。

SQL> ALTER DISKGROUP DG_DATA DROP DISK DG_DATA_0004;

 

Diskgroup altered.

 

SQL> ALTER DISKGROUP DG_DATA DROP DISK DG_DATA_0005;

 

Diskgroup altered.

 

 

 

 

SQL> col group# for 99

SQL> col disk# for 99

SQL> col name for a5

SQL> col path for a11

SQL> col LABEL for a7

SQL> col FAILGROUP for a10

SQL> select GROUP_NUMBER group#,DISK_NUMBER disk#,LABEL,STATE,FAILGROUP,name,path,TOTAL_MB,FREE_MB from v$asm_disk;

 

GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB    FREE_MB

------ ----- ------- -------- ---------- ----- ----------- ---------- ----------

     0     0         NORMAL                    /dev/ASM_DI          0          0

                                               SK_1G_2

 

     0     1         NORMAL                    /dev/ASM_DI          0          0

                                               SK_1G_1

 

     1     2         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1612

                              02         TA_00 SK_2G_3

                                         02

 

     1     3         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1611

 

GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB    FREE_MB

------ ----- ------- -------- ---------- ----- ----------- ---------- ----------

                              03         TA_00 SK_2G_4

                                         03

 

     1     1         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1614

                              01         TA_00 SK_2G_2

                                         01

 

     1     0         NORMAL   DG_DATA_00 DG_DA /dev/ASM_DI       2047       1611

                              00         TA_00 SK_2G_1

                                         00

 

 

GROUP# DISK# LABEL   STATE    FAILGROUP  NAME  PATH          TOTAL_MB    FREE_MB

------ ----- ------- -------- ---------- ----- ----------- ---------- ----------

     2     0         NORMAL   DG_NEW_DAT DG_NE /dev/ASM_DI       1019        994

                              A_0000     W_DAT SK_1G_3

                                         A_000

                                         0

 

     2     1         NORMAL   DG_NEW_DAT DG_NE /dev/ASM_DI       1019        992

                              A_0001     W_DAT SK_1G_4

                                         A_000

                                         1

 

 

8 rows selected.

 

 

 

[root@ora32 ~]# vi /etc/udev/rules.d/99-oracle-asmdevices.rules

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c29c9a269653c7cd04ea2edb0c71, NAME=ASM_DISK_2G_1, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c29861258ebc95eded634a1f36fd, NAME=ASM_DISK_2G_2, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c296fd09d9ed213df1999820ca89, NAME=ASM_DISK_2G_3, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c2934ae12fd4af0dd366d85b42f5,  NAME=ASM_DISK_2G_4, WNER=grid, GROUP=asmadmin, MODE=0660

 

#KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

#RESULT==36000c2968513d97eb7cdd25bdbd10600,  NAME=ASM_DISK_1G_1, WNER=grid, GROUP=asmadmin, MODE=0660

 

#KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

#RESULT==36000c29682ba5ec7a4c8a189499a89bb,  NAME=ASM_DISK_1G_2, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c292aa4a4ebbb25d15d2084c01ca,  NAME=ASM_DISK_1G_3, WNER=grid, GROUP=asmadmin, MODE=0660

 

KERNEL==sd?1, BUS==scsi, PROGRAM==/sbin/scsi_id,

RESULT==36000c29a98ca1bd8a0012e99f992a19d,  NAME=ASM_DISK_1G_4, WNER=grid, GROUP=asmadmin, MODE=0660

 

重新启动udev

[root@ora32 dev]# /sbin/udevcontrol reload_rules

[root@ora32 dev]# /sbin/start_udev

Starting udev: [  OK  ]

 

查看一下dev下的设备,发现仍然存在/dev/ASM_DISK_1G_1,/dev/ASM_DISK_1G_2

[root@ora32 dev]# ll /dev/ASM*

brw-rw---- 1 grid asmadmin 8,  17 May 13 16:15 /dev/ASM_DISK_1G_1

brw-rw---- 1 grid asmadmin 8,  97 May 13 16:15 /dev/ASM_DISK_1G_2

brw-rw---- 1 grid asmadmin 8, 113 May 13 16:38 /dev/ASM_DISK_1G_3

brw-rw---- 1 grid asmadmin 8, 129 May 13 16:37 /dev/ASM_DISK_1G_4

brw-rw---- 1 grid asmadmin 8,  33 May 13 16:38 /dev/ASM_DISK_2G_1

brw-rw---- 1 grid asmadmin 8,  49 May 13 16:38 /dev/ASM_DISK_2G_2

brw-rw---- 1 grid asmadmin 8,  65 May 13 16:38 /dev/ASM_DISK_2G_3

brw-rw---- 1 grid asmadmin 8,  81 May 13 16:37 /dev/ASM_DISK_2G_4

 

不知道是何原因。将数据库实例和ASM实例都停掉后,重新启动udev服务后发现dev下仍然存在/dev/ASM_DISK_1G_1,/dev/ASM_DISK_1G_2,通过udevinfo查询发现已经在udev不存在记录。

 

[root@ora32 dev]# udevinfo -q path -n /dev/ASM_DISK_1G_1

no record for \'ASM_DISK_1G_1\' in database

[root@ora32 dev]# udevinfo -q path -n /dev/ASM_DISK_1G_2

no record for \'ASM_DISK_1G_2\' in database

[root@ora32 dev]#

[root@ora32 dev]# udevinfo -q path -n /dev/ASM_DISK_1G_3

/block/sdh/sdh2

 

 

在网上查阅了资料,并未找到解决/dev/ASM_DISK_1G_1,/dev/ASM_DISK_1G_2为什么仍然存在的原因,继续跟踪这个问题。

新网虚拟主机