新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
DB2數(shù)據(jù)庫解死鎖之shell腳本經(jīng)典版!
以下的文章主要向大家描述的是在linux/unix下,DB2數(shù)據(jù)庫解死鎖之shell腳本,以下就是對在linux/unix下,DB2數(shù)據(jù)庫解死鎖之shell腳本的具體描述,希望在你今后的學(xué)習(xí)中會有所幫助。

創(chuàng)新互聯(lián)公司長期為近千家客戶提供的網(wǎng)站建設(shè)服務(wù),團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為龍安企業(yè)提供專業(yè)的成都網(wǎng)站設(shè)計、成都做網(wǎng)站,龍安網(wǎng)站改版等技術(shù)服務(wù)。擁有10余年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。
clear;
- DB2 "connect to db user dbuser using dbpass"
- DB2 "update monitor switches using lock on table on"
- tmpf=`echo "$HOME/tmp/""$RANDOM"_"$SECONDS"".lock"`
- DB2 get snapshot for locks on abbs>$tmpf
- handles=`cat $tmpf|awk '{if($2=="handle")print $4}'`
- x=0;
- y=0;
- deadhandles=" "
- for i in $handles
- do
取當(dāng)前id所在行
- ibeg=`cat $tmpf|awk '{if($2=="handle" && $4=="'$i'")print NR}'`;
- #echo "Line[15]:handle:$i,beg:$ibeg"
取當(dāng)前行以后的內(nèi)容
- cat $tmpf|awk '{if(NR-1>'$ibeg')printf("%s\n", $0);}'>$tmpf.$i;
取下一個handle所在行
- hangdleaf=`cat $tmpf.$i|awk '{if($2=="handle")print NR}'`
- #echo Line[20]:$hangdleaf
- if [ -z "$hangdleaf" ];then
- cat $tmpf.$i>$tmpf.$i.aft;
- else
取下一個handle
- itmp="";
- for j in $hangdleaf
- do
- if [ -z "$itmp" ];then
- handlenext=$j;
- itmp="get done!"
- fi
- done
- #echo Line[33]:$handlenext;
- #cat $tmpf.$i|awk '{if(NR<'$handlenext')print $0;}'
- cat $tmpf.$i|awk '{if(NR<'$handlenext')print $0;}'>$tmpf.$i.aft;
- fi
判斷本handle相關(guān)的鎖 是否存在排他鎖
- ifx=`cat $tmpf.$i.aft|awk '{if(($1=="Mode" && ($3=="X" || $3=="IX")) ||($2=="mode" && substr($6,2,1)=="X") )print $0;}'`
- #echo Line[39]:handle[$i],$ifx
- if [ -z "$ifx" ];then
- a=1
- else
- deadhandles="$deadhandles"" $i"
- x=`expr $x + 1`;
- echo $i
- fi
- #cat $tmpf.$i.aft|grep X|more
- #echo Line[48]:$deadhandles
- #read yn
- rm -f $tmpf.$i
- rm -f $tmpf.$i.aft
- done
- #echo "死鎖$x:$deadhandles";
- #read yn
- clear
- if [ -z "$deadhandles" ] || [ "$deadhandles" = " " ] ;then
- echo "沒有死鎖,退出......";
- read yn;
- exit 0;
- fi
- echo "鎖句柄:$deadhandles,解鎖? Y/N\c"
- read yn;
- if [ -z "$yn" ];then
- echo "放棄解鎖!"
- exit 0;
- fi
- if [ "$yn" = "Y" ] || [ "$yn" = "y" ];then
- x=0;
- for i in $deadhandles
- do
- echo 解死鎖:$i
- DB2 "force applications($i)"
- x=`expr $x + 1`
- done
- echo "解開[$x]個鎖...."
- else
- echo "放棄解鎖!"
- exit 0;
- fi
- DB2 connect reset;
- DB2 terminate;
- rm -f $tmpf
- echo "解鎖終端:">/tmp/tty.tmp
- tty>>/tmp/tty.tmp
- wall
- rm -f /tmp/tty.tmp
以上的相關(guān)內(nèi)容就是對linux/unix下DB2數(shù)據(jù)庫解死鎖的shell腳本的介紹,望你能有所收獲。
【編輯推薦】
- DB2 CMO安裝7.1.2.6補丁之后會出現(xiàn)的錯誤
- IBM DB2數(shù)據(jù)庫新手必看的基礎(chǔ)知識有哪些?
- 如何正確管理DB2 For z/OS or OS/390的操作性能
- 安裝DB2 Content Manager8.3出現(xiàn)144錯誤代碼
- 安裝IBM DB2 Content Manager V83時與122錯誤代碼
分享名稱:DB2數(shù)據(jù)庫解死鎖之shell腳本經(jīng)典版!
文章分享:http://www.5511xx.com/article/ccsecpo.html


咨詢
建站咨詢
