zoukankan      html  css  js  c++  java
  • del_archivelog

    #!/usr/bin/env bash                         
    # INTRO : The script for delete physical standby applied archivelog.
    #         Please set ur environment variables before use it.
    #         Please execute the script on physical standby site.
    #
    # USAGE : ./del_archivelog.sh                                                            
    #                                                                     
    # TEST  : This script has been successfully tested on these platforms:                                                                     
    #         Linux 
    #         Physical standby
    #         Oracle Database 10gR2,11gR2,Include RAC                            
    #                                                       
    # NOTE  : Please test this script in ur development environment 
    #         before attempting to run it in production.                                     
    # =================================================================================
     
    #----------------------------------------------------------------------------------
    ###setup environment variables
    export ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db_1
    export ORACLE_SID=standby
    export PATH=$ORACLE_HOME/bin:$PATH
    #export ARCHIVE_DIR=+DATA/standby/archivelog
    export LOG_FILE=$HOME/scripts/logs/del_archive.log
    #----------------------------------------------------------------------------------
     
    ###determine user 
    if [ `whoami` != 'oracle' ];then
    echo "Warning: Please use oracle execute.">>$LOG_FILE
    exit 99
    fi
     
    ###define archivelog sequence will be deleted
    sqlplus -s / as sysdba << EOF > tmp.log
    set lines 100 feedback off echo off heading off;
    select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread# order by thread#;
    EOF
     
    MAXLINE=`cat tmp.log|wc -l`
     
    for (( i=1;i<$MAXLINE;i++ )); do
     
    i=$(( i + 1 ))
    THREAD=`sed -n "$i,$i"p tmp.log|awk -F' ' '{print $1}'`
    MAXSEQ=`sed -n "$i,$i"p tmp.log|awk -F' ' '{print $2}'`
     
    ###Retains the most recent five Archive
    MAXSEQ=$(( $MAXSEQ - 5 ))
     
    ###Delete physical standby applied archivelog
    echo "****************************************************************************" >> $LOG_FILE
    echo ">>> Begin deleting applied archivelogs : `date` <<<">>$LOG_FILE
     
    i=$(( i - 1 ))
     
    rman target / <<EOF >> $LOG_FILE
    ##catalog start with '$ARCHIVE_DIR' noprompt;
    delete noprompt archivelog until sequence $MAXSEQ thread $THREAD;
    EOF
     
    echo >> $LOG_FILE
    echo ">>> End delete applied archivelogs : `date` <<<">>$LOG_FILE
     
    echo "****************************************************************************" >> $LOG_FILE
    echo >> $LOG_FILE
     
    done
     
    rm -f tmp.log
  • 相关阅读:
    Java中的访问修饰符详细解析
    Java继承 练习题
    (转)Java 内存整理——堆、栈、常量池
    关于Char思考题
    如何使用帮助文档
    工具类的来由与静态方法
    题解 【NOIP2011】计算系数
    题解 【Uva】硬币问题
    题解 【NOIP2006】作业调度方案
    题解 【NOIP2003】神经网络
  • 原文地址:https://www.cnblogs.com/l10n/p/9410577.html
Copyright © 2011-2022 走看看