6 Replies Latest reply: Mar 11, 2013 7:35 PM by mseberg RSS

    Archive Log Deletion

    995714
      Hi Friends,

      I have a RAC system with DR set-up, this is a test environment and it doesn't have any backup, please don't ask me why DR is required but it exist.
      Since this is a test a lot or archives gets generated and deleting the archives has become a daily job for this server manually.
      I want have a script to delete archive logs which is in non-ASM (i.e. filesystem) after ensuring that the archive log has been applied in standby database.
      If this can done only by RMAN please let me know how to do the same.


      Thanks
      R.Chandrasekar
        • 1. Re: Archive Log Deletion
          mseberg
          Hello;

          Welcome to the Forum.

          You have 3 options.

          1. Delete the archive at the OS level using a command like "rm" or "del" ( you will still need to run CROSSCHECK if any RMAN is used, if no RMAN then omit the CROSSCHECK)

          Example
          $ORACLE_HOME/bin/sqlplus /nolog <<EOF
             connect / as sysdba
             @/u01/app/oracle/dba_tool/bin/removestandbyarch.sql
             SPOOL OFF
          EOF
          
          
          echo "Setting permissions and running script"
          
          chmod 740 /u01/app/oracle/dba_tool/bin/rm_arch_standby.sh 
          
          
          
          . /u01/app/oracle/dba_tool/bin/rm_arch_standby.sh
          
          
          #####If using RMAN continue with
          
          echo `date`
          
          echo "Runnung RMAN archive crosscheck"
          
          $ORACLE_HOME/bin/rman <<EOF    
          connect target / 
          crosscheck archivelog all;  
          delete noprompt expired archivelog all; 
          exit
          EOF
          removestandbyarch.sql
          SET echo off
          SET feedback off
          SET term off
          SET pagesize 0
          SET linesize 200
          SET newpage 0
          SET space 0
          col name format a120
          spool /u01/app/oracle/dba_tool/bin/rm_arch_standby.sh
          select 'rm '||NAME from v$archived_log  
          where REGISTRAR='RFS' 
          and APPLIED='YES' 
          and DELETED='NO'  
          and COMPLETION_TIME < (SYSDATE-10);   
          SPOOL OFF
          2. Have RMAN remove the archive.

          Example
          delete noprompt ARCHIVELOG UNTIL TIME 'SYSDATE-8';
          3. Setup FRA and let Oracle handle it.


          Best Regards

          mseberg
          • 2. Re: Archive Log Deletion
            SPA2
            Hi,
            a very good way is to let it Oracle handle.
            So you configure and setup a flash recovery area.
            Then Oracle will handle it for you.


            If you use a DR with Oracle Data Guard then it is also possible to handle it via RMAN.
            Take a look in RMAN with "show all" and set the deletion policy like this.
            CONFIGURE ARCHIVELOG DELETION POLICY TO applied on standby;

            regards
            SPA2
            • 3. Re: Archive Log Deletion
              995714
              Thanks,

              Is it necessary to use FRA, I mean won't RMAN be able to take care if we are using FS as location for archive logs?

              My question is
              After I set "CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY" in both PRIMARY and STANDBY
              can RMAN take care of deleting archive logs only after it gets applied on the standby?
              If yes please let me know the correct statement to be used
              e.g.
              crosscheck archivelog all;
              delete noprompt expired archivelog all;
              • 4. Re: Archive Log Deletion
                mseberg
                Hello again;
                crosscheck archivelog all;
                
                delete noprompt expired archivelog all;
                You probably don't need the "crosscheck archivelog all". Unless you delete outside of RMAN you don't need to crosscheck that often.

                DELETE ARCHIVELOG ALL relies entirely on the configured archived redo log deletion policy. So this is OK.

                You can use "list expired backup all" to check.

                Best Regards

                mseberg
                • 5. Re: Archive Log Deletion
                  995714
                  Thanks very much,
                  I'm little confused,

                  can you tell me if I should configure the RMAN in Primary and Standby or both
                  can you tell me where I should run the delete archivelog all - Primary or Standby


                  Thanks
                  Chandru
                  • 6. Re: Archive Log Deletion
                    mseberg
                    Hello again
                    can you tell me if I should configure the RMAN in Primary and Standby or both.
                    Both.

                    Now you only register RMAN on the Primary since the Standby has the same DBID you cannot register it, as it is already registered.

                    How you configure depends upon where the backup is taken. If you backup from the Primary for example you want either of these set

                    configure archivelog deletion policy to applied on all standby;

                    or

                    configure archivelog deletion policy to shipped to all standby;


                    There's an RMAN best Practices for Data Guard here that details very well :


                    http://www.oracle.com/technetwork/database/features/availability/298772-132349.pdf

                    Best Regards

                    mseberg