How to map device name to ASMLIB disk [ID 1098682.1]

msdnchina發表於2011-10-10

Applies to:

Oracle Server - Enterprise Edition - Version: 10.2.0.1 to 11.2.0.1 - Release: 10.2 to 11.2
Generic Linux

Goal

ASMLIB is a support library for the Automatic Storage Management (ASM) feature of the Oracle Database and is available for the Linux operating system. ASMLIB packages are available for Linux kernel 2.4 and 2.6 for the following Linux operating systems:
  • Suse Linux Enterprise Server/United Linux versions 8 - 11
  • Red Hat Advanced Server 2.1, Red Hat Enterprise Linux versions 3 - 5
  • Oracle Enterprise Linux version 5
When ASMLIB is used to manage ASM disks, the device path information is not presented in GV$ASM_DISK.PATH. So, how do we map the device name to the ASMLIB disk name?


Solution

That information can be obtained with the following shell script:

#!/bin/bash
for asmlibdisk in `ls /dev/oracleasm/disks/*`
do
echo "ASMLIB disk name: $asmlibdisk"
asmdisk=`kfed read $asmlibdisk | grep dskname | tr -s | cut -f2 -d`
echo "ASM disk name: $asmdisk"
majorminor=`ls -l $asmlibdisk | tr -s | cut -f5,6 -d`
device=`ls -l /dev | tr -s | grep "$majorminor" | cut -f10 -d`
echo "Device path: /dev/$device"
done

The script can be run as OS user that owns ASM or Grid Infrastructure home (oracle/grid), i.e. it does not need to be run as privileged user. The only requirement it that kfed binary exists and that it is in the PATH.

If an ASMLIB disk was already deleted, it will not show up in /dev/oracleasm/disks. We can check for devices that are (or were) associated with ASM with the following shell script:

#!/bin/bash
for device in `ls /dev/sd*`
do
asmdisk=`kfed read $device | grep ORCLDISK | tr -s | cut -f2 -d | cut -c1-8`
if [ "$asmdisk" = "ORCLDISK" ]
then
echo "Disk device $device may be an ASM disk!"
fi
done

The second scripts takes a peek at sd devices in /dev, so in addition to the requirement for the kfed binary to be in the PATH, it also needs to be run as privileged user. Of course we can look at /dev/dm*, /dev/mapper, etc or all devices in /dev, although that may not be a good idea.

The kfed binary should be available in RDBMS home (prior to version 11.2) and in the Grid Infrastructure home (in version 11.2 and later). If the binary is not there, it can be built as follows:

cd $ORACLE_HOME/rdbms/lib
make -f ins* ikfed

Where ORACLE_HOME is the RDBMS home (prior to version 11.2) and the Grid Infrastructure home in version 11.2 and later.[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/161195/viewspace-1055563/,如需轉載,請註明出處,否則將追究法律責任。

相關文章