This content has been marked as final. Show 14 replies
You can use asmcmd.
set your ORACLE_SID to an ASM instance
using asmcmd locate the directory that contains the archive log files. for example..
ASMCMD> cd +POC2FLASH/POC2DWH/ARCHIVELOG
using 'rm' command you can delete the directory.
But don't forget to remove the archive log details from the control file or the RMAN catalog
For this you need to connect to the target database using rman
rman target sys/<password> nocatalog
rman>crosscheck archivelog all
rman>delete expired archivelog all
Message was edited by:
Thanks for quick reply.
This is what I am doing now, very manual process.
What I want is, setup an automatic job ( cron or other ) ,
to clean archive logs older than one day or one hour.
I am okay with RMAN solution,
if I don't have to backup these archive logs, before delete.
It is a very bad idea deleting archive logs via asmcmd, the controlfile-FRA code (space management) is not coginizant of this deletion since it was done outside its context.
You do not need to delete archive logs if the archlogs are stored in the Flash Area, since FRA will manage that.
But if you needed to delete manually delete these logs, then you should use RMAN for this. I dont recall the command off hand, but something along the lines of "delete archive logs backed up twice"
you need 2 scripts (modify paths accordingly as per your setup):
connect / as sysdba
set serveroutput on;
declare CURSOR cur IS
FROM v$asm_alias a, v$asm_file b
where a.group_number = b.group_number
and b.creation_date < sysdate-7
and a.file_number = b.file_number
and a.name like '%.arc'
order by a.name;
FOR cur_rec IN cur
sqlstr := 'alter diskgroup ASM_BACKUP drop file ''+ASM_BACKUP/DB1/' || cur_rec.name || '''';
EXECUTE IMMEDIATE sqlstr;
crosscheck archivelog all;
delete expired archivelog all;
Thanks for sharing this on the forum..
This is exactly, what I was looking for.
Can we send RMAN output to /dev/null .
This way, we don't have to write this extra logic.
We may be able to send the RMAN archive log output to /dev/null and delete the expire.
Is this possible ?
why do you want to do that? A delete obsolete is the simplest method
But, How can you make the archivelogs obsolete ?
I assume, you need to take a backup before they get obsolete.
In this scenario, I don't want to take any backup.
Just delete the archive logs ( This is non-prod database and we wanted to keep the archivelog option for perf testing ).
To delete all archivelog on disk no matter wether they are backed up or not ...
RMAN > delete archivelog all;
To delete all archivelog on disk no matter wether they are backed up or not and the yare one day old ...
RMAN > delete archivelog all completed before 'sysdate -1';
Use RMAN to clean all old archivelogs.
So You mean that..
If I delete archive log using asmcmd> rm command then
I have to execute crosscheck command from rman.
What about If I delete archive log using "alter diskgroup <DG> drop file command..
Do I still need to crosscheck the archivefile from RMAN
If your whole objective is to clean the disk group, then you should really not bother about RMAN.
RMAN crosscheck will come in to picture when you want to backup archielogs in future, Oracle will always look for the archives which u already deleted using RM command or using alter disk group command but RMAN is not aware of these deletion.
RM or alter disk group command does not update your controlfile so you need to crosscheck whenever in future you want to backup the archivelogs.
You can query v$archived_log:deleted column to see if the controlfile is update or not.