• 清理归档日志的脚本并未删除归档日志(疑问)


    客户linux,oracle 11.2.0.4单实例数据库,配置crontab定时任务每天进行DB,ARCH的备份,并且删除5天之前的内容?

    但是疑问在于,客户反馈归档目录满了,归档日志并未被删除???

    列举排查思路:

    #观察每日备份脚本,发现无法正常备份? 为什么,因为日志组并未完全写入完毕,非常有可能是归档路径满导致的。
    released channel: c4 RMAN
    -00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03009: failure of sql command on default channel at 04/02/2020 22:00:10 RMAN-11003: failure during parse/execution of SQL statement: alter system archive log current ORA-16038: ?? 6 sequence# 5322 ???? ORA-19502: ?? "", ??? (???=) ??????? ORA-00312: ???? 6 ?? 1: '/oracle/oradata/rbcheckin/redo06.log'

    在数据库层面切换日志,确认当前切换是否正常,正常的。说明现在DB无异常!

    SQL> alter system archive log current;

    System altered.

    SQL> archive log list

    Database log mode Archive Mode
    Automatic archival Enabled
    Archive destination /xx/arch/xx
    Oldest online log sequence 5335
    Next log sequence to archive 5338
    Current log sequence 5338

    需要检查归档清理脚本,是否存在异常现象?

    #!/bin/bash
    export ORACLE_SID=xxx
    export LOG_DIR=/bak/log
    export LOGFILE=${LOG_DIR}/${TIMESTAMP}_${ORACLE_SID}.log
    echo "==============================================" >>${LOGFILE}
    echo "   " >>${LOGFILE}
    echo "Begin xxx backup at:" `date` --`date +%Y%m%d%H%M` >>${LOGFILE}
    rman target / log=${LOGFILE} append  <<EOF
    run{
    configure retention policy to redundancy 3;
    allocate channel c1 type disk;
    allocate channel c2 type disk;
    allocate channel c3 type disk;
    allocate channel c4 type disk;
    sql'alter system archive log current';
    sql'alter system archive log current';
    crosscheck copy;
    crosscheck backup;
    crosscheck archivelog all;
    delete noprompt obsolete;
    delete noprompt expired archivelog all;
    delete noprompt backup completed before 'sysdate-5';
    delete noprompt backup of archivelog all completed before 'sysdate-5';
    backup current controlfile format='${RMAN_DIR}/ctl_%U_%T';
    backup spfile  format='${RMAN_DIR}/spfile_%U_%T';
    backup as compressed backupset full database format '${RMAN_DIR}/full_%d_%t_%s';
    backup as compressed backupset archivelog all format '${RMAN_DIR}/arch_%d_%T_%s'  not backed up;
    release channel c1;
    release channel c2;
    release channel c3;
    release channel c4;
    }
    exit;
    EOF
    echo "######End backup at:" `date` --`date +%Y%m%d%H%M`"######" >>${LOGFILE}

    初步看没啥问题?

    测试

    Oracle备份及清理归档空间的方式???  那些方式有效,关注重点突出内容即可。
    备份归档日志后,删除已备份的所有归档日志
    RMAN> backup format '/tmp/archlog_%T_%s_%U' archivelog all delete all input;
    备份全库DB后,附加备份归档日志并删除所有归档
    RMAN> backup as compressed backupset full database format '/tmp/full_%d_%t_%s' plus archivelog format
    '/tmp/archlog_%T_%s_%U' delete all input;

    但是常用的备份脚本并不会备份后立即删除!
    1.测试delete obsolete方式?
    日志组多次切换,产生多个归档日志。
    对数据库进行全备
    RMAN>configure retention policy to redundancy 1;
    RMAN> backup as compressed backupset full database format '/tmp/full_%d_%t_%s';

      RMAN> delete noprompt obsolete;  删除了在全备之前的,备份的归档日志文件 并且,对于之前切换多次产生的归档日志文件,也都进行了删除,因为这些归档日志的scn在全备的SCN之后。 

    也就是说,使用delete obsolete是能够有效的删除RMAN备份归档日志之后的备份文件,以及日志切换产生的归档日志文件。

    但是如果冗余时间过长,可能无法起到定期清理归档的作用。

    2.测试脚本中delete   backup 作用?

    同样,先切换多次日志组,产生足够数量的归档日志。

    RMAN> delete noprompt backup completed after 'sysdate-5'; 
    【测试环境没有那么多天前的归档备份,只能用after之后替代】
    备份的归档日志已删除,但是操作系统上日志组切换产生的归档日志还在!!!
    RMAN> backup format '/tmp/archlog_%T_%s_%U' archivelog all;
    delete noprompt backup of archivelog all completed after 'sysdate-5';
    备份的归档日志已删除,但是操作系统上日志组切换产生的归档日志还在!!!   
    至此,可以得到,客户的归档日志为什么没有被删除,因为脚本中并未对操作系统的归档日志有任何删除策略。
    Obsolete有作用,但是并未生效! 这个当时没有留下什么日志,因此不太好分析为啥存在obsolete删除,但是归档让操作系统撑满了!

     3.直接使用delete archive方式

    RMAN> backup format '/tmp/archlog_%T_%s_%U' archivelog all;

    RMAN> delete noprompt archivelog until time 'sysdate';

    只能删除日志组切换产生的归档日志,但是RMAN备份归档后产生的文件,并不会被删除!!!


    关于before,
    completed 时间请参考大佬博客链接
    https://blog.csdn.net/yabingshi_tech/article/details/43966033
  • 相关阅读:
    WIndows下编译libexif-0.6.21,生成VS下可用的dll和lib
    Android开发之获取系统12/24小时制的时间
    转自 x_x的百度空间
    BZOJ1483: [HNOI2009]梦幻布丁
    BZOJ2124: 等差子序列
    BZOJ2431: [HAOI2009]逆序对数列
    BZOJ1831: [AHOI2008]逆序对
    2821: 作诗(Poetize)
    BZOJ2038小Z的袜子(hose)
    NOI2005维护数列
  • 原文地址:https://www.cnblogs.com/lvcha001/p/12652019.html
Copyright © 2020-2023  润新知