What Is the Redo Log?什么是重做日志?

前端之家收集整理的这篇文章主要介绍了What Is the Redo Log?什么是重做日志?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Oracle官方原文:查看原文

The most crucial structure for recovery operations is theredo log,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.

在恢复操作中最关键的结构是重做日志,由两个或两个以上的预分配的文件存储到数据库发生变化。Oracle数据库的每一个实例都有相关的重做日志,以便在实例失败时保护数据库

Redo Threads

重做线程

When speaking in the context of multiple database instances,the redo log for each database instance is also referred to as aredo thread. In typical configurations,only one database instance accesses an Oracle Database,so only one thread is present. In an Oracle Real Application Clusters environment,however,two or more instances concurrently access a single database and each instance has its own thread of redo. A separate redo thread for each instance avoids contention for a single set of redo log files,thereby eliminating a potential performance bottleneck.

当讨论多个数据库实例的上下关系时,每个数据库实例的重做日志也称为重做线程。 在典型配置中,只有一个数据库实例访问Oracle数据库,因此只存在一个线程。 然而,在Oracle Real Application Clusters环境中,两个或多个实例并发访问单个数据库,每个实例都有自己的重做线程。 每个实例的单独重做线程避免了对单个重做日志文件的争用,从而消除潜在的性能瓶颈。

This chapter describes how to configure and manage the redo log on a standard single-instance Oracle Database. The thread number can be assumed to be 1 in all discussions and examples of statements. For information about redo log groups in an Oracle Real Application Clusters environment,please refer toOracle Real Application Clusters Administration and Deployment Guide.

本章介绍如何在标准单实例Oracle数据库上配置和管理重做日志。 在所有讨论和语句示例中,线程数可以假定为1。 有关Oracle Real Application Clusters环境中重做日志组的信息,请参阅“Oracle Real Application Clusters管理和部署指南”。

Redo Log Contents
重做日志内容

Redo log files are filled withredo records. A redo record,also called aredo entry,is made up of a group ofchange vectors,each of which is a description of a change made to a single block in the database. For example,if you change a salary value in an employee table,you generate a redo record containing change vectors that describe changes to the data segment block for the table,the undo segment data block,and the transaction table of the undo segments.

重做日志文件用重做记录填充。 重做记录(也称为重做条目)由一组改变向量组成,每个改变向量是对数据库中的单个块所作的改变的描述。 例如,如果更改employee表中的salary值,则生成包含更改向量的重做记录,这些更改向量描述对表的数据段块,undo段数据块和undo段的事务表的更改。

Redo entries record data that you can use to reconstruct all changes made to the database,including the undo segments. Therefore,the redo log also protects rollback data. When you recover the database using redo data,the database reads the change vectors in the redo records and applies the changes to the relevant blocks.

重做条目记录可用于重建对数据库所做的所有更改(包括恢复段)的数据。 因此,重做日志还保护回滚数据。 使用重做数据恢复数据库时,数据库读取重做记录中的更改向量,并将更改应用于相关块。

Redo records are buffered in a circular fashion in the redo log buffer of the SGA (see"How Oracle Database Writes to the Redo Log") and are written to one of the redo log files by the Log Writer (LGWR) database background process. Whenever a transaction is committed,LGWR writes the transaction redo records from the redo log buffer of the SGA to a redo log file,and assigns asystem change number(SCN) to identify the redo records for each committed transaction. Only when all redo records associated with a given transaction are safely on disk in the online logs is the user process notified that the transaction has been committed.

重做记录以循环方式在SGA的重做日志缓冲区中缓冲(请参见“如何将Oracle数据库写入重做日志”),并通过日志写入程序(LGWR)数据库后台进程将其写入其中一个重做日志文件。 无论何时提交事务,LGWR都会将事务重做记录从SGA的重做日志缓冲区写入重做日志文件,并分配系统更改编号(SCN)以标识每个已提交事务的重做记录。 只有当在联机日志中与给定事务相关联的所有重做记录安全在磁盘上时,用户进程才会通知该事务已提交。

Redo records can also be written to a redo log file before the corresponding transaction is committed. If the redo log buffer fills,or another transaction commits,LGWR flushes all of the redo log entries in the redo log buffer to a redo log file,even though some redo records may not be committed. If necessary,the database can roll back these changes.

还可以在提交相应的事务之前将重做记录写入重做日志文件。 如果重做日志缓冲区填满或另一个事务提交,LGWR将重做日志缓冲区中的所有重做日志条目刷新为重做日志文件,即使可能无法提交某些重做记录。 如果需要,数据库可以回滚这些更改。

How Oracle Database Writes to the Redo Log

Oracle数据库如何写入重做日志

The redo log of a database consists of two or more redo log files. The database requires a minimum of two files to guarantee that one is always available for writing while the other is being archived (if the database is inARCHIVELOGmode). See"Managing Archived Redo Logs"for more information.

