ITPub博客

首页 > 数据库 > Oracle > Oracle DG standby删除归档的判断脚本

Oracle DG standby删除归档的判断脚本

原创 Oracle 作者:静以致远√团团 时间:2015-08-11 11:20:53 0 删除 编辑
#!/bin/bash

rman_date=`date "+%Y%m%d"`
rman_log="/home/oracle/oracle_sh/rman_bk_delete.log"
arch_num='10'

####Oracle PATH INFO
export ORACLE_SID=fogtestdb
export ORACLE_BASE=/opt/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin


####select arch_num which is not recover
value=`sqlplus -S "/ as sysdba" << !
set heading off
set feedback off
set pagesize 0
set verify off
set echo off
select count(1) from v\\$archived_log where applied <> 'YES';
exit
!`


#### if count(1) is less than arch_num,delete archive log, else sent mail to me
if [[ $value -le $arch_num ]]; then


echo '---------------------------------------------------------------------------------------' >> $rman_log
echo 'delete_date is:' >> $rman_log
echo  $rman_date  >> $rman_log
echo '---------------------------------------------------------------------------------------' >> $rman_log
$ORACLE_HOME/bin/rman target / << EOF >> $rman_log
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog all completed before 'sysdate-4';
crosscheck backup;
delete noprompt obsolete;
exit;
EOF


echo "exec rman delete archivelog"
exit 0
else
echo "Oracle DGarchivelog is not recover,please check" | mail -s 'DG ARCH CHECK' **********@mail.com,*********@mail.com
fi

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

请登录后发表评论 登录
全部评论
每个人都有梦想,去实现吧!

注册时间:2013-11-14

  • 博文量
    164
  • 访问量
    2103521