软件环境:

系统:rhel-server-5.4-x86_64

数据库:oracle10201

asm环境:

oracleasm-2.6.18-164.el5-2.0.5-1.el5.x86_64.rpm
oracleasmlib-2.0.4-1.el5.x86_64.rpm
oracleasm-support-2.1.7-1.el5.x86_64.rpm

本来是想安装好数据库就建库,在进行升级实验。没想到进行了数据软件升级后,进行数据字典升级时,问题出现了,asm实例起不了:

[oracle@peng ~]$ export ORACLE_SID=+ASM
[oracle@peng ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Oct 27 15:13:53 2011

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

Connected to an idle instance.

SQL> startup
ASM instance started

Total System Global Area  130023424 bytes
Fixed Size                  2019032 bytes
Variable Size             102838568 bytes
ASM Cache                  25165824 bytes
ORA-15032: not all alterations performed
ORA-15063: ASM discovered an insufficient number of disks for diskgroup "PENG"

到系统上查看,列出已有的Oracle ASMLib disks:

[root@peng ~]# /etc/init.d/oracleasm listdisks

没有输出。

但是查看Oracle ASMlib所包含的磁盘时,却有相关信息:

[root@peng ~]# /etc/init.d/oracleasm querydisk /dev/VolGroup00/LogVol02
Device "/dev/VolGroup00/LogVol02" is marked an ASM disk with the label "VOL1"
[root@peng ~]# /etc/init.d/oracleasm querydisk /dev/VolGroup00/LogVol03
Device "/dev/VolGroup00/LogVol03" is marked an ASM disk with the label "VOL2"

试着进行Oracle ASMlib磁盘扫描:

[root@peng ~]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks:               [  OK  ]
[root@peng ~]# /etc/init.d/oracleasm listdisks
扫描显示ok,但是再次查看仍然没有结果。

继续查找原因:

[root@peng ~]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
oracleasmfs on /dev/oracleasm type oracleasmfs (rw)
发现asm磁盘挂载/dev/oracleasm下。

[root@peng oracleasm]# ls
disks  iid
[root@peng oracleasm]# ls disks/
[root@peng oracleasm]# ls iid/
0000000000000001
果然disks下没有文件,正常是有相应的设备文件的。

查看报错日志发现:

[root@peng ~]# tail -19 /var/log/oracleasm
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
oracleasm-read-label: Unable to open device "/dev/dm-0": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-0": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-0": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-0": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-1": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-1": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-1": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-1": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-2": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-2": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-2": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-2": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-3": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-3": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-3": No such file or directory
oracleasm-read-label: Unable to open device "/dev/dm-3": No such file or directory

[root@peng ~]# ls /dev/dm-*
ls: /dev/dm-*: 没有那个文件或目录

果然,没有结果的原因是因为在扫描系统的asm磁盘是不能读取/dev/dm-0,/dev/dm-1,/dev/dm-2,/dev/dm-3设备

没有,可不可以自己通过udev定义规则来生成一个呢?而一些设备信息会放在/sys/block/目录下,进入该目录下发现,所缺的设备都已经存在:

[root@peng ~]# cd /sys/block/
[root@peng block]# ls
dm-0  dm-2  fd0  md0   ram1   ram11  ram13  ram15  ram3  ram5  ram7  ram9
dm-1  dm-3  hdc  ram0  ram10  ram12  ram14  ram2   ram4  ram6  ram8  sda
此时才明白,原来在第一次创建asm磁盘时,这些设备文件都已经创建,只是没在系统中进行注册,所以再次启动asm时,系统不能正常的识别的这些设备而已。

既然这样,就手动将这些设备收编了吧。

[root@peng ~]# udevinfo -a -p /sys/block/dm-0

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/dm-0':
    KERNEL=="dm-0"
    SUBSYSTEM=="block"
    SYSFS{stat}=="   21819        0   922402  1690960    13024        0   104192  1251320        0   168972  2942280"
    SYSFS{size}=="20971520"
    SYSFS{removable}=="0"
    SYSFS{range}=="1"
    SYSFS{dev}=="253:0"

依次将dm-1,dm-2,dm-3的信息打印出来,并写入/etc/udev/rule.d/90-dm.rules
文件中。

[root@peng rules.d]# cat 90-dm.rules
KERNEL=="dm-0",SUBSYSTEM=="block",SYSFS{size}=="20971520", SYSFS{dev}=="253:0"
KERNEL=="dm-1",SUBSYSTEM=="block",SYSFS{size}=="4128768",SYSFS{dev}=="253:1"
KERNEL=="dm-2",SUBSYSTEM=="block",SYSFS{size}=="16842752",SYSFS{dev}=="253:2"
KERNEL=="dm-3",SUBSYSTEM=="block",SYSFS{size}=="16842752",SYSFS{dev}=="253:3"

[root@peng rules.d]# start_udev
启动 udev:                                                [确定]
将规则文件中得信息和相应的设备进行匹配。

[root@peng ~]# ls /dev/dm-*
/dev/dm-0  /dev/dm-1  /dev/dm-2  /dev/dm-3

查看设备文件已经生成。

[root@peng ~]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks:               [  OK  ]

再次进行设备扫描。然后列出设备。

[root@peng ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2

[root@peng ~]# tail -7 /var/log/oracleasm
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
Disk "VOL1" does not exist or is not instantiated
Instantiating disk "VOL1"
Disk "VOL2" does not exist or is not instantiated
Instantiating disk "VOL2"

查看日志,一切正常。

[root@peng ~]# ls /dev/oracleasm/disks/
VOL1  VOL2

/dev/oracleasm/disks下的设备文件显示正常。

再次启动asm实例:

[oracle@peng ~]$ export ORACLE_SID=+ASM
[oracle@peng ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Oct 27 16:10:41 2011

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

Connected to an idle instance.

SQL> startup
ASM instance started

Total System Global Area  130023424 bytes
Fixed Size                  2019032 bytes
Variable Size             102838568 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted

问题解决,可以进行继续升级了。