Backup Options   «Prev  Next»

Lesson 4Clearing corrupt Online Redo Log Files
ObjectiveDescribe the Application of Syntax to clear Redo Log Files

Clearing Corrupt online Redo Log Files in Oracle

The `ALTER DATABASE CLEAR LOGFILE` statement is still used to clear corrupt or inactive online redo log files in Oracle 19c. This command is necessary when one or more redo log files become corrupted and cannot be used for recovery purposes. Here’s a detailed explanation of its functionality and usage:
Purpose of `ALTER DATABASE CLEAR LOGFILE`
This command is used to:
  1. Clear corrupted online redo log files that are no longer needed for instance recovery.
  2. Reinitialize the redo log file so it can be used again without requiring a full database shutdown and manual intervention.
  3. Handle scenarios where redo log files are marked as "STALE" or unusable due to corruption.
Syntax
ALTER DATABASE CLEAR LOGFILE GROUP ;

Use Cases in Oracle 19c
  • Corrupted Inactive Redo Log: If an online redo log file becomes corrupt but is not part of the current redo log group, you can clear it.
  • Reset Unarchived Logs: If a redo log file has not been archived, you can use the UNARCHIVED option to clear it, but be aware this might result in a loss of recoverability:
    ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP <group_number>;
        

Steps for Clearing a Corrupt Redo Log File
  1. Check the Status of Redo Log Groups: Use the following query to identify the corrupt redo log group:
    SELECT GROUP#, STATUS FROM V$LOG;
        
    • INACTIVE: Safe to clear.
    • CURRENT: Cannot be cleared as it is actively being written to.
    • ACTIVE: Cannot be cleared directly; it must be archived or switched out.
  2. Clear the Corrupt Log:
    ALTER DATABASE CLEAR LOGFILE GROUP <group_number>;
        
  3. Special Case - Unarchived Redo Logs: If the log group has not been archived, add the UNARCHIVED option:
    ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP <group_number>;
        

Warning: This may result in the loss of redo data and compromise recoverability.


Important Considerations in Oracle 19c
  1. ARCHIVELOG Mode:
    • If the database is in ARCHIVELOG mode, ensure that the corrupt log has been archived (or force archiving) before clearing it. Otherwise, you risk losing data.
  2. Loss of Recoverability:
    • Clearing unarchived redo logs can lead to data loss in the event of a recovery. Use this only if necessary and after confirming there are no alternative recovery strategies.
  3. Redo Log Multiplexing:
    • If redo logs are multiplexed, ensure the other member(s) of the group are intact before clearing the corrupt log.

Example
-- Identify the redo log groups and their status
SELECT GROUP#, STATUS, MEMBER FROM V$LOGFILE;

-- Clear the corrupt log group (e.g., Group 2)
ALTER DATABASE CLEAR LOGFILE GROUP 2;

-- If unarchived, use this:
ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 2;

Alternative in Some Cases If the redo log file corruption impacts recoverability or the database cannot be opened, you may need to:
  1. Perform incomplete recovery (RECOVER DATABASE UNTIL CANCEL) if unarchived redo logs were lost.
  2. Drop and recreate the redo log group using:
    ALTER DATABASE DROP LOGFILE GROUP <group_number>;
    ALTER DATABASE ADD LOGFILE GROUP <group_number> ('<path>') SIZE <size>;
        

Conclusion: The `ALTER DATABASE CLEAR LOGFILE` command remains relevant and functional in Oracle 19c for managing corrupt or inactive redo log files. However, it must be used cautiously to avoid jeopardizing the recoverability of the database. Always review the status of the redo log groups and ensure data safety, especially in `ARCHIVELOG` mode.

Media Failure damages the Online Redo Log (Legacy)

If a media failure damages the online redo log files of a database, you have to consider the following two situations in order to determine the appropriate recovery procedure:
  1. Is the media failure temporary or permanent?
  2. Which online redo log is damaged?
  3. Is it the current or the inactive one?
  4. Has it been archived yet?

In most situations, the corrupt online redo log files can be recovered by issuing the
ALTER DATABASE CLEAR LOGFILE GROUP <group_number>;
command with the options UNARCHIVED and UNRECOVERABLE DATAFILE. View the SlideShow below to examine the steps to clear damaged online redo log files.

Steps to clear damaged online redo log files

1) If a media failure happens, check if the media failure is permanent or temporary.
1) If a media failure happens, check if the media failure is permanent or temporary.

2) If the media failure is temporary, simply have the hardware problem fixed
2) If the media failure is temporary, simply have the hardware problem fixed

3) If the media failure is permanent, check if the database is open. If not, mount the database.
3) If the media failure is permanent, check if the database is open. If not, mount the database.

4) Check if the damaged online redo log is archived
4) Check if the damaged online redo log is archived . If not issue the
ALTER DATABASE CLEAR UNARCHIVED LOGFILE <group_number>; 
command

5) If the damaged online redo log is archived, use the  ALTER DATABASE CLEAR LOGFILE <group_number>; command
5) If the damaged online redo log is archived, use the
ALTER DATABASE CLEAR LOGFILE <group_number>; 

command

ALTER DATABASE CLEAR LOGFILE GROUP in Oracle 19c

