Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

OGG Operation and maintenance Optimization script (2)-Information Modification Class-batch Table addition

2025-01-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Now let's introduce the script. All scripts must be annotated in the prm configuration file before they can be used successfully.

For details, please refer to script deployment preparation.

In the actual operation and maintenance process, our OGG programs are all deployed under the $home/ggserver path.

Add tables in batch

File name: insert.sh

The path to the script: $HOME/ggscript/gginsert

Function: to meet the requirements of increasing synchronous tables in large quantities which are often put forward by applications

Used for batch table addition, including repeated configuration table filtering and automatic addition of additional logs

The script is selected to call through the edit script

This script is currently only valid for EXTRACT and sending processes

Log path: $HOME/gglog/gginsert

#! / bin/bashbackuptime= `date +% Y% m% dHOME/ggserver/dirprm/e*.prm% H% M`datenow = `date +% Y% m% d% H`date $HOME/ggscript/gginsertecho $backuptimeecho "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# enter the filename corresponding to the process to be operated (end of prm) read -p "Please enter the prm file name:" valecho "- insert file name-" > >''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log'echo $val > >''$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log'# input requires batch increment of the corresponding area of the table cat $HOME/ggserver/dirprm/$val | grep Beginread-p "Please enter the Area name:" areaecho "- insert area -"> >'$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log'echo $area > >'$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log'# pastes the table name to be added in the vi interface (no TABLE prefix) No semicolon ending, do not insert spaces) echo "Please Enter the table you want to add (Please enter any key)-Do not include spaces!" read-n 1vi AddTempecho "- 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 Repeat table comparison: filter cat $HOME/ggserver/dirprm/$val | awk'/--'$area'-Begin/,/--'$area'-End/ {if (I > 1) print x = 'tempawk-F' -'($1) {print $1} 'temp > temp2rm-rf tempsed-e' / ^ $/ d 'temp2 > temp3rm-rf temp2awk-F','{print $1} 'temp3 > temp4rm-rf temp3awk-F' '{print $1}' temp4 > temp5rm-rf temp4echo "Confirm the tables that have increased" cat temp5 | awk-F 'TABLE' {print $2}'> AddedTemprm-rf temp5sed'/ ^ $/ d 'AddedTemp > AddedTemp2sed' / ^ $/ d 'AddTemp > AddTemp2cat AddTemp2 | sort-n > AddTablecat AddedTemp2 | sort-n > AddedTablerm-f AddTempcomm-12 AddTable AddedTable > Duplicatenum= `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 > NeedToAddnum= `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# table insert operation echo" Do you want to insert the table into'$val'? "read-p" Please enter y or N: "conif [" $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 Compact accounts / / '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 > table3rm-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# additional log add operation echo "Do you Want to addtrandata? "read-p" Please enter y or n: "conbif [" $conb "= =" y "] then sed's / ^ / addtrandata / '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 = `e xpr $I + 1` Done echo OBEY dirdat/addtrandata |. / ggsci else echo "process complete" echo "process complete" > >'$HOME'/ggscript/gginsert/log/InsertLog-'$backuptime'.log' exit 2fi

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 300

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report