1. 程式人生 > >OGG運維優化腳本(九)-查詢維護類--進程重復表檢查

OGG運維優化腳本(九)-查詢維護類--進程重復表檢查

ogg oracle goldengate 腳本 數據同步 shell

路徑:$HOME/ggscript/ggrepeat

功能:該腳本為處理目標端因為源端重復配置源端表,導致目標端數據重復的問題而設計。可以針對進程檢查重復配置的表名,並羅列具體信息和所在文件行數

可以配合note快速註釋腳本進行源端重復表清理操作

#!/bin/bash
echo "+--------------------------------------------------------+"
echo "|This script will search for the repeat table ( by RenYi)|"
echo "+--------------------------------------------------------+"
if [ $# -eq 0 ]; then
        echo "REPEAT EXTRACT"
        exit 2
fi

backuptime=`date +%Y%m%d-%H%M`
datenow=`date +%Y%m%d%H`

val=$1
val=`echo $val|tr a-z A-Z`
echo "-------------------------"
echo "The process name is $val"
echo "-------------------------"
val=`echo $val.PRM|tr A-Z a-z`
cd $HOME/ggserver/dirprm
if [ ! -e $val ]; then
        echo "the EXTRACT is not exist"
        exit 2
fi

cd $HOME/ggscript/ggrepeat
cat $HOME/ggserver/dirprm/$val|awk ‘/TABLE#/,/#TABLE/{if(i>1)print x;x=$0;i++}‘ > temp
awk -F ‘--‘  ‘($1) { print $1}‘ temp > temp2
rm -rf temp
sed  -e ‘/^$/d‘  temp2 > temp3
rm -rf temp2
awk -F ‘,‘ ‘{print $1}‘ temp3 >temp4
rm -rf temp3
awk -F ‘;‘ ‘{print $1}‘ temp4 >temp5
rm -rf temp4
cat temp5|awk  -F ‘TABLE ‘  ‘{print $2}‘ > Temp
rm -rf temp5

sort Temp |uniq -d > $HOME/ggscript/ggrepeat/tmp
echo "-------------------------"
echo "The repeat table:"
echo "-------------------------"

cat tmp

i=1

num=`sed -n ‘$=‘ tmp`

echo "num = $num"
echo "-------------------------"
echo "The Detailed results:"
echo "-------------------------"
while [ ! -n "$num" ]
do
	echo "no result"
	exit 2
done

while [ "$i" -le "$num" ]
do
        TAL=`sed -n $i‘p‘ tmp`
        echo $TAL
	grep -ni $TAL $HOME/ggserver/dirprm/$val
	((i++));
done
echo "-------------------------"


本文出自 “netsman” 博客,請務必保留此出處http://netsman.blog.51cto.com/5750076/1939639

OGG運維優化腳本(九)-查詢維護類--進程重復表檢查