Cleaning Oracle Archived Logs

  • Last update: March 10, 2025
  • Overview

    When Oracle operates in the ARCHIVELOG mode, it generates a large number of log files in the specified archive log directory, and these log files are not cleaned up regularly by default. Prolonged operation can lead to log files consuming significant storage space, potentially causing Oracle to run out of disk space and fail to maintain its startup state.

    Business operations may be impacted if the disk becomes full. Clean up expired archived logs regularly.

    The control file of an Oracle database retains entries for archived logs even after their physical files are deleted. Ensure both the files and their entries in the control file are removed.

    Preparation

    Determine the location of the archive logs. The archive log paths may differ. If you are unsure where the archive logs are, you can use the command find / -name *.dbf to locate them.

    2-1.png

    Method One: Deleting Archive Logs with RMAN

    Using this method, you can delete the physical files and their entries in the control file synchronously.

    Viewing the Control File

    Log in to Oracle Recovery Manager (RMAN).

    Use the following command to enter RMAN, as shown in the following figure.

    rman target /

    3.1-1.png

    Use the following command to view all archive log entries.

    list archivelog all;

    Deleting Logs Prior to a Specified Date

    You can use the following command to delete archive logs from three days ago, which deletes both the physical files and their entries in the control file.

    delete archivelog all completed before 'SYSDATE - 3';

    3.2-1.png

    Enter YES after the confirmation prompt to finish deletion.

    Checking Physical File Status

    Check the physical file list after deleting the files in the previous step. You can see that the physical files are deleted synchronously.

    Method Two

    If you have manually deleted a physical file before, you can use this method to delete its entry in the control file.

    Deleting a Physical File

    To delete the physical file xxxx.dbf, navigate to the location where the DBF file is stored and use the following command to delete it. Change the file name to the name of the log file you want to delete.

    rm -f xxxx.dbf

    Viewing the Control File

    Use the following command to check the log file entries in the Oracle control file. You will find that xxxx.dbf still exists.

    Log in to RMAN.

    Use the following command to enter RMAN, as shown in the following figure.

    rman target /

    4.2-1.png

    Use the following command to view all archive log entries.

    list archivelog all;

    Checking Consistency Between Physical Files and the Control File Content

    If you have previously deleted physical files but did not remove the entries from the control file, proceed as follows.

    You are advised to prioritize using the following command to check consistency between the physical files and the entries in the control file.

    crosscheck archivelog all;

    You can use the following command to filter expired log files after checking consistency.

    list expired archivelog all;

    Deleting Expired Files

    You can use the following command to delete expired log files. Upon execution, you will be prompted to confirm the deletion of the identified expired files.

    delete expired archivelog all;

    4.4-1.png








    附件列表


    主题: Data Pipeline
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    9s后關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy