• 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
  • 相关阅读:
    第一次点击button, view视图出现;第二次点击button,view视图消失
    快速破解ps方法
    终端中出现While executing gem ... (Errno::EPERM) Operation not permitted
    隐藏顶部状态栏的方法
    python之dict和set
    python之循环
    python 之条件判断
    python 之列表和元组
    python 之字符串和编码
    人生第一次面试之旅
  • 原文地址:https://www.cnblogs.com/liang545621/p/9410577.html
Copyright © 2020-2023  润新知