[ora11g@ol7 ~]$ vi dumpblock.sh
#/bin/bash
#功能,批量dump block
echo "######请输入你要dump的文件号,块号!######"
echo "######文件号只能输入一个,块号如果有多个,用空格隔开######"
read -t 30 -p "input you file : " file
read -t 30 -p "input you block : " blk
rm -f /tmp/info.txt
if [ ! -z "$file" -a ! -z "$blk" ]
then
#变量叠加处理多个块用空格进来的情况,末尾加上换行符进行行转列;
blk=$blk|tr " " "\n"
#将传进来的块处理后输出到/tmp/inputblk;
echo $blk|tr " " "\n" &> /tmp/inputblk
#进入循环
for i in $(cat /tmp/inputblk)
do
#将每次循环的结果追加到/tmp/info.txt
sqlplus / as sysdba << eof &>>/tmp/info.txt
alter session set tracefile_identifier=$i;
oradebug setmypid
alter system dump datafile $file block $i;
oradebug tracefile_name;
eof
done
#循环完成后处理/tmp/info.txt
echo `cat /tmp/info.txt|grep "\.*trc"|tr "SQL>" "more"`
#删除过程中的文件
rm -f /tmp/info.txt /tmp/inputblk
else
echo "文件号或块号未输入,请重新输入!"
fi
[ora11g@ol7 ~]$ sh dumpblock.sh
######请输入你要dump的文件号,块号!######
######文件号只能输入一个,块号如果有多个,用空格隔开######
input you file : 1
input you block : 94696 94697 94698 94699 94700
more /u02/app/oracle/diag/rdbms/zlhis/zlhis/trace/zlhis_ora_7260_94696.trc
more /u02/app/oracle/diag/rdbms/zlhis/zlhis/trace/zlhis_ora_7262_94697.trc
more /u02/app/oracle/diag/rdbms/zlhis/zlhis/trace/zlhis_ora_7264_94698.trc
more /u02/app/oracle/diag/rdbms/zlhis/zlhis/trace/zlhis_ora_7266_94699.trc
more /u02/app/oracle/diag/rdbms/zlhis/zlhis/trace/zlhis_ora_7268_94700.trc
如果有什么问题可以v-x咨询:13330288582,也可以进qq group :660316651
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27147296/viewspace-2944685/ ,如需转载,请注明出处,否则将追究法律责任。