Turns out to be quite easy actually. I do backups from the primary database to a local drive and have been puzzled how to delete the standby archive logs after they ship. The ‘obvious’ solution is the documented feature in RMAN:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY
However, that didn’t work when I originally setup RMAN. Turns out that because I’m using ‘Maximum Performance Mode’, my standby archivelog destination is NOT mandatory and therefore Oracle only half pays attention to it.
Finally (August 2005) Oracle released a Metalink Note 331924.1 explaining how to enable this feature of RMAN with either Max Performance or Max Availability mode – just add _log_deletion_policy=’ALL’ to the spfile, restart your database and all should be good (haven’t tested yet – have to ask for reboot time).
Anyway – back to those archivelogs on the standby.
Turns out that RMAN, when you are using a catalog, IS aware of the standby logs, but just can’t delete them if you connected to the primary database. If you invoke RMAN from the standby machine, you can just use regular RMAN commands to manage the files. I had been just deleting archivelogs manually from the drive on the standby once they were old, to keep room available – turns out eventually (9 months on a fairly busy server) I got this message in the alert log, that finally forced me to do it right (although I will take some comfort in getting it wrong since Oracle documented the feature a year after releasing the software):
ORA-19815: WARNING: db_recovery_file_dest_size of 62914560000 bytes is 95.59% used, and has 2773004800 remaining bytes available.
*************************************************************
You have the following choices to free up space from
flash recovery area:
1. Consider changing your RMAN retention policy.
If you are using dataguard, then consider changing your
RMAN archivelog deletion policy.
2. Backup files to tertiary device such as tape using the
RMAN command BACKUP RECOVERY AREA.
3. Add disk space and increase the db_recovery_file_dest_size
parameter to reflect the new space.
4. Delete unncessary files using the RMAN DELETE command.
If an OS command was used to delete files, then use
RMAN CROSSCHECK and DELETE EXPIRED commands.
*************************************************************
What’s strange and let me know that something was horribly wrong, is that there were only 4Gb of files in that area, and the message says that 95.9% of the 60 Gb is used.
Anyway, do what I said above – use RMAN to connect to your standby d/b and the catalog, and for example to delete up to 5 days ago of archivelogs sitting in the flashback area:
run {
allocate channel for maintenance device type disk;
delete archivelog until time 'sysdate -5';
}
(This assumes the db_recovery_file_dest IS the flashback area!)
If you create these files with a directory path specification, you end up with empty directories as each older day's archivelogs get cleaned out, so eventually you will have to hand delete these.