1 2 Previous Next 15 Replies Latest reply: Oct 27, 2012 4:16 AM by 864988 RSS

    Script remove archives from standby after applied

    864988
      Hello,

      I am looking for a script to remove archivelog files from the standby flash recovery area after beeing applied.

      My database is 11.2.0.3.3 on Linux Redhat 5.

      Can someone kindly proovide me an example?

      Thank you
        • 1. Re: Script remove archives from standby after applied
          mseberg
          Hello;

          Something like this works :
          echo "Starting RMAN..."
          $ORACLE_HOME/bin/rman target / catalog rmancat/rmancat@rcatalog << EOF
          
          
          delete noprompt ARCHIVELOG UNTIL TIME 'SYSDATE-8';
          
          
          exit
          EOF
          Make sure you have CONFIGURE set to delete when applied on Standby first.

          On Primary

          archivelog deletion policy to applied on standby

          Best Regards

          mseberg
          • 2. Re: Script remove archives from standby after applied
            864988
            Thank you. But, the issue , the archivelogs are too much generated (very busy system) also acccording to your input you don't verify whenever archives have been applied or not :(
            • 3. Re: Script remove archives from standby after applied
              mseberg
              RMAN does that for you :

              RMAN>CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;

              Then set the date to what you need and run as often as you need.

              http://docs.oracle.com/cd/E18283_01/server.112/e17022/rman.htm#BAJHHAEB
              #!/bin/bash
              #.................................................
              # Name: db_rman_arch_standby.sh 
              # Purpose: Delete archive from standby
              # Usage : db_rman_arch_standby <DBNAME>
              #..................................................
              # 
              
              if [ "$1" ]
              then DBNAME=$1
              else
              echo "basename $0 : Syntax error : use . db_rman_full <DBNAME> "
              exit 1
              fi
              
              . /u01/app/oracle/dba_tool/env/${DBNAME}.env
              
              
              echo ${DBNAME}
              
              MAILHEADER="Archive_cleanup_on_STANDBY_${DBNAME}"
              
              echo "Starting RMAN..."
              $ORACLE_HOME/bin/rman target / catalog rmancat/rmancat@rcatalog << EOF
              
              
              delete noprompt ARCHIVELOG UNTIL TIME 'SYSDATE-1';
              
              
              exit
              EOF
              
              
              echo `date`
              #
              echo
              echo 'End of archive cleanup on STANDBY'
              
              mailx -s ${MAILHEADER} $MAILTO < /tmp/rmandbarchstandby.out
              
              
              
              . /u01/app/oracle/dba_tool/bin/rmemptyfolders.sh ${DBNAME}
              #
              # End of Script
              Uses an ENV file ( standby.env ) for each database. Use Linux ENV to compare to your settings
              ORACLE_BASE=/u01/app/oracle
              
              ULIMIT=unlimited
              
              ORACLE_SID=STANDBY
              
              ORACLE_HOME=$ORACLE_BASE/product/11.2.0.2
              
              ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
              
              LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
              
              LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
              
              LIBPATH=$LD_LIBRARY_PATH:/usr/lib
              
              TNS_ADMIN=$ORACLE_HOME/network/admin
              
              PATH=$ORACLE_HOME/bin:$ORACLE_BASE/dba_tool/bin:/bin:/usr/bin:/usr/ccs/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/lbin:/GNU/bin/make:/u01/app/oracle/dba_tool/bin:/home/oracle/utils/SCRIPTS:/usr/local/bin:.
              
              export TERM=vt100
              
              export ORACLE_BASE ORACLE_SID ORACLE_TERM ULIMIT
              
              export ORACLE_HOME
              
              export LIBPATH LD_LIBRARY_PATH ORA_NLS33
              
              export TNS_ADMIN
              
              export PATH
              Best Regards

              mseberg

              Edited by: mseberg on Oct 25, 2012 4:58 AM
              • 4. Re: Script remove archives from standby after applied
                teits
                DBA wrote:
                Hello,

                I am looking for a script to remove archivelog files from the standby flash recovery area after beeing applied.

                My database is 11.2.0.3.3 on Linux Redhat 5.

                Can someone kindly proovide me an example?

                Thank you
                to delete archivelogs after ensuring that they were applied on all standby destinations set persistent in rman:
                rman> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
                then you can automatic the below scripts as frequency as possible for you.
                RMAN>  run {
                2>  #if you have other thing to do put it here
                3> crosscheck archivelog all;
                4> DELETE noprompt ARCHIVELOG ALL;
                5>  }
                Tobi
                • 5. Re: Script remove archives from standby after applied
                  864988
                  sorry I don't have recovery catalogue I am using controlfile catalogue ... I think it doesn't work right?
                  • 6. Re: Script remove archives from standby after applied
                    mseberg
                    Should still work. The control file would hold the CONFIGURE setting for RMAN.

                    Change setting and then run :

                    RMAN> SHOW ALL;

                    Best Regards

                    mseberg
                    • 7. Re: Script remove archives from standby after applied
                      864988
                      Thank you, Do you have the script you provided setup in your production env and does it removing the archivelogs from physical standby FRA site? or you just create the script now and you didn't tested it?

                      cheers

                      Edited by: DBA on 25-oct-2012 3:21
                      • 8. Re: Script remove archives from standby after applied
                        mseberg
                        The script and .env in my second post are tested for what you asked for.

                        Each database you want to use this for needs its own .env file

                        STANDBY.env
                        RECOVER.env


                        etc, etc.

                        Then you can call the script in the back ground like this : ( crontab every 30 minutes )

                        00,30 * * * * /u01/app/oracle/dba_tool/bin/db_rman_arch_standby.sh STANDBY > /tmp/rmandbarchstandby.out

                        OR

                        nohup /u01/app/oracle/dba_tool/bin/db_rman_arch_standby.sh STANDBY > /tmp/rmandbarchstandby.out &

                        Best Regards

                        mseberg
                        • 9. Re: Script remove archives from standby after applied
                          864988
                          thank you,
                          How RMAN knows about the archives to delete? So RMAN knows which archivelogs to delete once I configure this in RMAN catalogue of Standby site (CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY; ) , right?

                          Cheers
                          • 10. Re: Script remove archives from standby after applied
                            864988
                            In RMAN standby catalogue, I already have this;
                            CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
                            But, I would need to remove withc more frequency the archivelogs as soon as they are applied perhaps every 30 minutes ...
                            • 11. Re: Script remove archives from standby after applied
                              teits
                              DBA wrote:
                              thank you,
                              How RMAN knows about the archives to delete? So RMAN knows which archivelogs to delete once I configure this in RMAN catalogue of Standby site (CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY; ) , right?

                              Cheers
                              YES
                              • 12. Re: Script remove archives from standby after applied
                                mseberg
                                Hello again;

                                That's really an internal Oracle question. Oracle knows what's been applied and RMAN in part of Oracle.

                                It works. If you try to delete a log not applied Oracle throws an error to warn you.

                                I have to go get ready for work.

                                I hope I answered all your questions.

                                Best Regards

                                mseberg
                                • 13. Re: Script remove archives from standby after applied
                                  teits
                                  DBA wrote:
                                  In RMAN standby catalogue, I already have this;
                                  CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
                                  But, I would need to remove withc more frequency the archivelogs as soon as they are applied perhaps every 30 minutes ...
                                  RMAN>  run {
                                  2>  #if you have other thing to do put it here
                                  3> crosscheck archivelog all;
                                  4> DELETE noprompt ARCHIVELOG ALL;
                                  5>  }
                                  simply, put this in crontab/rman script....an execute it every 30 minutes.

                                  see full example...tested
                                  [oracle@red1 ~]$ more del_archivelog.sh 
                                  PATH=$PATH:$HOME/bin
                                  export PATH
                                  #TMP=/oratmp
                                  #TMPDIR=/oratmp
                                  ORACLE_BASE=/u01/app/oracle
                                  ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
                                  ORACLE_SID=stby2
                                  PATH=$ORACLE_HOME/bin:$PATH
                                  export TMP TMPDIR ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
                                  
                                  rman target / LOG /home/oracle/rman_del_arch.log <<-EOI
                                  RUN {
                                  #IF YOU HAVE OTHER THING TO DO PUT IT HERE
                                  CROSSCHECK ARCHIVELOG ALL;
                                  DELETE NOPROMPT ARCHIVELOG ALL;
                                  } 
                                  exit
                                  EOI
                                  
                                  exit
                                  [oracle@red1 ~]$ crontab -l
                                  00,30 * * * * /home/oracle/del_archivelog.sh
                                  Edited by: teits on Oct 25, 2012 11:10 AM
                                  • 14. Re: Script remove archives from standby after applied
                                    mseberg
                                    Hello again;

                                    So all you have to do is change this :
                                    delete noprompt ARCHIVELOG UNTIL TIME 'SYSDATE-1';
                                    To this
                                    DELETE NOPROMPT ARCHIVELOG ALL;
                                    And set the cron to run as you need it.

                                    There's a couple of Oracle notes worth a look too :

                                    RMAN Archived Redo Logs Are Deleted Before Being Applied at Standby Database [ID 740322.1]

                                    How to Ensure that RMAN Does NOT Delete Archived Logs That Have Not Yet Shipped to Standby [ID 394261.1]

                                    Dataguard-Automate Removal Of Archives Once Applied Against Physical Standby [ID 260874.1]

                                    Best Regards

                                    mseberg
                                    1 2 Previous Next