Tuesday, 19 April 2016

How do you purge old archivelogs which are applied on Standby DB



 Is there a command in RMAN for standby db  which list the old archivelogs that has been applied and can be deleted ?


SOLUTIONS :

In a dataguard configuration, the archivelogs from the FRA will be automatically purged when the following conditions are met by the database. If you need it purged in at the Primary site, set it on Primary database.

1) Prior to 11g, if not using mandatory archivelog destinations, the database (primary and standby) must be restarted with the following parameter:

 SQL> alter system set "_ log_deletion_policy"='ALL' scope=spfile;  



2) configure the following parameter in RMAN (primary and standby):
 RMAN> CONFIGURE  ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;  




3) Use Below Script
 $ cat delete.sh  
 [oracle@ora-db u01]$ cat delete.sh  
 ORACLE_HOME=<ORACLE_HOME path>  
 export ORACLE_HOME  
 PATH=$PATH:$ORACLE_HOME/bin  
 export PATH  
 rman target sys/<pwd>@<standbydb> <<EOF  
 spool log to "/u01/delete.log";  
 run  
 {  
 delete force noprompt archivelog all completed before 'SYSDATE-4';  
 }  
 EXIT;  
 EOF  





This would delete all the archives before SYSDATE-4. If this does not work, then you can try deleting them by checking the sequence that was last applied and delete until that sequence using RMAN.

4) The archivelog must have been applied to the standby. Run the following query to list all archivelogs applied to the standby:
 SQL> select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;  



 Now,
 RMAN>delete archivelog until sequence <above value>;  


5) If on the primary site, the archivelog must be obsolete per RMAN retention policy
To list the obsolete objects, run the following query:
 RMAN> SHOW RETENTION POLICY;  
 RMAN>REPORT OBSELETE;  


RMAN> SHOW RETENTION POLICY;
RMAN>REPORT OBSELETE;



6) On Primary
 RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;  
 On Standby ( Depends upon where backup is preformed )  
 RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; 
 
 Or 
 
 RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY; ( if Standby Where Backups Are Not Performed )  






REFERENCES

NOTE:740322.1 - RMAN Archived Redo Logs Are Deleted Before Being Applied at Standby Database

BUG:6216036 - RMAN+DG ARCHIVELOG DELETION POLICY APPLIED ON STANDBY NOT RESPECTED




No comments:

Post a Comment