大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
现在开始介绍脚本,所有的脚本必须在prm配置文件添加注释后才能成功使用
武冈网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站设计等网站项目制作,到程序开发,运营维护。创新互联于2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。详细请参考 脚本部署准备
实际的运维过程中,我们的OGG程序都统一部署在$home/ggserver路径下,
批量加表
文件名: insert.sh
脚本所在路径:$HOME/ggscript/gginsert
功能:为满足应用时常提出的大批量增加同步表需求
用于批量加表,包括重复配置表过滤功能以及附加日志自动增加功能
该脚本通过edit脚本选择调用
该脚本目前只能对EXTRACT和发送进程生效
日志路径: $HOME/gglog/gginsert
#!/bin/bash backuptime=`date +%Y%m%d-%H%M` datenow=`date +%Y%m%d%H` cd $HOME/ggscript/gginsert echo $backuptime echo "This script will search for the table that has been added and insert new table( by RenYi)" echo $backuptime > ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' ls -lrt $HOME/ggserver/dirprm/e*.prm $HOME/ggserver/dirprm/p*.prm $val #输入需操作的进程对应文件名(prm结尾) read -p "Please enter the prm file name:" val echo "--------insert file name------" >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' echo $val >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' #输入需要批量增加表对应的区域 cat $HOME/ggserver/dirprm/$val|grep Begin read -p "Please enter the Area name:" area echo "--------insert area------" >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' echo $area >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' #在vi界面内粘贴需要增加的表名(无TABLE前缀,无分号结尾,请勿插入空格) echo "Please Enter the table you want to add(Please enter any key)-Do not include spaces!" read -n 1 vi AddTemp echo "-----insert table------" >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' cat AddTemp >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' #echo $val #echo "awk '/--$area-Begin/,/--$area-End/{if(i>1)print x;x=$1;i++}' $HOME/ggserver/dirprm/$val" #重复表比对过滤 cat $HOME/ggserver/dirprm/$val|awk '/--'$area'-Begin/,/--'$area'-End/{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 echo "Confirm the tables that have increased" cat temp5|awk -F 'TABLE ' '{print $2}' > AddedTemp rm -rf temp5 sed '/^$/d' AddedTemp > AddedTemp2 sed '/^$/d' AddTemp > AddTemp2 cat AddTemp2 |sort -n > AddTable cat AddedTemp2 |sort -n > AddedTable rm -f AddTemp comm -12 AddTable AddedTable > Duplicate num=`sed -n '$=' Duplicate` echo "Check out the already added table in file "Duplicate",there were '$num' tables has being added" echo "---------The already added table---------" >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' cat Duplicate >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' comm -23 AddTable AddedTable > NeedToAdd num=`sed -n '$=' NeedToAdd` echo "Check out the Not yet add table in file "NeedToAdd",,there are '$num' tables not add" echo "---------The not yet added table---------" >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' cat NeedToAdd >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' #rm -rf AddedTable #rm -rf AddTable #表插入操作 echo "Do you want to insert the table into '$val'?" read -p "Please enter y or n:" con if [ "$con" == "y" ] then echo "backup the '$val' to the '$HOME/ggserver/dirprm/bak/$val.$backuptime.bak'" echo "backup the '$val' to the '$HOME/ggserver/dirprm/bak/$val.$backuptime.bak'" >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' cp $HOME/ggserver/dirprm/$val $HOME/ggserver/dirprm/bak/$val.$backuptime.bak echo "backup complete" echo "backup complete" >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' echo "modifying table " sed 's/^/TABLE /' NeedToAdd > table1 sed 's/$/;/' table1 > table2 num=`sed -n '$=' table2` rm -f table1 read -p "Please enter your name:" name echo "-----The Operator is '$name'--------" >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' echo "inserting '$num' tables into '$val' " echo "inserting '$num' tables into '$val' " >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' sed '1 i\ --'$datenow'-'$name'-add ' table2 > table3 rm -f table2 mv table3 table2 echo "inserting table" sed '/'$area'-Insert/r table2 ' $HOME/ggserver/dirprm/$val > $HOME/ggserver/dirprm/tem3 rm -f $HOME/ggserver/dirprm/$val mv $HOME/ggserver/dirprm/tem3 $HOME/ggserver/dirprm/$val echo "insert complete" echo "---------insert complete"--------- >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' else echo "process complete" echo "process complete" >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' fi #附加日志增加操作 echo "Do you want to addtrandata?" read -p "Please enter y or n:" conb if [ "$conb" == "y" ] then sed 's/^/add trandata /' NeedToAdd > addtrandata NUX=`sed -n '$=' addtrandata` # echo $NUX i=1 #echo $i cd $HOME/ggserver echo dblogin `more $HOME/ggserver/dirprm/$val|grep USERID` > dirdat/addtrandata #echo $login while [ "$i" -le "$NUX" ] do sed -n "${i}p" $HOME/ggscript/gginsert/addtrandata >> dirdat/addtrandata i=`expr $i + 1` done echo OBEY dirdat/addtrandata |./ggsci else echo "process complete" echo "process complete" >> ''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' exit 2 fi另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。