OverviewoftheOnlineRedoLog --- online redo log Overview

Source: Internet
Author: User
For oracle restoration, the most important data structure is onlineredolog (online redo log). Online redo log contains at least two pre-allocated files used to store database changes. Online redo logs record changes in data files. What is the role of OnlineRedoLog? Oracle database ensures that log files are redone online

For oracle restoration, the most important data structure is the online redo log (online redo log). The online redo log contains at least two pre-allocated files used to store database changes. Online redo logs record changes in data files. What is the role of Online Redo Log? Oracle database ensures that Log files are redone Online.

For oracle restoration, the most important data structure is the online redo log (online redo log). The online redo log contains at least two pre-allocated files used to store database changes. Online redo logs record changes in data files.
What is the function of Online Redo Log?


Oracle databases redo log files online to prevent data loss. In particular, when an instance fails, the oracle database can restore the data that has been submitted but not yet written to the data file through online redo log files.
The Oracle database first writes each transaction to the redo log buffer and then to the online redo log file. The log content includes uncommitted transactions, undo data, and schema object management declarations.
Oracle databases use online redo logs only [this article comes from Internet (http://www.68idc.cn)] for recovery only. The database administrator can also use the LogMiner tool to query online redo logs. Online redo log files are a useful source of information that reflects the database history.




How to write Online Redo logs in Oracle databases


Online redo logs of database instances are also called redo threads. In a single-instance environment, only one instance accesses the database, so only one redo thread is running. In the Oracle RAC environment, two or more instances access the database concurrently. Each database instance has a redo thread. Each instance has a separate redo thread to avoid competition for unique online redo log files.
Online redo logs generally contain two or more log files. The Oracle database must contain at least two log files to ensure that one pair is available for writing, and the other is used for archiving (if the database runs in archive mode ).




Online Redo Log Switching


Oracle Database uses only one online redo log file at a time to store records written from the redo log buffer. The online redo log file to which Log writer (LGWR)Process is actively writing is called CurrentOnline redo log file.


Oracle databases can only use one online redo log file to store data in the redo log buffer at a time. The online redo log file being written by the LGWR process is called the current online redo log file.


A Log switchOccurs when the database stops writing to one online redo log file and begins writing to another. normally, a switch occurs when the current online redo log file is full and writing must continue. however, you can configure log switches to occur at regular intervals, regardless of whether the current online redo log file is filled, and force logs witches manually.


Log switching occurs when the database stops redoing log files online and starts writing logs to another log file. Generally, when the current online redo log file is full and must be written again, log switching will occur. Then, you can set log switching to happen on a regular basis, regardless of whether the current online redo log file is full or not, Force manual log switching.


Log writer writes to online redo log files circularly. when log writer fills the last available online redo log file, the process writes to the first log file, restarting the cycle. figure 11-6 analyze strates the circular writing of the redo log.


LGWR cyclically writes online redo log files. When LGWR is full of the Last Online redo log file, the process will re-write new data to the first log file.


Figure 11-6 Reuse of Online Redo Log Files





The numbers in Figure 11-6 shows the sequence in which LGWR writes to each online redo log file. The database assigns each file a new Log sequence numberWhen a log switches and log writers begins writing to it. When the database reuses an online redo log file, this file has es the next available log sequence number.
Filled online redo log files are available for reuse depending on the archiving mode:
If archiving is disabled, which means that the database is in NOARCHIVELOGMode, then a filled online redo log file is available after the changes recorded in it have been Checkpointed(Written) to disk Database writer (DBW).
If archiving is enabled, which means that the database is in ARCHIVELOG mode, Then a filled online redo log file is available to log writer after the changes have been written to the data files AndThe file has been archived.

Whether the online redo log files that have been filled with logs can be reused depends on whether they are in archive mode:

If it is not in archive mode, when the changes in the online redo log file have been written to the disk by the DBW process, the online redo log files that have been filled up can be reused;

In archive mode, when the changes in the online redo log file have been written to the data file and the file has been archived, the filled online redo log file can be reused;

In some circumstances, log writer may be prevented from reusing an existing online redo log file. For example, an online redo log file may beActive(Required for instance recovery) ratherInactive(Not required for instance recovery). Also, an online redo log file may be in the process of being cleared.

Online Redo Log Files multiple backups

Oracle Database can automatically maintain two or more identical copies of the online redo log in separate locations.Online redo log groupConsists of an online redo log file and its redundant copies. Each identical copy isMemberOf the online redo log group. Each group is defined by a number, such as group 1, group 2, and so on.

The Oracle database can automatically manage the same backup set of online redo log files in two or more different locations. An online redo log file group contains an online redo log file and its redundant backup. Each identical backup is a member of the online redo log file group. Each group is defined by numbers, such as group 1 and group 2.

Maintaining multiple members of an online redo log group protects against the loss of the redo log. ideally, the locations of the members shocould be on separate disks so that the failure of one disk does not cause the loss of the entire online redo log.

Multiple members of the online redo log file group are saved to ensure that the redo log is not lost. Theoretically, members of the log file group should be stored in different locations on the disk, so that even if a disk is damaged, the entire online redo log file will not be lost.

In Figure 11-7,A_LOG1AndB _LOG1Are identical members of group 1, whileA_LOG2AndB _LOG2Are identical members of group 2. Each member in a group must be the same size. LGWR writes concurrently to group 1 (membersA_LOG1AndB _LOG1), Then writes concurrently to group2 (membersA_LOG2AndB _LOG2), Then writes to group 1, and so on. LGWR never writes concurrently to members of different groups.

In Figure 11-7, A_LOG1 and B _LOG1 are the same members in group 1, while A_LOG2 and B _LOG2 are the same members in group 2. Members in each group must be of the same size. The background process LGWR concurrently writes data to group 1, then concurrently writes data to group 2, and then concurrently writes data to group 1. LGWR never writes data concurrently to different groups.

Figure 11-7 Multiple Copies of Online Redo Log Files


Note:

Oracle recommends that you multiplex the online redo log. the loss of log files can be catastrophic if recovery is required. when you multiplex the online redo log, the database must increase the amount of I/O it performs. depending on your system, this additional I/O may impact overall database performance.

Oracle recommends retaining multiple online redo log files. The loss of log files will be fatal for restoration. However, when you retain multiple online redo logs, the database must increase the number of I/O executions. Whether this extra I/O will affect the overall performance of the database depends on your system.

Archived Redo Log Files (archive and Redo Log Files)

Archive log files are backups of online redo log files and are not considered part of the database, however, archive log files are offline backups of online redo log files created by the database and can be written to the specified location.

Archive log files are an important part of the recovery policy. You can use archive log files:

Recover a database backup (Recover database)
Update Standby database(Update backup database)
Obtain information about the history of a database using the LogMiner utility (Obtain historical database information through logminer)

Archiving is an operation to generate archive log files. Archiving is only effective when the database runs in archive log mode and can be automatically or manually.

An archived redo log file contains des the redo entries and the log sequence number of the identical member of the online redo log group. In Figure 11-7, filesA_LOG1AndB _LOG1Are identical members of Group 1. If the database is inARCHIVELOGMode, and if automatic archiving is enabled, thenArchiver process (ARCn)Will archive one of these files. IfA_LOG1Is already upted, then the process can archiveB _LOG1. The archived redo log contains a copy of every group created since you enabled archiving.

An archive log file contains the same log serial number as the redo entries (redo entry) and online redo log file group. In Figure 11-7, the files A_LOG1 and B _LOG1 are the same members of Group 1. If the database runs in archive log mode and automatic archiving is enabled, the archive process (ARCn) archives one of them. If A_LOG1 is corrupted, the archiving process can archive B _LOG1. If archiving is enabled, archived redo log files include backups of each online redo log file group.

Online Redo Log structure

Online redo logs contain manyRedo records (Redo record)A redo record is composed of a group of change vectors, each of which describes the modification to a data block. For example, modifying salary in the employees table generates a redo record to describe the changes in the data segment of the table, the transaction table of the undo data block and the undo segment.

Redo records contain all the related basic metadata of changes, as shown in the following code:

SCN and timestamp at the time of change
ID of the transaction that generates this change
The SCN and timestamp submitted by the transaction (if committed)
Change Operation Type
Name and type of the modified data segment

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.