The most crucial structure for recovery operations is the Managing the Redo Log - Oracle DBA, which consists of two or more preallocated files that store all changes made to the database as they occur. Every instance of an Oracle Database has an associated redo log to protect the database in case of an instance failure.
The current redo log is always online, unlike archived copies of a redo log. Therefore, the online redo log is usually referred to as simply the redo log.
This section describes some of the more common redo log management tasks. It contains the following topics:
If you would like to Enrich your career with a Database Administrator(DBA) and get Oracle certified professional, then visit Mindmajix - A Global online training platform: “Oracle DBA Online Course” Course. This course will help you to achieve excellence in this domain. |
You can create groups and members of online redo log files during or after database creation. To create new online redo log groups and members, you must have the ALTER DATABASE system privilege.
The database log writer process (lgwr) writes redo records from the memory buffer to a redo log group until the log files in that group reach their storage size limit, or until you request a log switch operation. The lgwr process then writes to the next log group. The lgwr process performs this action in a circular fashion so that the oldest group is overwritten by the most recent redo records.
Multiplexing provides better protection for data in the case of instance or media failure. To protect against a failure involving the redo log itself, Oracle Database allows a multiplexed redo log, meaning that two or more identical copies of the redo log can be automatically maintained in separate locations.
To multiplex your redo log, you must add members to each redo log group. It is not required that redo log groups be symmetrical, but Oracle recommends that your groups all have the same number of members. A database must have a minimum of two redo log groups.
Related Article: Undo Retention In DBA - Oracle DBA |
The online redo log of a database instance should consist of multiplexed groups of online redo log files as shown below:
In the above figure, a_log1 and b_log1 are both members of group 1, a_log2, and b_log2 are both members of group 2, and so forth. Each member of a group must be exactly the same size.
Each member of a log file group is concurrently active—that is, concurrently written to by lgwr—as indicated by the identical log sequence numbers assigned by lgwr. In the figure, the first lgwr writes concurrently to both a_log1 and b_log1. Then it writes concurrently to both a_log2 and b_log2, and so on. Lgwr never writes concurrently to members of different groups (for example, to a_log1 and b_log2).
Related Article: Oracle DBA Interview Questions |
To multiplex the redo logs, first, we must identify how many groups and members exist.
Sql> select group#, member from v$logfile order by group#, member;
The above query helps to find out the existing groups and members' information.
For example, if your existing member filename is redo01.log and belongs to group1, then you might name this member as redo01a.log.
Sql> alter database add logfile member ‘/u02/app/oracle/oradata/redo01a.log’ to group1;
You can create ‘/u02/app/oracle/oradata/redo01a.log’ file in the same directory, but it is recommended that you store members on separate disk drives. That way, if there is a drive failure, you still have access to one member.
Related Article: Oracle Performance Tuning Interview Questions |
Switching a log file:
A log switch occurs when LGWR stops writing to one redo log group and starts writing to another. By default, a log switch occurs automatically when the current redo log file group fills.
The below query is helpful to know the status of the groups.
Sql> select * from v$log;
When a log switch occurs, the log writer (lgwr) process stops writing to the current redo log group and starts writing to the next available redo log group. You can force a log switch to make the current redo group inactive and available for redo log maintenance operations. For example, you might want to drop the current redo group but are not able to do so until the group is inactive. You may also want to force a log switch if the current redo group needs to be archived at a specific time before the members of the group are completely filled. This option is useful in configurations with large redo log files that take a long time to fill.
Sql> alter system switch logfile;
The status of the current group changes to active and the status of the next group in the list changes from inactive to current.
Online redo log files may be moved while the database is shutdown. Once renamed (or moved), the DBA should use the ALTER DATABASE command to update the data dictionary.
Although it is possible to indirectly move online redo log files by dropping entire redo log groups and re-adding the groups in a different location, this solution will not work if there are only two redo log groups because a database will not open with only one redo log filegroup. Temporarily adding a third group and dropping the first or second group is an option if the database must be kept open; alternatively, the method shown here will move the redo log file(s) while the database is shutdown.
In the following example, we have three redo log file groups with two members each. One member of each group is on the same volume as the oracle software and should be moved to a different volume to eliminate any connection between log file filling and accessing oracle software components. The method you will use here with alter database command.
Related Article: Oracle DBA Tutorial for Beginners |
Example:
Sql> select group#, member from v$logfile order by group#, member;
Group# member
——– ———–
1 /u01/app/oracle/oradata/redo01.log
1 /u05/oradata/redo01.log
2 /u01/app/oracle/oradata/redo02.log
2 /u05/oradata/redo02.log
3 /u01/app/oracle/oradata/redo03.log
3 /u05/oradata/redo03.log
6 rows selected
Sql> shutdown immediate;
Database closed.
Database dismounted.
Oracle instance shut down.
Sql> ! Mv /u01/app/oracle/oradata/redo0[1-3]/log /u04/oradata
Sql>startup mount
Sql>alter database rename file ‘/u01/app/oracle/oradata/redo01.log’ to ‘/u04/oradata/redo01.log’;
Database altered.
Sql> alter database rename file ‘/u01/app/oracle/oradata/redo02.log’ to ‘/u04/oradata/redo02.log’;
Database altered.
Sql> alter database rename file ‘/u01/app/oracle/oradata/redo03.log’ to ‘/u04/oradata/redo03.log’;
Database altered.
Sql> alter database open;
Database altered.
Now, we can check out the location of the log files from the following query.
Sql> select group#, member from v$logfile order by group#, member;
Group# member
——– ———–
1 /u04/oradata/redo01.log
1 /u05/oradata/redo01.log
2 /u04/oradata/redo02.log
2 /u05/oradata/redo02.log
3 /u04/oradata/redo03.log
3 /u05/oradata/redo03.log
6 rows selected
The i/o for the redo log files no longer contends with the oracle software; in addition, the redo log files are multiplexed between two different mount points, /u04 and /u05.
Sql>alter database add logfile group 4 ‘/u01/app/oracle/oradata/redo03.log’ size 10m;
Related Article: Granting Roles And Privileges In Oracle DBA |
Dropping the existing redo log groups:
Sql>alter database drop logfile group 4; /* (to drop a entire group) */
Sql>alter database drop logfile member ‘/u01/app/oracle/oradata/redo03.log’;
/* (to drop a particular member) */
Note:
To drop an online redo log group, consider the following points:
Sql>alter system switch logfile;
To drop a member consider the following points:
You can configure the database to use checksums to verify blocks in the redo log files. If you set the initialization parameter db_block_checksum to typical (the default), the database computes a checksum for each database block when it is written to disk, including each redo log block as it is being written to the current log. The checksum is stored in the header of the block.
Oracle database uses the checksum to detect corruption in a redo log block. The database verifies the redo log block when the block is read from an archived log during recovery and when it writes the block to an archive log file. An error is raised and written to the alert log if corruption is detected.
If corruption is detected in a redo log block while trying to archive it, the system attempts to read the block from another member in the group. If the block is corrupted in all members of the redo log group, then archiving cannot proceed.
The value of the db_block_checksum parameter can be changed dynamically using the alter system statement.
Explore Oracle DBA Sample Resumes! Download & Edit, Get Noticed by Top Employers! |
Normally we need to clear the redo log if it's corrupted and oracle is not able to reuse it. It may already be archived or may not be. In both cases, we need to clear it to allow oracle instance to re-use it.
A redo log file might become corrupted while the database is open, and ultimately stop database activity because archiving cannot continue. In this situation, the alter database clear logfile statement can be used to reinitialize the file without shutting down the database.
The following statement clears the log files in redo log group number 3:
Sql>alter database clear logfile group 3;
This statement overcomes two situations where a dropping redo log is not possible:
If the corrupt redo log file has not been archived, use the unarchived keyword in the statement.
Sql>alter database clear unarchived logfile group 3;
This statement clears the corrupted redo logs and avoids archiving them. The cleared redo logs are available for use even though they were not archived.
If you clear a log file that is needed for the recovery of a backup, then you can no longer recover from that backup. The database writes a message in the alert log describing the backups from which you cannot recover.
If you want to clear an unarchived redo log that is needed to bring an offline tablespace to online, use the unrecoverable datafile clause in the alter database clear logfile statement.
If you clear a redo log needed to bring an offline tablespace online, you will not be able to bring the tablespace online again. You will have to drop the tablespace or perform an incomplete recovery. Note that tablespaces taken offline normally do not require recovery.
Data dictionary views:
Central set of read-only reference tables and views of each Oracle database, known collectively as the data dictionary.
The following views provide information on redo logs.
View | Description |
V$log | Displays the redo log file information from the control file |
V$logfile | Identifies redo log groups and members and member status |
V$log_history | Contains log history information |
The following query returns the control file information about the redo log for a database.
Select * from v$log;
Group# thread# seq bytes members arc status first_change# first_tim
——- —— —— —– ———- —– —— ————-
1 1 10605 1048576 1 yes active 11515628 16-apr-00
2 1 10606 1048576 1 no current 11517595 16-apr-00
3 1 10603 1048576 1 yes inactive 11511666 16-apr-00
4 1 10604 1048576 1 yes inactive 11513647 16-apr-00
To see the names of all of the member of a group, use a query similar to the following:
Select * from v$logfile;
Group# status member
———- ————————–
1 /u01/app/oracle/oradata/redo01.log
2 /u02/oradata/redo02.log
3 /u03/oradata/redo03.log
4 /u04/oradata/redo04.log
If the status is blank for a member, then the file is in use.
Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:
Name | Dates | |
---|---|---|
Oracle DBA Training | Dec 24 to Jan 08 | View Details |
Oracle DBA Training | Dec 28 to Jan 12 | View Details |
Oracle DBA Training | Dec 31 to Jan 15 | View Details |
Oracle DBA Training | Jan 04 to Jan 19 | View Details |
Ravindra Savaram is a Technical Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.