shell脚本

#!/bin/bash
#get archived log name and create reg_arc.sql
#ftp upload archived log to standby
#will create get_arc_name.tmp reg_name.sql reg_arc.sql three file

#get the latest sequence number from standby database
echo standby_arc.sh start time is `date` running......
values=`sqlplus -silent "sys/linyuyang@standby as sysdba"<< END
set pagesize 0 feedback off verify off heading off echo off
select max(sequence#) from v\\\$archived_log  where stamp=(select max(stamp) from v\\\$archived_log);
exit;
end`
length=`echo $values | awk '{printf("%d",length($1))}'`
echo sequence length is $length
if [ $length -gt 3 ]
then
echo ORA-02 unable to connect to standby oracle please check standby database isok
exit;
else
#get need register archivelog name and create reg_arc.sql script
sqlplus / as sysdba</dev/null
set pagesize 0 feedback off verify off heading off echo off
spool get_arc_name.tmp
select name from v\$archived_log where DEST_ID=1 AND completion_time>=sysdate-1 and sequence#>$values;
spool off

spool reg_name.sql
set pages 0
set feedback off
set linesize 83
select 'alter database register physical logfile '''||name||''';' from v\$archived_log where DEST_ID=1 AND completion_time>=sysdate-1 and sequence#>$values;
spool off
exit
EOF
#modify reg_name.sql to the propery sql script
sed '/SQL/d' reg_name.sql>reg_arc.sql

# ftp upload archivelog
ftp -i -n <open 192.168.1.148
user oracle oracle

cd /home/oracle/archive
bin
$(sed '/SQL/d' get_arc_name.tmp|sed 's/^/mput /')
mput reg_arc.sql
bye
EOF
fi
echo standby_arc.sh stop time is `date` end

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7301064/viewspace-442058/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7301064/viewspace-442058/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值