这篇文章主要介绍了dg如何实现删除备库已经应用的归档日志脚本,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
#!/bin/bash
#by ray
#2017-08-30
#v0.1
. ~/.bash_profile
#get sequence id that have applied.
[ -e /home/oracle/.applied_archivelog.txt ] && rm -f /home/oracle/.applied_archivelog.txt
sqlplus -s /nolog <<-RAY
conn / as sysdba
set heading off
set feedback off
set linesize 300
set pages 1000
col name for a100
spool /home/oracle/.applied_archivelog.txt
select sequence# from v\$archived_log where applied='YES' order by sequence#;
spool off
exit
RAY
[ -e /home/oracle/.applied_archivelog.txt ] && seq=`tail -2 /home/oracle/.applied_archivelog.txt | sed -n '1p'` || (echo "delete archive log failed!" >> /home/oracle/log/delete_archivelog.log ; exit 1)
logfile=/home/oracle/log/delete_archivelog_`date +%Y%m%d-%H%M%S`.log
rman target / log $logfile append <<EOF
delete noprompt archivelog until sequence ${seq};
crosscheck archivelog all;
delete noprompt expired archivelog all;
exit;
EOF
感谢你能够认真阅读完这篇文章,希望小编分享的“dg如何实现删除备库已经应用的归档日志脚本”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!