Media Failure and Online Redo Log Recovery
  1. Considering the Media Failure:
    • It is true that determining whether the media failure is temporary or permanent is critical in deciding the appropriate recovery procedure in Oracle 19c.
    • A temporary failure (e.g., disk or file system issue) may allow for repairing or restoring the damaged files.
    • A permanent failure (e.g., hardware damage or file corruption) often requires clearing or recreating the redo log files.
  2. Damaged Online Redo Log Group:
    • The recovery method depends on whether the damaged redo log file is current, active, or inactive:
      • Current log file: This cannot be cleared directly. You would need to:
        • Resolve the issue if possible (e.g., fix the media failure).
        • Perform recovery using backups and archived logs, if necessary.
      • Active log file: Contains data still needed for recovery. You need to archive it (if possible) before clearing.
      • Inactive log file: Can typically be cleared directly, as it is not required for recovery.
  3. Archived vs. Unarchived Logs:
    • If the damaged redo log group is archived, recovery is straightforward. The database can safely clear or recreate the group.
    • If the damaged redo log group is unarchived, special care is needed. Using the UNARCHIVED option during the clear operation will result in the loss of recoverability for transactions contained in the log. This is a critical decision.

Using `ALTER DATABASE CLEAR LOGFILE` in Oracle 19c The command you mentioned is valid and used in Oracle 19c for recovering corrupt redo log files:
ALTER DATABASE CLEAR LOGFILE GROUP ;

Options:
  1. UNARCHIVED:
    • Used when the log group is damaged and has not been archived. This removes the redo log contents, meaning any data within the log group will not be available for recovery.
  2. UNRECOVERABLE DATAFILE:
    • This option is necessary if the corrupted redo log contains information required for recovering a datafile. It marks the datafile as unrecoverable, and recovery cannot be performed for that datafile from this redo log. Subsequent recovery will require a fresh backup of the affected datafile.

Modern Considerations in Oracle 19c
  1. Redo Log Multiplexing:
    • Oracle recommends multiplexing redo logs across multiple disk locations. If one member of the redo log group becomes corrupted, the other members can still be used without clearing the log group.
  2. ARCHIVELOG Mode:
    • In ARCHIVELOG mode, always try to archive the damaged redo log group if it contains data needed for recovery before using the CLEAR LOGFILE command.
    • Oracle 19c's advanced logging mechanisms make redo log corruption less common, especially when logs are properly multiplexed.
  3. Automatic Diagnostic Repository (ADR):
    • In Oracle 19c, ADR simplifies troubleshooting by providing detailed diagnostic information for corrupt redo logs, helping to determine if clearing or other recovery methods are needed.

Modern Alternatives in Oracle 19c - If the redo log group cannot be cleared, or if `ALTER DATABASE CLEAR LOGFILE` is not feasible (e.g., for a current log), you might:
  1. Drop and recreate the log group:
    ALTER DATABASE DROP LOGFILE GROUP <group_number>;
    ALTER DATABASE ADD LOGFILE GROUP <group_number> ('<path>') SIZE <size>;
        
  2. Restore from backup and recover: Use backups and archived redo logs to perform media recovery.

Conclusion The statements about considering the type of media failure and the status of the redo log (current, active, or inactive) are fully relevant to Oracle 19c. The use of `ALTER DATABASE CLEAR LOGFILE` with options like `UNARCHIVED` and `UNRECOVERABLE DATAFILE` is still applicable, but care must be taken to ensure data recoverability, especially in `ARCHIVELOG` mode. Modern Oracle features, such as redo log multiplexing and ADR diagnostics, further mitigate these issues in Oracle 19c.
The
ALTER DATABASE CLEAR LOGFILE GROUP 

command drops the corrupted online redo file and recreates it without shutting down the database.
  1. Advantages of ALTER DATABASE CLEAR LOGFILE command: The ALTER DATABASE CLEAR LOGFILE command can be used in several situations. It is applicable even if there are only two online redo log groups (the minimum needed to keep your database operating). If the corrupt redo log file belongs to the current group, you can still use the command.
  2. Disadvantages of ALTER DATABASE CLEAR LOGFILE command: However, you can't use the ALTER DATABASE CLEAR LOGFILE command across the board. If the online redo log file is not archived before it is cleared with this command, a complete recovery of the database becomes impossible. You can only recover the database up to the time before this damaged online redo log is needed. So, use the command with the UNARCHIVED option very carefully. Performing a whole database backup after the command is issued, including the control file, is highly recommended. You also should not use this command to clear an online redo log file that is required for media ecovery.

Corrupted online redo logs for offline Datafiles

If you have an offline datafile and it requires the damaged, unarchived online redo log for recovery, you can still use the
ALTER DATABASE CLEAR LOGFILE GROUP <grour_number> 
UNRECOVERABLE DATAFILE;

command to clear the corrupted online redo log file. Be aware that the offline datafile needing this redo log for recovery becomes unusable after this command is issued. For this procedure to be successful, you have to drop the datafile and its tablespace from the database. To avoid losing the datafile and its tablespace:
  1. Bring the offline datafile online
  2. Restore all the datafiles, and
  3. Perform an incomplete recovery prior to the corrupted redo log file
Either way, it is strongly recommended that you make a backup of the database in case future recovery is necessary.
The next lesson explains how to recover a database with inactive redo logs.

SEMrush Software