oracle rman 删除 dataguard 环境中 role 为 physical standby 的 archivelog

oracle_ifexec.sh

#!/bin/bash

sqlplus -S /nolog <

oracle_globalvar.sh

#!/bin/bash
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/dbhome_1
export ORACLE_SID=_GLOBAL_ORACLE_SID_
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export PATH=$PATH:/ORACLE_HOME/bin
export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$ORACLE_HOME/opatch
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib

其中 _GLOBAL_ORACLE_SID_ 为节点的实例名

oracle_standby_delete.sh

#!/bin/bash

readonly DELETETYPE=$1

ORACLE_SCRIPTDIR=_GLOBAL_ORACLE_SCRIPTDIR_
source $ORACLE_SCRIPTDIR/oracle_globalvar.sh

function usage() {
    echo "Usage: $0 < arch >";
    exit 1;
}


IFDELETE=`bash $ORACLE_SCRIPTDIR/oracle_ifexec.sh`
echo "$IFDELETE"

if [[ $IFDELETE == "STANDBY1" ]]; then
    echo "`date` info: this node [`hostname`] will begin [$DELETETYPE] standby delete,..."
elif [[ $IFDELETE == 'PRIMARY1' ]]; then
    echo "`date` warning: this node [`hostname`] is not allow execute [$DELETETYPE] standby delete,exit now..."
    exit 0;
elif [[ $IFDELETE == 'NO' ]]; then
    echo "`date` warning: this node [`hostname`] is not allow execute [$DELETETYPE] standby delete,exit now..."
    exit 0;    
else
    echo "`date` error: sqlplus execute result is error on [`hostname`] ,please check [$DELETETYPE],exit now..."
    exit 1;
fi

case $DELETETYPE in
    arch)
        rman target=/ cmdfile=_GLOBAL_ORACLE_SCRIPTDIR_/oracle_standby_archivelog_delete.rman log=_GLOBAL_ORACLE_LOGDIR_/oracle_standby_archivelog_delete_`date +%Y%m%d%H%M%S`.log
        if [ $? -eq 0 ];then
            echo ""
            echo "`date` info: this node [`hostname`] end [$DELETETYPE] standby delete..."
        else
            echo ""
            echo "`date` error: this node [`hostname`] end [$DELETETYPE] standby delete,but standby delete fail,please check [$DELETETYPE],exit now..."
            exit 1
        fi
        ;;
    *)
        usage
        ;;
esac

其中 _GLOBAL_ORACLE_SCRIPTDIR_ 为脚本存放路径

oracle_standby_archivelog_delete.rman

crosscheck archivelog all;

delete force noprompt expired archivelog all;
delete force noprompt archivelog until time 'sysdate - _GLOBAL_ORACLE_STANDBY_ARCHIVELOG_RETENSION_DAYS_';

list archivelog all;
list expired archivelog all;
 
exit;

其中 _GLOBAL_ORACLE_STANDBY_ARCHIVELOG_RETENSION_DAYS_ 为 standby 节点需要保留归档日志的天数.
比如:

delete force noprompt archivelog until time 'sysdate - 3';

你可能感兴趣的:(#,oracle,backup,recovery,#,oracle,ha,data,guard)