Use below scripts to get the needed mapping between the ASM raw disks to OS devices to SCSI ID's.
use below script if your Unix admin is using dev rules for mapping....
run below one as oracle user ... if needed this to run as grid owner then change the logic below..
1) 1st script:-
disk_info.sql
{
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;
spool off
use below script if your Unix admin is using dev rules for mapping....
run below one as oracle user ... if needed this to run as grid owner then change the logic below..
1) 1st script:-
disk_info.sql
{
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;
spool off
}
2) 2nd script which is *.sh
ASM_disk_SCSI_shell.sh
{
COMMAND=$0
PGM=${COMMAND##*/}
host_name=`hostname | cut -d"." -f1`
# Remove nohup.out files if any from previous execution.
if [ -f nohup.out ]; then
rm nohup.out
fi
#
## Choose directory/Path or hit enter to choose default path(currect directory).
echo "Enter the unix directory path to create the reports.Press Enter to create in current directory:"
read dir
if [ "$dir" = "" ]
then
repdir=$PWD
else
repdir=$dir
cp $PWD/*.sql $repdir
fi
##
### Remove the old log files.
cd $repdir
rm $repdir/*.log
rm $repdir/*.html
###
#### Chech to find which database/instance is up and running based on crontab entries.
for db in `cat /etc/oratab| egrep -v '(^#|\+|\-)'|cut -f1 -d: -s|egrep -v 'OMS'|egrep -v 'AGENT'`
do
echo "$db";
db_check=`pgrep -al pmon|grep $db |cut -f3,4 -d_`
if [ -n "$db_check" ]
then
db_sid=$db_check
# echo "$db_sid"
echo "$db"
dbhome=`cat /etc/oratab|egrep $db|egrep -v '(^#|\+)'|cut -f2 -d: -s`
echo "$dbhome"
uname -a
break
else
echo "db_check is empty";
fi
done
####
### /// Setting environment variables.
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/xterm:/sbin:/opt/freeware/bin:/bin:.
export ORACLE_SID=$db_check
export ORACLE_HOME=$dbhome
PATH=$ORACLE_HOME/bin:$PATH
LIBPATH=$ORACLE_HOME/lib:$LIBPATH
### ///
#### Login into database to get the Disk info.
sqlplus / as sysdba << EOF
set heading off
set feedback off
set echo off
set pagesize 0
@$repdir/disk_info.sql
exit
EOF
sort -b -V -k 2 $repdir/asm_info.log >>$repdir/asm_info_cut.log_1
mv $repdir/asm_info_cut.log_1 $repdir/asm_info.log
cat asm_info.log| awk '{print $2}' >> $repdir/asm_info_cut.log
cat asm_info_cut.log | sort -V >asm_info_cut_1.log
mv asm_info_cut_1.log 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 -w $disk | awk '{print $2}' | grep -Po '".*?"' | grep -oP '"\K[^"]+' `" >> $repdir/asm_disk_lun_info.log
echo "` raw -qa | grep -w $disk | awk '{print $1,$5,$7}' | sed 's/,//;s/://g' | awk '{ print $1"\t"$2":"$3}' `" >>asm_disk_lun_info_m.log
done
cat $repdir/asm_disk_lun_info.log |while read rawd
do
echo "$rawd `lsscsi | grep $rawd'' | tr '[' '\t' | tr ']' '\t' | awk '{print $1}'` " >> $repdir/asm_raw-physical.log
done
paste $repdir/asm_info.log $repdir/asm_disk_lun_info.log $repdir/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 : "")}' >> $repdir/asm_info_final.log;
exit;
}
Hope this helps...
Interesting information.
ReplyDeleteMysql DBA Training