温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

OGG运维优化脚本(八)- 查询维护类--批量查询

发布时间:2020-06-23 00:23:50 来源:网络 阅读:770 作者:netsman1030 栏目:关系型数据库

文件名:search.sh

路径:$HOME/ggscript/ggsearch

功能:该脚本用于满足检查goldengate进程具体配置情况的需求而设计

通过edit脚本选择调用

#!/bin/bash
echo "This script is used to search the specified table!(created by renyi)"

echo $dir
dir=$PWD 
cd $HOME/ggserver

#确定搜索对象类型
echo "Please select the search type"
echo 

select ch in "ALLFILE" "EXTRACT" "REPLICAT" "PUMP"
do
case $ch in
"ALLFILE")
ls -lrt $HOME/ggserver/dirprm/*.prm

#获取进程清单
cd $HOME/ggserver
(echo info all;echo exit)|./ggsci
cd $dir
val=1

    break;
;;
#针对对应类型 进行搜索操作
#输入需搜索的进程文件名
"EXTRACT")
ls -lrt $HOME/ggserver/dirprm/e*.prm
cd $HOME/ggserver
(echo info all;echo exit)|./ggsci
cd $dir



read -p "Please enter the prm file name:"  val
break;
;;


"REPLICAT")
ls -lrt $HOME/ggserver/dirprm/r*.prm
cd $HOME/ggserver
(echo info all;echo exit)|./ggsci
cd $dir
read -p "Please enter the prm file name:"  val
    break;
;;

"PUMP")
ls -lrt $HOME/ggserver/dirprm/p*.prm
cd $HOME/ggserver
(echo info all;echo exit)|./ggsci
cd $dir
read -p "Please enter the prm file name:"  val
 break;
;;
   
*)
 echo "Please select your choice : 1.ALLFILE  2.EXTRACT   3.REPLICAT  4.PUMP"
 ;;
esac
done;


echo "Please Enter the table you want to search!"
read -n 1
vi SearchTemp





i=1
num=`sed -n '$=' SearchTemp`

if [ "$val" == 1 ]
 then
	while [ "$i" -le "$num" ]
	do
		TAL=`sed -n $i'p' SearchTemp`
		grep -ni $TAL $HOME/ggserver/dirprm/* 1>> exist || echo $TAL >> notexist
		 ((i++));
	done
else 
	while [ "$i" -le "$num" ]
	do
		TAL=`sed -n $i'p' SearchTemp`
		grep -ni $TAL $HOME/ggserver/dirprm/$val 1>> exist || echo $TAL >> notexist
		 ((i++));
	done
fi

#输出搜索结果
echo "---------------------------------------"
echo "The search result is"
cat exist
echo "---------------------------------------"
echo "The not exist table is"
cat notexist
echo "---------------------------------------"

cat SearchTemp | sort -n > SearchTempu 
cat notexist | sort -n > notexistu 
comm -23  SearchTempu  notexistu  > existable
cat /dev/null > exist
cat /dev/null > SearchTemp 
cat /dev/null > notexist 
echo "The  exist table is"
cat existable
exit


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI