Wednesday, January 3, 2018

Script to get Lun ids for Linux in VM for ASM disks.



Below information will be handy when you want to know the lun id'd for the raw devices you are using in the ASM environment ..this will eliminate the need for you to wait for Unix admins to give you the lun info. ....

> there are 2 scripts... one is .sql and another one is .sh(main shell)..

1)
 make a script to ger ASM info of the raw devices...

set heading off
set feedback off
set echo off
set pagesize 0
col NAME for a30
col PATH for a30
spool asm_info.log
select NAME,PATH,OS_MB from V$ASM_DISK order by NAME asc;

2)
then make a main shell.... and give execute permissions...

--------------------------------------------------------------------
ORACLE_SID=+ASM
ORACLE_HOME=/usr/app/oracle/db_1
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID
export ORACLE_HOME
export PATH
echo $ORACLE_SID
echo $ORACLE_HOME
cd /usr/job/scripts/lun_info

rm -f /usr/job/scripts/lun_info/asm_info.log
rm -f /usr/job/scripts/lun_info/asm_info_cut.log
rm -f /usr/job/scripts/lun_info/asm_info_final.log
rm -f /usr/job/scripts/lun_info/asm_disk_lun_info.log
rm -f /usr/job/scripts/lun_info/asm_raw-physical.log

sqlplus / as sysdba << EOF
set heading off
set feedback off
set echo off
set pagesize 0
@disk_info.sql
exit
EOF
#cat asm_info.log|cut -c7- > asm_info_cut.log
cat asm_info.log| awk '{print $2}' > asm_info_cut.log
cat asm_info_cut.log|while read disk
do
echo "`cat /etc/udev/rules.d/60-raw.rules | grep -v '^#' | grep $disk | awk '{print $2}' | grep -Po '".*?"' | grep -oP '"\K[^"]+' `" >> asm_disk_lun_info.log
done

cat asm_disk_lun_info.log |while read rawd
do
echo "$rawd  `lsscsi | grep $rawd'' | awk '{print $1}'` " >> asm_raw-physical.log
done

paste asm_info.log asm_disk_lun_info.log asm_raw-physical.log| awk  '
BEGIN {
format = "%-20s %-18s %-19s %-18s  %-19s %s\n"
printf format,  "ASM_groups", "ASM_RAW_DISK",  "OS_DISK_SIZE", "UNIX_MAP_Disk", "LINUX_id",  "LINUX_SCSI_id"
printf format,  "----------", "-------------", "------------", "-------------", "--------", "-------------"}
{for(i=1;i<=NF;i++)
printf("%-20s%c", $i, (i==NF) ? ORS : "")}' >> asm_info_final.log;
exit;

--------------------------------------------------------------------------------------------


look for asm_info_final.log...... for this column....

LINUX_SCSI_id  --- validate with your storage admins...

Hope this helps......................................


No comments:

Post a Comment

PostgreSql: Useful Commands-

 1)   ************************* Users ***************************  -- List of users with roles assigned: SELECT usename AS role_name,   CASE...