How to correctly Delete Oracle archive log files

Source: Internet
Author: User
We all know that the controlfile records information about each archivelog. Of course, after deleting these physical files in the OS

We all know that the controlfile records information about each archivelog. Of course, after deleting these physical files in the OS

We all know that each archivelog information is recorded in controlfile. Of course, after deleting these physical files under OS, the archivelog information is still recorded in our controlfile, the Oracle OEM manager displays visualized logs. After we manually clear the files in the archive directory, these records are not cleared from the controlfile, that is, oracle does not know that these files no longer exist! In this case, if we want to manually clear it, we can try this method after experiment:


1. Enter rman
2. connect target/
3. crosscheck archivelog all;
4. delete expired archivelog all;
At this time, we will not see it again in the OEM. If you have never done this operation, we can compare the controlfile size after the controlfile before this action!

How Does ORACLE Delete the archive and recycle the space correctly?


How Does ORACLE Delete the archive and recycle the space correctly?
An ORACLE archive log is often full, as the file space occupied by/oraarchive is 100%. Everyone must complain about why ORACLE does not have an archive maintenance tool. Many people delete the file directly. Wrong, ORACLE has, it is intelligent to delete archive and FLASHBACK correctly. However, it is important to remember that ORACLE archive logs are important for ORACLE data recovery and backup. You cannot delete archive logs unless necessary.
Deleting archived logs
Log on to the database server host as an ORACLE user or connect to the database server through a network
Go to ORACLE Data Backup Tool
Rman target/
Or rman target/@ orcl
Run
Delete archivelog all completed before 'sysdate-7 ';
Description
SYSDATA-7, indicating the current system time 7 days ago, the before keyword indicates the archived log 7 days ago, and if the flash back function is used, the flash back data is also deleted.
In the same way, you can delete all the logs from the past seven days to the present. However, this command should be clear. After this deletion, it is best to back up the database immediately.
Delete archivelog from time 'sysdate-7'; DELETE all logs FROM the past 7 days, with caution

In UNIX/LINUX, you can also use FIND to FIND the archived data seven days ago and delete it using the EXEC sub-operation.

Find/oraarchive-xdev-mtime + 7-name "*. dbf"-exec rm-f {};
In this way, unmanaged archive files will still be left in RMAN.
You still need to execute the following two commands in RMAN
Crosscheck archivelog all;
Delete expired archivelog all;
So it is not as easy to use as the above method, but the advantage of using FIND is that you can perform a lot of operations on the condition and the EXEC subitem to implement more complex functions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.