您好,登錄后才能下訂單哦!
文件名: skiptrans.sh skip.sh
所在路徑:$HOME/ggscript/ggtrandata
功能:該腳本用于重啟抽取進程時跳過長事務,可自動識別1小時以上的長事務并批量跳過,skiptrans.sh通過edit腳本選擇調用,skip.sh用于在其他腳本中調用用,例如allstop.sh全goldengate進程停止腳本
Ps:目前該腳本目前僅適用于AIX和LINUX系統
skiptrans.sh
#!/bin/bash #時間轉換為秒的函數,參考某位大神的腳本 function date2seconds { echo "$*" | awk '{ z=int((14-$2)/12); y=$1+4800-z; m=$2+12*z-3; j=int((153*m+2)/5)+$3+y*365+int(y/4)-int(y/100)+int(y/400)-2472633; j=j*86400+$4*3600+$5*60+$6 print j }' } cd $HOME/ggscript/ggtrandata echo $login echo $dir dir=$PWD echo $dir cd $HOME/ggserver #輸入需要跳過長事務的進程名 echo "searching the Extract name......" (echo info all;echo exit)|./ggsci|grep "EXTRACT" |awk 'BEGIN {FS=" +"} {print $3}'|grep '^E' read -p "Please enter the extract name:" extract #獲取2個線程的showtrans長事務 echo "loading the trans data.....please wait....." (echo send $extract showtrans thread 1;echo exit)|./ggsci > $dir/thread1 echo "Thread 1 data load compete" (echo send $extract showtrans thread 2;echo exit)|./ggsci > $dir/thread2 echo "Thread 2 data load compete" cd $dir #將長事務信息分割為時間與trans編號兩部分 cat thread1|awk 'BEGIN{}{FS=" "} /^XID:/{print $2}'|sed -e '/^$/d' > xid1 cat thread1|awk -F 'Time: ' '{print $2}'|sed -e '/^$/d' > time1 paste time1 xid1 > trandata cat thread2|awk 'BEGIN{}{FS=" "} /^XID:/{print $2}'|sed -e '/^$/d' > xid2 cat thread2|awk -F 'Time: ' '{print $2}'|sed -e '/^$/d' > time2 paste time2 xid2 > trandata2 cat trandata2 >> trandata #通過函數轉換時間,并排除掉一小時以內的長事務 sydate=`date +"%Y-%m-%d:%H:%M:%S"` echo $HSYSTIME date2seconds `echo $sydate | sed 's/-/ /g;s/:/ /g'` > secondssys HSYSTIME=`cat secondssys` echo $HSYSTIME rm -f secondssys #date2seconds `echo $sydate | sed 's/-/ /g;s/:/ /g'` NUX=`sed -n '$=' trandata` i=1 cat /dev/null > trains while(($i<=$NUX)); do str=`sed -n "${i}p" trandata |awk '{print $1}'` echo $str date2seconds `echo $str | sed 's/-/ /g;s/:/ /g'` > secondssys HGTI=`cat secondssys` rm -f secondssys echo $HGTI echo $HSYSTIME POOR=`expr $HSYSTIME - 3600` echo $POOR echo "--------------------" if [ "$HGTI" -le "$POOR" ] then sed -n "${i}p" trandata |awk '{print $2}' >> trains fi i=`expr $i + 1` done #將一小時以前的長事務組合成skiptrans指令,并通過obey指令批量執行 sed 's/^/send '$extract' skiptrans /' trains > trains1 sed 's/$/ force/' trains1 > skiptrains cd $HOME/ggserver cat $HOME/ggscript/ggtrandata/skiptrains > dirdat/skiptrains echo OBEY dirdat/skiptrains |./ggsci
skip.sh
#!/bin/bash echo $dir cd $HOME/ggscript/ggtrandata dir=$PWD cd $HOME if [ -f .profile ];then . .profile fi if [ -f .bash_profile ];then . .bash_profile fi cd $dir function date2seconds { echo "$*" | awk '{ z=int((14-$2)/12); y=$1+4800-z; m=$2+12*z-3; j=int((153*m+2)/5)+$3+y*365+int(y/4)-int(y/100)+int(y/400)-2472633; j=j*86400+$4*3600+$5*60+$6 print j }' } if [ $# -eq 0 ]; then echo "skip EXTRACT" exit 2 fi extract=$1 if [ `echo $extract|grep ^E` ];then IType=EXTRACT elif [ `echo $extract|grep ^P` ];then echo "only can operate the EXTRACT process" exit 2 elif [ `echo $extract|grep ^R` ];then echo "only can operate the extract process" exit 2 else echo "only can operate the EXTRACT process" exit 2 fi val=`echo $extract.PRM|tr A-Z a-z` cd $HOME/ggserver/dirprm if [ ! -e $val ]; then echo "the EXTRACT is not exist" exit 2 fi cd $dir echo $login echo $dir cd $HOME/ggserver echo "loading the trans data.....please wait....." (echo send $extract showtrans thread 1;echo exit)|./ggsci > $dir/thread1 echo "Thread 1 data load compete" (echo send $extract showtrans thread 2;echo exit)|./ggsci > $dir/thread2 echo "Thread 2 data load compete" cd $dir cat thread1|awk 'BEGIN{}{FS=" "} /^XID:/{print $2}'|sed -e '/^$/d' > xid1 cat thread1|awk -F 'Time: ' '{print $2}'|sed -e '/^$/d' > time1 paste time1 xid1 > trandata cat thread2|awk 'BEGIN{}{FS=" "} /^XID:/{print $2}'|sed -e '/^$/d' > xid2 cat thread2|awk -F 'Time: ' '{print $2}'|sed -e '/^$/d' > time2 paste time2 xid2 > trandata2 cat trandata2 >> trandata sydate=`date +"%Y-%m-%d:%H:%M:%S"` echo $HSYSTIME date2seconds `echo $sydate | sed 's/-/ /g;s/:/ /g'` > secondssys HSYSTIME=`cat secondssys` echo $HSYSTIME rm -f secondssys #date2seconds `echo $sydate | sed 's/-/ /g;s/:/ /g'` NUX=`sed -n '$=' trandata` i=1 cat /dev/null > trains while(($i<=$NUX)); do str=`sed -n "${i}p" trandata |awk '{print $1}'` echo $str date2seconds `echo $str | sed 's/-/ /g;s/:/ /g'` > secondssys HGTI=`cat secondssys` rm -f secondssys echo $HGTI echo $HSYSTIME POOR=`expr $HSYSTIME - 3600` echo $POOR echo "--------------------" if [ "$HGTI" -le "$POOR" ] then sed -n "${i}p" trandata |awk '{print $2}' >> trains fi i=`expr $i + 1` done sed 's/^/send '$extract' skiptrans /' trains > trains1 sed 's/$/ force/' trains1 > skiptrains cd $HOME/ggserver cat $HOME/ggscript/ggtrandata/skiptrains > dirdat/skiptrains echo OBEY dirdat/skiptrains |./ggsci
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。