Conde Bond Post

Sólo existe un tipo de conocimiento, aquel que se transmite.

Mapping (Virtual) SCSI Devices with ASM Content


Recently, we had to change the storage of a vm host in which we had an Oracle database server (single instance) with ASM.
This simple script allows to know which virtual SCSI devices contain ASM disks and also displays the linux volume.

for isd in $(find /sys/bus/scsi/devices/  | sort)
  do
    if [ -n $isd ] ; then
      if [[ $isd != "/sys/bus/scsi/devices/" ]] ; then 
        ppidv=$(echo $isd | cut -d"/" -f6 | awk -F":" '{print "SCSI ("$1":"$2") Hardk disk "$3}') # Pretty Print
        idv=$(ls -l /dev/$(ls -d $(echo $isd | sed -e "s/\:/\\\:/g")/block* 2>/dev/null | awk -F":" '{print $5}' )[0-9] | awk '{print $10}' 2>/dev/null)
        if [[ -n  $idv ]] ; then
          tmpV=$(/usr/sbin/oracleasm querydisk $idv 2>/dev/null | grep " with the label");
          if [[ $(echo "$tmpV" | grep "is not marked as an ASM disk" | wc -l ) -eq 0 ]] ; then
            if [[ ! -z $tmpV ]] ; then
              tmpStr1=$(fdisk -l | grep "Disk $(echo "$tmpV" | awk '{print $2}' | tr -d "[0-9]" | tr -d '"')" | awk '{print $3" "$4}' | tr -d ",")
              tmpStr2=$(echo "ASM Device Found : "$(echo "$tmpV" | awk '{print $2"       "$11}') | tr -d '"')
              if [[ $(echo $ppidv | grep "SCSI (0:0)" | wc -l ) -eq 0 ]]; then
                TAB="$(printf '\t')"
                echo "$ppidv $TAB $tmpStr1 $TAB $tmpStr2 " 
              fi
            fi
          fi
        fi
      fi
      idv="";        pdv="";       tmpV="";
      tmpStr1="";    tmpStr2=""
    fi
done

The output looks like this…

SCSI (1:0) Hardk disk 0     109.4 GB    ASM Device Found : /dev/sdd1 ASM_DB_DAT00
SCSI (1:0) Hardk disk 1     109.4 GB    ASM Device Found : /dev/sde1 ASM_DB_DAT01
SCSI (1:0) Hardk disk 10    109.4 GB    ASM Device Found : /dev/sdm1 ASM_DB_DAT09
SCSI (1:0) Hardk disk 11    109.4 GB    ASM Device Found : /dev/sdn1 ASM_DB_DAT10
SCSI (1:0) Hardk disk 12    109.4 GB    ASM Device Found : /dev/sdo1 ASM_DB_DAT11
SCSI (1:0) Hardk disk 13    109.4 GB    ASM Device Found : /dev/sdp1 ASM_DB_DAT12
SCSI (1:0) Hardk disk 14    109.4 GB    ASM Device Found : /dev/sdq1 ASM_DB_DAT13
SCSI (1:0) Hardk disk 15    109.4 GB    ASM Device Found : /dev/sdr1 ASM_DB_DAT14
SCSI (1:0) Hardk disk 2     109.4 GB    ASM Device Found : /dev/sdf1 ASM_DB_DAT02
SCSI (1:0) Hardk disk 3     109.4 GB    ASM Device Found : /dev/sdg1 ASM_DB_DAT03
SCSI (1:0) Hardk disk 4     109.4 GB    ASM Device Found : /dev/sdh1 ASM_DB_DAT04
SCSI (1:0) Hardk disk 5     109.4 GB    ASM Device Found : /dev/sdi1 ASM_DB_DAT05
SCSI (1:0) Hardk disk 6     109.4 GB    ASM Device Found : /dev/sdj1 ASM_DB_DAT06
SCSI (1:0) Hardk disk 8     109.4 GB    ASM Device Found : /dev/sdk1 ASM_DB_DAT07
SCSI (1:0) Hardk disk 9     109.4 GB    ASM Device Found : /dev/sdl1 ASM_DB_DAT08
SCSI (2:0) Hardk disk 0     38.3 GB     ASM Device Found : /dev/sds1 ASM_DB_TMP001
SCSI (2:0) Hardk disk 1     109.4 GB    ASM Device Found : /dev/sdt1 ASM_DB_YTS00
SCSI (2:0) Hardk disk 10    109.4 GB    ASM Device Found : /dev/sdab1 ASM_DB_YTS08
SCSI (2:0) Hardk disk 11    109.4 GB    ASM Device Found : /dev/sdac1 ASM_DB_YTS09
SCSI (2:0) Hardk disk 12    10.7 GB     ASM Device Found : /dev/sdad1 ASM_DB_LOG02
SCSI (2:0) Hardk disk 13    12.8 GB     ASM Device Found : /dev/sdae1 ASM_DB_LOG03
SCSI (2:0) Hardk disk 14    109.4 GB    ASM Device Found : /dev/sdaf1 ASM_DB_FSH00
SCSI (2:0) Hardk disk 15    109.4 GB    ASM Device Found : /dev/sdag1 ASM_DB_FSH01
SCSI (2:0) Hardk disk 2     109.4 GB    ASM Device Found : /dev/sdu1 ASM_DB_YOT01
SCSI (2:0) Hardk disk 3     109.4 GB    ASM Device Found : /dev/sdv1 ASM_DB_YOT02
SCSI (2:0) Hardk disk 4     109.4 GB    ASM Device Found : /dev/sdw1 ASM_DB_YOT03
SCSI (2:0) Hardk disk 5     109.4 GB    ASM Device Found : /dev/sdx1 ASM_DB_Y0T04
SCSI (2:0) Hardk disk 6     109.4 GB    ASM Device Found : /dev/sdy1 ASM_DB_YOT05
SCSI (2:0) Hardk disk 8     109.4 GB    ASM Device Found : /dev/sdz1 ASM_DB_YOT06
SCSI (2:0) Hardk disk 9     109.4 GB    ASM Device Found : /dev/sdaa1 ASM_DB_YOT07
SCSI (3:0) Hardk disk 1     12.8 GB     ASM Device Found : /dev/sdai1 ASM_DB_CTL01
SCSI (3:0) Hardk disk 10    109.4 GB    ASM Device Found : /dev/sdaq1 ASM_DB_DAT18
SCSI (3:0) Hardk disk 11    109.4 GB    ASM Device Found : /dev/sdar1 ASM_DB_DAT17
SCSI (3:0) Hardk disk 12    109.4 GB    ASM Device Found : /dev/sdas1 ASM_DB_DAT16
SCSI (3:0) Hardk disk 14    96.4 GB     ASM Device Found : /dev/sdau1 ASM_DB_DAT15
SCSI (3:0) Hardk disk 2     12.8 GB     ASM Device Found : /dev/sdaj1 ASM_DB_CTL02
SCSI (3:0) Hardk disk 3     12.8 GB     ASM Device Found : /dev/sdak1 ASM_DB_LOG00
SCSI (3:0) Hardk disk 4     12.8 GB     ASM Device Found : /dev/sdal1 ASM_DB_LOG01
SCSI (3:0) Hardk disk 5     12.8 GB     ASM Device Found : /dev/sdam1 ASM_DB_LOG02
SCSI (3:0) Hardk disk 6     12.8 GB     ASM Device Found : /dev/sdan1 ASM_DB_LOG03
SCSI (3:0) Hardk disk 8     12.8 GB     ASM Device Found : /dev/sdao1 ASM_DB_LOG00
SCSI (3:0) Hardk disk 9     12.8 GB     ASM Device Found : /dev/sdap1 ASM_DB_LOG01

I hope it’s helpful.

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: