Because the rm and find methods Delete the actual archive logs and release the space, the archive information stored in the control file is not completely cleared. Still occupying some space
Because the rm and find methods Delete the actual archive logs and release the space, the archive information stored in the control file is not completely cleared. Still occupying some space
In the development environment and UAT environment, you often encounter the need to clear archived logs. There are many ways to solve this problem. You can use rm to clear archived logs directly, or use the find command to find matching records to clear archived logs, or write a shell script to clear the logs. In this way, DEV or UAT can be used. However, in the Prod environment, we recommend that you use the Command provided by RMAN to handle the problem properly. Because the rm and find methods Delete the actual archive logs and release the space, the archive information stored in the control file is not completely cleared. It still occupies some space and cannot be cleared in time. Therefore, you need to control the file to release the space in the age out mode. This document describes how to use RMAN to clear archived logs and deploy the logs in shell scripts.
For more information, see
Oracle archiving logs
Oracle Control File)
Oracle ONLINE redo LOG FILE)
Linux/Unix shell scripts call SQL and RMAN scripts
Linux/Unix shell script to clear archived log files
1. How to clear archived logs
A. manually delete
You can use rm or find to delete an archive. After deletion, you can use crosscheck archivelog all in RMAN to check whether the archive is invalid. The following operations are performed:
Rm-rf arch_816906485_48710.arc
Find/u02/database/GOBO1/archive/-ctime + 0-delete
RMAN> crosscheck archivelog all
B. Clear Data Using RMAN
The RMAN cleanup method automatically clears the archive log files on the disk, and releases the archive information of the corresponding archive log in the control file.
You can clear archived logs based on different conditions, such as SCN, SEQUENCE, and TIME.
The preceding three methods can be used with clauses such as from, until, between... and so on to limit the scope. The method is flexible and variable.
The following command is used to verify the validity of archived logs, list invalid archived logs, and how to clear archived logs to list several common:
Crosscheck archivelog all; ---> verify log availability
List expired archivelog all; ---> list all invalid archive logs
Delete archivelog until sequence 16; ---> delete all archived logs whose log sequence is 16 or before 16
Delete archivelog all completed before 'sysdate-7'; ---> delete the archived logs generated seven days earlier than the system time. Valid archived logs in the flash back area are not deleted.
Delete archivelog all completed before 'sysdate-1'; ---> same as above
Delete archivelog from time 'sysdate-1'; ---> note this command to delete the archived logs generated within one day of the system.
Delete noprompt archivelog all completed before 'sysdate'; ---> This command clears all archived logs.
Delete noprompt archivelog all; ---> same as the previous command
2. Use RMAN to clear archived logs
Robin @ SZDB: ~> Export ORACLE_SID = GOBO1
Robin @ SZDB: ~> Rman target/
Recovery Manager: Release 10.2.0.3.0-Production on Thu Jul 11 17:07:00 2013
Copyright (c) 1982,200 5, Oracle. All rights reserved.
Connected to target database: GOBO1 (DBID = 733951103)
RMAN> host;
Robin @ SZDB: ~> Cd/u02/database/GOBO1/archive/
Robin @ SZDB:/u02/database/GOBO1/archive> ls
Arch_816906485_1_10.arc arch_816906485_1_12.arc
Arch_816906485_1_11.arc arch_816906485_1_13.arc
............
Robin @ SZDB:/u02/database/GOBO1/archive> rm-rf arch_816906485_1_10.arc arch_816906485_1_11.arc arch_816906485_1_12.arc
Robin @ SZDB:/u02/database/GOBO1/archive> exit;
Exit
Host command complete
RMAN> crosscheck archivelog all;
Released channel: ORA_DISK_1
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: sid = 1075 devtype = DISK
Archive log filename =/u02/database/GOBO1/archive/arch_816906485_00009.arc recid = 2085 stamp = 817211151
Validation failed for archived log
Archive log filename =/u02/database/GOBO1/archive/arch_816906485_20.10.arc recid = 2086 stamp = 817250793
..............
Validation succeeded for archived log
Archive log filename =/u02/database/GOBO1/archive/arch_816906485_000090.arc recid = 2166 stamp = 820458049
Crosschecked 83 objects
RMAN> list expired archivelog all;