数据库的重做日志由两个或多个重做日志文件组成。 数据库至少需要两个文件,以确保一个总是可用于写入,而另一个正在归档(如果数据库处于ARCHIVELOG模式)。 有关详细信息,请参见“管理归档重做日志”。

LGWR writes to redo log files in a circular fashion. When the current redo log file fills,LGWR begins writing to the next available redo log file. When the last available redo log file is filled,LGWR returns to the first redo log file and writes to it,starting the cycle again.Figure 10-1illustrates the circular writing of the redo log file. The numbers next to each line indicate the sequence in which LGWR writes to each redo log file.

LGWR以循环方式写入重做日志文件。 当当前重做日志文件填满时,LGWR开始写入下一个可用的重做日志文件。 当最后一个可用的重做日志文件被填满时,LGWR返回到第一个重做日志文件并写入它,再次开始循环。 图10-1说明了重做日志文件的循环写入。 每行旁边的数字表示LGWR写入每个重做日志文件的顺序。

Filled redo log files are available to LGWR for reuse depending on whether archiving is enabled.

被填充的重做日志文件能否供LGWR重用取决于是否启用存档。

  • If archiving is disabled (the database is inNOARCHIVELOGmode),a filled redo log file is available after the changes recorded in it have been written to the datafiles.

  • 如果禁用归档(数据库处于NOARCHIVELOG模式),则填充的重做日志文件在其中记录的更改已写入数据文件后即可用。


  • If archiving is enabled (the database is inARCHIVELOGmode),a filled redo log file is available to LGWR after the changes recorded in it have been written to the datafilesandthe file has been archived.

  • 如果启用归档(数据库处于ARCHIVELOG模式),则在LGWR中记录的更改已写入数据文件并且文件已归档之后,已填充的重做日志文件才可用。


Figure 10-1 Reuse of Redo Log Files by LGWR

图10-1 LGWR重做日志文件的重用


Description of "Figure 10-1 Reuse of Redo Log Files by LGWR"
“图10-1 LGWR重用重做日志文件的重用”

Active (Current) and Inactive Redo Log Files

活动(当前)和非活动重做日志文件

Oracle Database uses only one redo log files at a time to store redo records written from the redo log buffer. The redo log file that LGWR is actively writing to is called thecurrentredo log file.

Oracle数据库一次只使用一个重做日志文件来存储从重做日志缓冲区写入的重做记录。 LGWR正在写入的重做日志文件称为当前重做日志文件

Redo log files that are required for instance recovery are calledactiveredo log files. Redo log files that are no longer required for instance recovery are calledinactiveredo log files.

实例恢复所需的重做日志文件称为活动重做日志文件。 实例恢复不再需要的重做日志文件称为非活动重做日志文件

If you have enabled archiving (the database is inn) has archived its contents. If archiving is disabled (the database is in 如果已启用归档(数据库处于ARCHIVELOG模式),则数据库无法重复使用或覆盖活动的联机日志文件,直到其中一个归档器后台进程(ARCn)归档其内容为止。 如果禁用归档(数据库处于NOARCHIVELOG模式),则当最后重做日志文件已满时,LGWR将继续覆盖第一个可用的活动文件

Log Switches and Log Sequence Numbers
日志切换和日志序列号

Alog switchis the point at which the database stops writing to one redo log file and begins writing to another. Normally,a log switch occurs when the current redo log file is completely filled and writing must continue to the next redo log file. However,you can configure log switches to occur at regular intervals,regardless of whether the current redo log file is completely filled. You can also force log switches manually.

日志切换是数据库停止写入一个重做日志文件并开始写入另一个重做日志文件的点。 通常,当当前重做日志文件完全填充并且写入必须继续到下一个重做日志文件时,将发生日志切换。 但是,无论当前重做日志文件是否已完全填充,您都可以将日志开关配置为定期进行。 您也可以手动强制日志开关。

Oracle Database assigns each redo log file a newlog sequence numberevery time a log switch occurs and LGWR begins writing to it. When the database archives redo log files,the archived log retains its log sequence number. A redo log file that is cycled back for use is given the next available log sequence number.

每当发生日志切换并且LGWR开始对其写入时,Oracle数据库会为每个重做日志文件分配一个新的日志序列号。 当数据库归档重做日志文件时,归档日志保留其日志序列号。 将循环使用的重做日志文件将提供下一个可用的日志序列号。

Each online or archived redo log file is uniquely identified by its log sequence number. During crash,instance,or media recovery,the database properly applies redo log files in ascending order by using the log sequence number of the necessary archived and redo log files.

每个联机或归档的重做日志文件由其日志序列号唯一标识。 在崩溃,实例或介质恢复期间,数据库通过使用必需的归档日志文件和重做日志文件的日志序列号,以升序顺序正确应用重做日志文件

原文链接:https://www.f2er.com/oracle/210031.html

猜你在找的Oracle相关文章