select 'nohup exp userid=$username/$password file=$dir/$file.dmp log=$dir/$file.log tables=$tables grants=$grants statistics=none triggers=n compress=$compress flashback_scn=&scn &' as "exp" from dual;
select 'echo ''echo ''\''''modify replicat process $rep add : " ,filter ( @GETENV ("TRANSACTION", "CSN") >&scn); "''\'' >>$dir/ogg_tables.sh' as "tmp" from dual;
select 'echo ''echo ''\''Press ENTURN to continue\'''''' >>$dir/ogg_tables.sh' as "tmp" from dual;
select 'echo ''read continue'' >>$dir/ogg_tables.sh' as "tmp" from dual;
vi drop_tables.txt<
:%s/,/ purge;,drop table /g
:wq
EOF
cat drop_tables.txt|tr ',' '\n' >drop_tables.sh
#复制端脚本传参
echo 'clear' >>ogg_tables.sh
echo 'echo '\'Please input goldengate user name:\''' >>ogg_tables.sh
echo 'read username' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\'Please input goldengate user password:\''' >>ogg_tables.sh
echo 'read password' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\'Please input fromuser:\''' >>ogg_tables.sh
echo 'read fromuser' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\'Please input touser:\''' >>ogg_tables.sh
echo 'read touser' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\'Please input replicat process name :\''' >>ogg_tables.sh
echo 'read rep' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\'Please input goldengate software directory :\''' >>ogg_tables.sh
echo 'read oggdir' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'cd '$rdir >>ogg_tables.sh
#复制端脚本传参确认
echo 'clear' >>ogg_tables.sh
echo 'echo '\''check your setup :'\'
echo 'echo '\''goldengate user name/password : '\''$username'\''/'\''$password' >>ogg_tables.sh
echo 'echo '\'' '\' >>ogg_tables.sh
echo 'echo '\''imp parameter fromuser : '\''$fromuser' >>ogg_tables.sh
echo 'echo '\'' '\' >>ogg_tables.sh
echo 'echo '\''imp parameter touser : '\''$touser' >>ogg_tables.sh
echo 'echo '\'' '\' >>ogg_tables.sh
echo 'echo '\''replicat process name : '\''$rep' >>ogg_tables.sh
echo 'echo '\'' '\' >>ogg_tables.sh
echo 'echo '\''goldengate sowftware directory : '\''$oggdir' >>ogg_tables.sh
echo 'echo '\'' '\' >>ogg_tables.sh
echo 'echo '\''Are you ready start this job? if "ok" press RETURN to continue ! if have error press "ctrl + C" :'\' >>ogg_tables.sh
echo 'read continue' >>ogg_tables.sh
#复制端脚本IMP要同步的表
echo 'sqlplus / as sysdba <>ogg_tables.sh
cat drop_tables.sh >>ogg_tables.sh
echo 'quit' >>ogg_tables.sh
echo 'EOF' >>ogg_tables.sh
echo 'nohup imp userid=$username/$password file='$rdir'/'$file'.dmp log='$rdir'/'$file'.log fromuser=$fromuser touser=$touser &' >>ogg_tables.sh
echo 'echo '\'' '\' >>ogg_tables.sh
echo 'echo '\'' '\' >>ogg_tables.sh
echo 'echo '\'' '\' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''The job is OK press RETURN to start replicat process "'\''$rep'\''"'\' >>ogg_tables.sh
echo 'read continue' >>ogg_tables.sh
echo 'cd $oggdir' >>ogg_tables.sh
echo './ggsci << EOF' >>ogg_tables.sh
echo 'start $rep' >>ogg_tables.sh
echo 'quit' >>ogg_tables.sh
echo 'EOF' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''please wait 10 second'\' >>ogg_tables.sh
echo 'sleep 1' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''please wait 9 second'\' >>ogg_tables.sh
echo 'sleep 1' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''please wait 8 second'\' >>ogg_tables.sh
echo 'sleep 1' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''please wait 7 second'\' >>ogg_tables.sh
echo 'sleep 1' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''please wait 6 second'\' >>ogg_tables.sh
echo 'sleep 1' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''please wait 5 second'\' >>ogg_tables.sh
echo 'sleep 1' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''please wait 4 second'\' >>ogg_tables.sh
echo 'sleep 1' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''please wait 3 second'\' >>ogg_tables.sh
echo 'sleep 1' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''please wait 2 second'\' >>ogg_tables.sh
echo 'sleep 1' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''please wait 1 second'\' >>ogg_tables.sh
echo 'sleep 1' >>ogg_tables.sh
echo 'clear' >>ogg_tables.sh
echo 'echo '\''This the $rep current status'\' >>ogg_tables.sh
echo './ggsci << EOF >ogg.out' >>ogg_tables.sh
echo 'info $rep' >>ogg_tables.sh
echo 'quit' >>ogg_tables.sh
echo 'EOF' >>ogg_tables.sh
echo 'echo '\''Press RETURN to EXIT'\' >>ogg_tables.sh
echo 'read continue' >>ogg_tables.sh
#FTP传送文件
cd $dir
chmod 755 ogg_tables.sh
ftp -n $host <
user $user $passwd
prompt
bin
cd $rdir
put $file.dmp
put ogg_tables.sh
chmod 555 ogg_tables.sh
chmod 666 $file.dmp
bye
EOF
#清理环境
rm -rf $dir/ogg_tables.sh
rm -rf $dir/$file.dmp
rm -rf $dir/dorp_tables.txt
rm -rf $dir/dorp_tables.sh
#确认源端的操作
clear
echo 'source node job is "OK" '
echo ' '
echo 'execute the script :"'$rdir'/ogg_tables.sh" at "'$host'" on "oracle" user'
echo ' '
echo 'Confirm tables'
echo ' '
echo $tables
echo ' '
echo 'press RETURN to EXIT'
read contiune
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7986761/viewspace-1731179/,如需转载,请注明出处,否则将追究法律责任。