Wednesday, June 25, 2014

Map ASM disks to physical ones

Once ASM is configured and ASM disks are created several structures are created:

[root@dba-test2 ~]# ls -l /dev/oracleasm
total 0
drwxr-xr-x 1 root   root     0 Sep 29 04:28 disks
drwxrwx--- 1 oracle oinstall 0 Sep 29 03:40 iid
 
On the /dev/oracleasm/disks directory are located the ASMLib mappings of ASM devices to physical devices

[root@dba-test2 ~]# ls -l /dev/oracleasm/disks/
total 0
brw-rw---- 1 grid asmadmin 202,  33 Sep 29 04:28 ASMDISK01
brw-rw---- 1 grid asmadmin 202,  49 Sep 29 04:28 ASMDISK02
brw-rw---- 1 grid asmadmin 202,  65 Sep 29 04:28 ASMDISK03
brw-rw---- 1 grid asmadmin 202,  81 Sep 29 04:28 ASMDISK04
brw-rw---- 1 grid asmadmin 202,  97 Sep 29 04:28 ASMDISK05
brw-rw---- 1 grid asmadmin 202, 193 Sep 29 04:28 ASMDISK06

The major and minor numbers permit to map the ASM Disks to the physical devices

[root@dba-test2 ~]# ls -l /dev/* |grep 202, |egrep " 33 | 49 | 65 | 81 | 97 | 193 "
brw-r-----  1 root disk     202,  33 Sep 29 04:28 /dev/xvdc1
brw-r-----  1 root disk     202,  49 Sep 29 04:28 /dev/xvdd1
brw-r-----  1 root disk     202,  65 Sep 29 04:28 /dev/xvde1
brw-r-----  1 root disk     202,  81 Sep 29 04:28 /dev/xvdf1
brw-r-----  1 root disk     202,  97 Sep 29 04:28 /dev/xvdg1
brw-r-----  1 root disk     202, 193 Sep 29 04:28 /dev/xvdm1
 
A faster way to do it would be to use the short perl script I wrote for this :

#!/usr/bin/perl

my @asmmajmin = qx 'ls -l /dev/oracleasm/disks/';
my @alldevsmajmin = qx 'ls -l /dev/*';
my %mapasmmin = my %mapdiskmin = ();

foreach (@asmmajmin) {
        if (/^b.*\s+(\d+,)\s+(\d+).*\d+:\d+\s+(.*$)/) {
                $mapasmmin{$2} = $3;
                $maj = $1;
        }
}
my $major = $maj;

foreach (@alldevsmajmin) {
        if (/^b.*$major\s+(\d+).*\d+:\d+\s+(.*$)/) {
                $mapdiskmin{$1} = $2;
        }
}

foreach (sort (keys %mapasmmin)) {
  chomp;
  print "The asmdisk $mapasmmin{$_} maps to $mapdiskmin{$_}\n";
}
 
Another way to do this is to issue the following command provided that you are the owner of the /dev/xvd* devices : 
 
[root@dba-test2 ~]# /etc/init.d/oracleasm querydisk /dev/xvd*1
Device "/dev/xvda1" is not marked as an ASM disk
Device "/dev/xvdb1" is not marked as an ASM disk
Device "/dev/xvdc1" is marked an ASM disk with the label "ASMDISK01"
Device "/dev/xvdd1" is marked an ASM disk with the label "ASMDISK02"
Device "/dev/xvde1" is marked an ASM disk with the label "ASMDISK03"
Device "/dev/xvdf1" is marked an ASM disk with the label "ASMDISK04"
Device "/dev/xvdg1" is marked an ASM disk with the label "ASMDISK05"
Device "/dev/xvdh1" is marked an ASM disk with the label "ASMDISK08"
Device "/dev/xvdi1" is marked an ASM disk with the label "ASMDISK07"
Device "/dev/xvdj1" is not marked as an ASM disk
Device "/dev/xvdk1" is not marked as an ASM disk
Device "/dev/xvdl1" is not marked as an ASM disk
Device "/dev/xvdm1" is marked an ASM disk with the label "ASMDISK06"
 

No comments:

Post a Comment