Redo logs are also called online redo logs. The purpose of introducing redo logs is data recovery. As the database runs, the data that the user changes is temporarily stored in the database's buffer zone. In order to improve the speed of writing data, it is not necessary to write the changed data to the data file once the data is changed. Frequent reading and writing of disk files can reduce the efficiency of the database system, so the DBWR process will write the changed data to the data file until the data in the database buffer zone reaches a certain amount or satisfies certain conditions. In this case, the data in the data cache will be lost if there is an outage before DBWR writes the changed changes to the data file. It is obviously not possible to recover data changed by this part of the user after the database restarts.
Redo the log is to change the data first save, wherein the LGWR process is responsible for the user changed data written to the redo log file, so that when the database starts, the database system from the Redo log files read the changed data, the user changed data submitted to the database, write data files.
To improve disk efficiency and prevent the corruption of redo log files, Oracle uses a special redo log file structure consisting of 3 redo log groups, each containing two redo log group members, which stops writing when the first log group is full, writes to the second log group, and the second log group is full. Write to the second log group, the third log group is full, and the first log group is written, and Oracle uses the Redo log group in this circular manner.
Oracle requires at least two log groups per database, with at least one or more log members per group. Oracle loops use the Redo log group to switch to another redo log group that it can find when a redo log group is fully written. Before using the new Redo log group, the DBWR process needs to write all of the data changes to the data file. If the database is in archive mode, when a log switch occurs, the archive process (ARCH) copies the data from the currently full redo log file to the archive log.
The purpose of designing multiple log members is to provide backup in a timely manner after a log file in the log group is corrupted, so the same group of log members generally has the same content information, but the storage location is different.
Read Redo log file information
The data dictionary view V$log records the log group ordinal of the current database, the log sequence number, the size of each log file, the number of members per log group, and the current status of the log group.
Using V$log to view redo log information
The output has three log groups with one log file per log group. Log Group 2 is the Redo log group currently in use, called the current day group, the current log file has not been archived, and the other inactive redo log files have been archived.
The data dictionary v$logfile records the current log group number, the status of the log group, the type, and the log group membership information.
Use V$logfile to view redo log Group information
Where the status parameter has the following meanings:
Blank: This file is in use.
Stale: The contents of this file are incomplete
Invalid: The file cannot be accessed, such as a newly created
Deleted: The file is no longer useful
As you can see from the above output, there are 3 redo log groups in the database, and 1 redo log files per log group.
Redo log groups and their member management
To create a redo log group:
There are too few Oracle database log groups that can cause log files to switch frequently and affect system performance, so it is sometimes necessary to add new log groups. If there is only one log member in the log group, you need to add a new log member to avoid corruption.
Using V$log to view redo log information
Use V$logfile to view redo log Group information
How to create a redo log group:
Delete Redo Log Group
Add Delete redo log file
It is found that the newly added log file Redo33.log is invalid, the log member of three log group is not full, so redo33.log is invalid state, as long as two times forced log switch can be found online status
Delete Redo log files
To the operating system log file directory to see if Redo33.log is still present
View redo log information, GROUP3 is the current log group
Delete log file Redo33.log in log Group 3, you will find that the log files in the current log group are not deleted
After you force the log switch, you can delete the newly added log files.
The following restrictions apply to deleting redo log files
? You cannot delete a member of the current group to delete a command that performs a mandatory switchover redo log first: alter SYSTEM switch logfile
? Activity log members cannot be deleted
? Log members that are not archived cannot be deleted
? Only one member of the current log group is or cannot be deleted
Log group switchover and checkpoint events
Log switchover is to stop writing the current log group and move to another new log group. The system can be switched automatically or manually. When a log switchover occurs, the system completes the checkpoint in the background to reduce the recovery time of the instance.
A checkpoint is an event that is used to reduce the time that an instance recovers. When the checkpoint occurs, it starts the DBWR process, writes the changed data in the data buffer area to the data file, while the checkpoint process updates the control file and data file header to ensure data consistency. The checkpoint is actually a background process that guarantees that all modified database buffers are written to the data file.
The more frequent the checkpoint event, the less data in the redo log that requires data recovery (since the data in the redo log before the recovery checkpoint does not have to be checked when recovering), as soon as the database fails, reducing the recovery time of the instance.
Forces a log switchover and forces a checkpoint event to occur.
Force Log Switchover
Forcing a checkpoint event to occur
If you have any questions about this article, please add the following discussion
Oracle 11g Management Redo log files