OGG单表初始化交互式脚本

该脚本早期匆忙编写,当时脚本能力也有限,方法比较笨,redhat下可以运行,unix下可能scn有问题,一直没时间调整
给ogg运维总有表同步引发abend的兄弟参考一下,共同苦逼吧
#传参
clear
echo 'Please first stop replicat process and press RETURN to continue'
read continue
clear
echo 'Please input goldengate user name :'
read username
clear
echo 'Please input goldengate password :'
read password
clear
echo 'Please input exp directory :'
read dir
clear
echo 'Please input exp file name :'
read file
clear
echo 'Please input tables name(hr.employees,hr.departments) :'
read tables
clear
echo 'Please input compress(n/y) :'
read compress
clear
echo 'Please input grants(n/y) :'
read grants
clear
echo 'Please input replicat host IP :'
read host
clear
echo 'Please input replicat operator system user :'
read user
clear
echo 'Please input replicat operator system password :'
read passwd
clear
echo 'Please input replicat host directory :'
read rdir
clear

#传参确认
echo 'check your setup :'
echo ' '
echo 'goldengate user name/password : '$username'/'$password
echo ' '
echo 'exp file : '$dir'/'$file'.dmp'
echo ' '
echo 'exp parameter compress : '$compress
echo ' '
echo 'exp parameter grants : '$grants
echo ' '
echo 'replicat host IP : '$host
echo ' '
echo 'replicat operator system user : '$user
echo ' '
echo 'replicat operator system password : '$passwd
echo ' '
echo 'replicat host directory : '$rdir
echo ' '
echo 'exp tables :'
echo ' '
echo $tables
echo ' '
echo 'Are you ready start this job? if "ok" press RETURN to continue ! if have error press "ctrl + C" :'
read continue


#导出表
cd $dir
sqlplus / as sysdba <
set pagesize 500
set linesize 150
col exp for a150
col scn new_val scn
col exp new_val exp
col filter new_val filter
alter system checkpoint;
select checkpoint_change# scn from v\$database;
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;

#复制端脚本提示部分
col tmp new_val tmp
select 'echo ''clear'' >$dir/ogg_tables.sh' as "tmp" from dual;
!&tmp
col tmp new_val tmp
select 'echo ''echo ''\''''modify replicat process $rep add : " ,filter ( @GETENV ("TRANSACTION", "CSN") >&scn); "''\'' >>$dir/ogg_tables.sh' as "tmp" from dual;
!&tmp
col tmp new_val tmp
select 'echo ''echo ''\''Press ENTURN to continue\'''''' >>$dir/ogg_tables.sh' as "tmp" from dual;
!&tmp
col tmp new_val tmp
select 'echo ''read continue'' >>$dir/ogg_tables.sh' as "tmp" from dual;
!&tmp
!&exp
quit
EOF

#生成复制端脚本
#复制端脚本删除需要IMP的表
cd $dir
echo 'drop table '$tables' purge;' >drop_tables.txt
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/,如需转载,请注明出处,否则将追究法律责任。

上一篇: clob的null值查询引发600错误
下一篇: 没有了~
user_pic_default.png
请登录后发表评论 登录
全部评论
<%=items[i].createtime%>

<%=items[i].content%>

<%if(items[i].items.items.length) { %>
<%for(var j=0;j
<%=items[i].items.items[j].createtime%> 回复

<%=items[i].items.items[j].username%>   回复   <%=items[i].items.items[j].tousername%>: <%=items[i].items.items[j].content%>

<%}%> <%if(items[i].items.total > 5) { %>
还有<%=items[i].items.total-5%>条评论 ) data-count=1 data-flag=true>点击查看
<%}%>
<%}%>
<%}%>
nisumost

注册时间:2013-04-27

  • 博文量
    11
  • 访问量
    53221

最新文章

  • clob的null值查询引发600错误
  • 10g 文件系统转ASM方法
  • ORA-27125问题的解决
  • 数据不断变化的脚本
  • ora-12545连接时好时坏的解决
  • public vip 网络的变更 (10g rac)
  • 控制文件自动备份在数据库恢复时带来的小问题
  • 无归档导致数据库无法打开
  • [rac][crs]无法启动_vote与ocr权限变动
  • oracle手工建库_10g

转载于:http://blog.itpub.net/7986761/viewspace-1731179/

你可能感兴趣的:(数据库,运维)