千家信息网

OGG运维优化脚本(四)-信息修改类--长事务跳过

发表于:2025-01-22 作者:千家信息网编辑
千家信息网最后更新 2025年01月22日,文件名: skiptrans.sh skip.sh所在路径:$HOME/ggscript/ggtrandata功能:该脚本用于重启抽取进程时跳过长事务,可自动识别1小时以上的长事务并批量跳过,skip
千家信息网最后更新 2025年01月22日OGG运维优化脚本(四)-信息修改类--长事务跳过

文件名: skiptrans.sh skip.sh

所在路径:$HOME/ggscript/ggtrandata

功能:该脚本用于重启抽取进程时跳过长事务,可自动识别1小时以上的长事务并批量跳过,skiptrans.sh通过edit脚本选择调用,skip.sh用于在其他脚本中调用用,例如allstop.shgoldengate进程停止脚本

Ps:目前该脚本目前仅适用于AIXLINUX系统

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/ggtrandataecho $loginecho $dirdir=$PWD echo $dircd $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/thread1echo "Thread 1 data load compete"(echo send $extract showtrans thread 2;echo exit)|./ggsci > $dir/thread2echo "Thread 2 data load compete"cd $dir#将长事务信息分割为时间与trans编号两部分cat thread1|awk 'BEGIN{}{FS=" "} /^XID:/{print $2}'|sed  -e '/^$/d' > xid1cat thread1|awk -F 'Time:           ' '{print $2}'|sed  -e '/^$/d' > time1paste time1 xid1 > trandatacat thread2|awk 'BEGIN{}{FS=" "} /^XID:/{print $2}'|sed  -e '/^$/d' > xid2cat thread2|awk -F 'Time:           ' '{print $2}'|sed  -e '/^$/d' > time2paste time2 xid2 > trandata2cat trandata2 >> trandata#通过函数转换时间,并排除掉一小时以内的长事务sydate=`date +"%Y-%m-%d:%H:%M:%S"`echo $HSYSTIMEdate2seconds `echo $sydate | sed 's/-/ /g;s/:/ /g'` > secondssysHSYSTIME=`cat secondssys`echo $HSYSTIMErm -f secondssys#date2seconds `echo $sydate | sed 's/-/ /g;s/:/ /g'`NUX=`sed -n '$=' trandata`i=1cat /dev/null > trainswhile(($i<=$NUX));  dostr=`sed -n "${i}p"  trandata |awk '{print $1}'`echo $strdate2seconds `echo $str | sed 's/-/ /g;s/:/ /g'` > secondssysHGTI=`cat secondssys`rm -f secondssysecho $HGTIecho $HSYSTIMEPOOR=`expr $HSYSTIME - 3600`echo $POORecho "--------------------"if [ "$HGTI" -le "$POOR" ]        then                sed -n "${i}p"  trandata |awk '{print $2}' >> trainsfii=`expr $i + 1`done#将一小时以前的长事务组合成skiptrans指令,并通过obey指令批量执行sed 's/^/send '$extract' skiptrans /' trains > trains1sed 's/$/ force/' trains1 > skiptrains cd $HOME/ggservercat $HOME/ggscript/ggtrandata/skiptrains > dirdat/skiptrainsecho   OBEY dirdat/skiptrains |./ggsci


skip.sh

#!/bin/bashecho $dircd $HOME/ggscript/ggtrandatadir=$PWDcd $HOMEif [ -f .profile ];then        . .profilefiif [ -f .bash_profile ];then         . .bash_profileficd $dirfunction 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 2fiextract=$1if [ `echo $extract|grep ^E` ];then         IType=EXTRACTelif [ `echo $extract|grep ^P` ];then        echo "only can operate the EXTRACT  process"        exit 2elif  [ `echo $extract|grep ^R` ];then        echo "only can operate the extract process"        exit 2else        echo "only can operate the EXTRACT  process"        exit 2fival=`echo $extract.PRM|tr A-Z a-z`cd $HOME/ggserver/dirprmif [ ! -e $val ]; then        echo "the EXTRACT is not exist"        exit 2ficd $direcho $loginecho $dircd $HOME/ggserverecho "loading the trans data.....please wait....."(echo send $extract showtrans thread 1;echo exit)|./ggsci > $dir/thread1echo "Thread 1 data load compete"(echo send $extract showtrans thread 2;echo exit)|./ggsci > $dir/thread2echo "Thread 2 data load compete"cd $dircat thread1|awk 'BEGIN{}{FS=" "} /^XID:/{print $2}'|sed  -e '/^$/d' > xid1cat thread1|awk -F 'Time:           ' '{print $2}'|sed  -e '/^$/d' > time1paste time1 xid1 > trandatacat thread2|awk 'BEGIN{}{FS=" "} /^XID:/{print $2}'|sed  -e '/^$/d' > xid2cat thread2|awk -F 'Time:           ' '{print $2}'|sed  -e '/^$/d' > time2paste time2 xid2 > trandata2cat trandata2 >> trandatasydate=`date +"%Y-%m-%d:%H:%M:%S"`echo $HSYSTIMEdate2seconds `echo $sydate | sed 's/-/ /g;s/:/ /g'` > secondssysHSYSTIME=`cat secondssys`echo $HSYSTIMErm -f secondssys#date2seconds `echo $sydate | sed 's/-/ /g;s/:/ /g'`NUX=`sed -n '$=' trandata`i=1cat /dev/null > trainswhile(($i<=$NUX));  dostr=`sed -n "${i}p"  trandata |awk '{print $1}'`echo $strdate2seconds `echo $str | sed 's/-/ /g;s/:/ /g'` > secondssysHGTI=`cat secondssys`rm -f secondssysecho $HGTIecho $HSYSTIMEPOOR=`expr $HSYSTIME - 3600`echo $POORecho "--------------------"if [ "$HGTI" -le "$POOR" ]        then                sed -n "${i}p"  trandata |awk '{print $2}' >> trainsfii=`expr $i + 1`donesed 's/^/send '$extract' skiptrans /' trains > trains1sed 's/$/ force/' trains1 > skiptrains cd $HOME/ggservercat $HOME/ggscript/ggtrandata/skiptrains > dirdat/skiptrainsecho   OBEY dirdat/skiptrains |./ggsci


0