zoukankan      html  css  js  c++  java
  • dataguard日志自动删除

    dataguard日志自动删除

    1、判断日志是否已经应用到今天。
    2、删除3天前的日志。
    3、主机、备机分别配置

    ----check_del_arch.sh
    #!/bin/sh
    ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome1
    ORACLE_SID=capp
    export ORACLE_HOME ORACLE_SID
    cd $HOME/ljy
    tab='v$archived_log'
    res=`$ORACLE_HOME/bin/sqlplus -S '/ as sysdba' <<EOF |
            set heading off
            select sign(sysdate-max(first_time)-1) from $tab where dest_id=2 and applied='YES';
    EOF

    awk '{print}'`
    echo $res

    if [ $res = "-1" ]; then
            sh delarch.sh
    fi

    echo "ennnnd!"


    ---delarch.sh

    #!/bin/sh
    ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome1
    ORACLE_SID=capp
    export ORACLE_HOME ORACLE_SID
    cd $HOME/ljy

    $ORACLE_HOME/bin/rman nocatalog target / log delarch.log <<!
    delete noprompt archivelog all completed before 'sysdate - 3';
    quit
    !


    rman管理归档日志
    ===============================rman 管理archivelog
    rman登录
     rman target /
     查看所有日志
     list archivelog all;
     检查存在错误的日志,适用于日志文件已经被删除的情形。
     crosscheck archivelog all;
     查看错误的日志
    list expired archivelog all;
    删除错误的日志
     delete expired archivelog all;
     
     删除7天前全部日志
     DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-1';

    《《《《《《《《《《《 千里之行,始于足下
  • 相关阅读:
    软件工程之项目管理核心框架
    JPA @Column
    centos 安装 nodejs vue 工具链.
    c语言 打印二进制数
    Python import 导入指定目录的某块
    最近的一点思考,关于高手/大师/学霸
    同步与非同步,阻塞与非阻塞。
    Spring MVC 配置
    Java Web框架的基本组件
    add函数
  • 原文地址:https://www.cnblogs.com/junyue/p/7792236.html
Copyright © 2011-2022 走看看