Es una tarea bastante frecuente, tener que realizar el mapeo de nuestros discos ASM con los dispositivos físicos asociados a nivel sistema operativo.
Cuando utilizamos ASMLib en Linux, desde la vista v$asm_disk podemos obtener el path de los discos ASM:
select dg.name "Group"
, ds.total_mb/1024 "Total GB"
, ds.name "Disk Name"
, ds.path "Path"
from v$asm_disk_stat ds, v$asm_diskgroup dg
where header_status not in ('FORMER','CANDIDATE')
and ds.group_number = dg.group_number
order by dg.name;
(Esta consulta puede ser modificada a gusto)
Group Total GB Disk Name Path
-------------------- ---------- ------------------------------ ------------------------------
DATA1 100 DISK01 ORCL:DISK01
DATA1 100 DISK03 ORCL:DISK03
DATA1 100 DISK04 ORCL:DISK04
DATA1 100 DISK05 ORCL:DISK05
DATA2 50 DISK06 ORCL:DISK06
DATA2 50 DISK07 ORCL:DISK07
DATA2 50 DISK08 ORCL:DISK08
FRA1 100 DISK20 ORCL:DISK20
FRA2 100 DISK21 ORCL:DISK21
El problema aqui es que el Path de ASMLib NO nos dá información de cual es el dispositivo fisico asociado el disco.
Para obtener esta información, debemos recurrir el utilitario de linea de comando propio de la librería: /etc/init.d/oracleasm
Tenemos dos comando que pueden resultarnos utiles para nuestro proposito: listdisks y querydisk. Este último es el que va devolvernos la información necesaria.
The basic oracleasm commands are:
configure Configure the Oracle Linux ASMLib driver
init Load and initialize the ASMLib driver
exit Stop the ASMLib driver
scandisks Scan the system for Oracle ASMLib disks
status Display the status of the Oracle ASMLib driver
listdisks List known Oracle ASMLib disks
querydisk Determine if a disk belongs to Oracle ASMlib
createdisk Allocate a device for Oracle ASMLib use
deletedisk Return a device to the operating system
renamedisk Change the label of an Oracle ASMlib disk
update-driver Download the latest ASMLib driver
[root@server01 tmp]# /etc/init.d/oracleasm querydisk
Usage: oracleasm-querydisk [-l <manager>] [-v] [-d|-p] <label>|<device> ..
[root@server01 tmp]# /etc/init.d/oracleasm querydisk DISK05
Disk "DISK05" is a valid ASM disk
[root@server01 tmp]# /etc/init.d/oracleasm querydisk -p DISK05
Disk "DISK05" is a valid ASM disk
/dev/sdba: LABEL="DISK05" TYPE="oracleasm"
/dev/sddu: LABEL="DISK05" TYPE="oracleasm"
/dev/sdgo: LABEL="DISK05" TYPE="oracleasm"
/dev/sdji: LABEL="DISK05" TYPE="oracleasm"
/dev/mapper/oradisk05: LABEL="DISK05" TYPE="oracleasm"
[root@server01 tmp]# /etc/init.d/oracleasm querydisk -d DISK05
Disk "DISK05" is a valid ASM disk on device [253,52]
[root@server01 mapper]# ls -l /dev|grep 253|grep 52
brw-rw----. 1 root disk 253, 52 Jun 24 10:26 dm-52
[root@server01 mapper]# ls -lrt /dev/mapper/oradisk05
lrwxrwxrwx. 1 root root 8 Jun 24 10:26 /dev/mapper/oradisk05 -> ../dm-52
El especialista Alejandro Vargas, proporciona en su blog un script que nos puede facilitar la tarea de obtener la información de todos los discos ASM:
---------- start here ------------
#!/bin/ksh
for i in `/etc/init.d/oracleasm listdisks`
do
v_asmdisk=`/etc/init.d/oracleasm querydisk $i | awk '{print $2}'`
v_minor=`/etc/init.d/oracleasm querydisk $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk '{print $1}'`
v_major=`/etc/init.d/oracleasm querydisk $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk '{print $2}'`
v_device=`ls -la /dev | grep $v_minor | grep $v_major | awk '{print $10}'`
echo "ASM disk $v_asmdisk based on /dev/$v_device [$v_minor $v_major]"
done
---------- finish here -----------
En el caso de utilizar muiltipath, el siguiente script basado en el flag -p nos permite obtener sobre que alias de multipath se ha creado el disco ASM:
---------- start here ------------
#!/bin/bash
for i in `/etc/init.d/oracleasm listdisks`
do
v_asmdisk=`/etc/init.d/oracleasm querydisk $i | awk '{print $2}'`
v_dev=`/etc/init.d/oracleasm querydisk -p $i |grep mapper| awk '{print $1}'|sed 's/:$//'`
echo "ASM disk $v_asmdisk based on $v_dev"
done
---------- finish here -----------
ASM disk "DISK01" based on /dev/mapper/oradisk01
ASM disk "DISK02" based on /dev/mapper/oradisk02
ASM disk "DISK03" based on /dev/mapper/oradisk03
ASM disk "DISK04" based on /dev/mapper/oradisk04
ASM disk "DISK05" based on /dev/mapper/oradisk05
ASM disk "DISK06" based on /dev/mapper/oradisk06
ASM disk "DISK07" based on /dev/mapper/oradisk07
ASM disk "DISK08" based on /dev/mapper/oradisk08
ASM disk "DISK20" based on /dev/mapper/oradisk20
ASM disk "DISK20" based on /dev/mapper/oradisk21
#!/bin/ksh
for i in `/etc/init.d/oracleasm listdisks`
do
v_asmdisk=`/etc/init.d/oracleasm querydisk $i | awk '{print $2}'`
v_mpath=`/etc/init.d/oracleasm querydisk -p $i |grep mapper| awk '{print $1}'|sed 's/:$//'`
v_dev=`ls -lrt $v_mpath| awk '{print $11}'`
echo "ASM disk $v_asmdisk based on $v_mpath -> $v_dev"
done
ASM disk "DISK01" based on /dev/mapper/oradisk01 -> ../dm-55
ASM disk "DISK02" based on /dev/mapper/oradisk02 -> ../dm-57
ASM disk "DISK03" based on /dev/mapper/oradisk03 -> ../dm-54
ASM disk "DISK04" based on /dev/mapper/oradisk04 -> ../dm-53
ASM disk "DISK05" based on /dev/mapper/oradisk05 -> ../dm-52
ASM disk "DISK06" based on /dev/mapper/oradisk06 -> ../dm-45
ASM disk "DISK07" based on /dev/mapper/oradisk07 -> ../dm-33
ASM disk "DISK08" based on /dev/mapper/oradisk08 -> ../dm-23
ASM disk "DISK20" based on /dev/mapper/oradisk20 -> ../dm-34
ASM disk "DISK21" based on /dev/mapper/oradisk21 -> ../dm-9
Espero les resulte útil.
Saludos,
Referencia:
https://blogs.oracle.com/AlejandroVargas/entry/mapping_asm_disks_to_physical
Buen script!
ResponderEliminar