ITPub博客

首页 > Linux操作系统 > Linux操作系统 > shell脚本

shell脚本

原创 Linux操作系统 作者:sswgej 时间:2008-09-05 17:08:24 0 删除 编辑

#!/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博客 ” ,链接:https://blog.itpub.net/7301064/viewspace-442058/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: Histograms
请登录后发表评论 登录
全部评论

注册时间:2008-07-28

  • 博文量
    62
  • 访问量
    81191