0

0

OverviewoftheOnlineRedoLog---在线重做日志概述

php中文网

php中文网

发布时间:2016-06-07 16:13:15

|

1347人浏览过

|

来源于php中文网

原创

对于 oracle 恢复来说最重要的数据结构莫过于online redo log(在线重做日志), 在线重做日志包含至少两个预先分配好的,用来存储数据库变化的文件。在线重做日志记录着数据文件中的变化。 Online Redo Log有什么作用 Oracle 数据库通过在线重做日志文件来确保

对于 oracle 恢复来说最重要的数据结构莫过于online redo log(在线重做日志), 在线重做日志包含至少两个预先分配好的,用来存储数据库变化的文件。在线重做日志记录着数据文件中的变化。
Online Redo Log有什么作用


Oracle 数据库通过在线重做日志文件来确保数据不丢失。特别是当实例失败后, oracle数据库可以通过在线重做日志文件恢复已经提交但尚未写到数据文件中的数据。
Oracle 数据库把每个事务先同步写到 redo log buffer,然后再写到在线重做日志文件中。日志的内容包括未提交的事务,undo数据,模式对象管理声明。
Oracle 数据库使用在线重做日志仅【本文来自鸿网互联 (http://www.68idc.cn)】仅用于恢复。数据库管理员也可以使用 LogMiner这个工具来查询在线重做日志。在线重做日志文件是一个有用的反映数据库历史的信息源。




Oracle数据库怎样写 Online Redo Log


数据库实例的在线重做日志通常也被称为 redo线程。在单实例的环境中,仅仅只有一个实例访问数据库,因此只有一个 redo线程正在运行。而在 Oracle RAC环境中,通常有两个或者两个以上的实例并发的访问数据库,每个数据库实例拥有一个redo线程。每个实例拥有单独的redo线程是为了避免对唯一的在线重做日志文件的竞争。
在线重做日志一般包含两个或者两个以上的日志文件。Oracle数据库要求至少包含两个日志文件来保证其中一个对写可用,而另外一个用来归档(如果数据库运行在归档模式下)。




Online Redo Log切换


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 the log writer (LGWR) process is actively writing is called the current online redo log file.


Oracle 数据库同一时间只能使用一个在线重做日志文件来存储 redo log buffer 中的数据。LGWR进程正在写的在线重做日志文件称为当前的在线重做日志文件。


A log switch occurs 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 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 illustrates the circular writing of the redo log.


LGWR 循环的写在线重做日志文件。当 LGWR 写满了最后一个在线重做日志文件,这个进程会重新往第一个日志文件中写新的数据。


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 number when a log switches and log writers begins writing to it. When the database reuses an online redo log file, this file receives 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 NOARCHIVELOG mode, then a filled online redo log file is available after the changes recorded in it have been checkpointed (written) to disk by 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 and the file has been archived.

已经填充满的在线重做日志文件是否可以重用取决于是否是在归档模式下:

如果不是在归档模式下,当在线重做日志文件中的变化的记录已经被 DBW 进程写到了磁盘上之后,已经填充满的在线重做日志文件可以重用;

如果是在归档模式下,当在线重做日志文件中变化的记录已经写到数据文件中并且文件已经归档后,已经填充满的在线重做日志文件可以重用;

 

In some circumstances, log writer may be prevented from reusing an existing online redo log file. For example, an online redo log file may be active (required for instance recovery) rather than inactive (not required for instance recovery). Also, an online redo log file may be in the process of being cleared.

 

 

Online Redo Log Files多个备份

 

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

 

Oracle 数据库能够自动管理两个或者多个不同位置的在线重做日志文件的相同备份集。一个在线重做日志文件组包含一个在线重做日志文件和它的冗余备份。每个完全相同的备份是在线重做日志文件组中的一个成员。每个组用数字来定义,例如 group 1, 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 should be on separate disks so that the failure of one disk does not cause the loss of the entire online redo log.

 

保存在线重做日志文件组的多个成员来保证重做日志不丢失。理论上说,日志文件组的成员的存放位置应该放在磁盘上的不同位置,这样即使一个磁盘损坏也不会导致整个在线重做日志文件丢失。

 

In Figure 11-7, A_LOG1 and B_LOG1 are identical members of group 1, while A_LOG2 and B_LOG2 are identical members of group 2. Each member in a group must be the same size. LGWR writes concurrently to group 1(members A_LOG1 and B_LOG1), then writes concurrently to group2 (members A_LOG2 and B_LOG2), then writes to group 1, and so on. LGWR never writes concurrently to members of different groups.

 

在图 11-7 中,A_LOG1 和 B_LOG1 是 group 1 中的相同的成员,而 A_LOG2 和 B_LOG2 是 group 2中的相同的成员。每个组中的成员必须大小一致。后台进程 LGWR 并发的写数据到 group 1,然后并发的写数据到 group 2,然后再并发的写数据到 group 1. LGWR 从不会并发写数据到不同的组。

 

Figure 11-7 Multiple Copies of Online Redo Log Files

 

\
 

注意:

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 推荐保留多份在线重做日志文件。日志文件的丢失对于恢复来说将是致命的。但是当你保留多份在线重做日志时,数据库必须增加执行 I/O 的数量。这种额外的 I/O 是否会影响数据库的整体性能取决于你的系统。

 

Archived Redo Log Files(归档重做日志文件)

 

归档日志文件是在线重做日志文件的一个备份,也不认为是数据库的一部分,但是归档日志文件是数据库创建的在线重做日志文件的离线备份并且可以写到指定的位置。

归档日志文件是和恢复策略中非常重要的部分,你可以使用归档日志文件用来:

Recover a database backup (恢复数据库)
Update a standby database (更新备用数据库)
Obtain information about the history of a database using the LogMiner utility (通过logminer获取数据库的历史信息)

归档是产生归档日志文件的一个操作,归档这个操作只有在数据库运行在归档日志模式才有效,可以自动也可以手动

 

An archived redo log file includes the redo entries and the log sequence number of the identical member of the online redo log group. In Figure 11-7, files A_LOG1 and B_LOG1 are identical members of Group 1. If the database is in ARCHIVELOG mode, and if automatic archiving is enabled, then the archiver process (ARCn) will archive one of these files. If A_LOG1 is corrupted, then the process can archive B_LOG1. The archived redo log contains a copy of every group created since you enabled archiving.

 

一个归档日志文件包含redo entries(重做条目)和在线重做日志文件组相同的日志序列号。在图 11-7 中,文件 A_LOG1 和 B_LOG1 是 Group 1 相同的成员。如果数据库运行在归档日志模式下并且开启了自动归档,那么归档进程(ARCn)将他们中一个进行归档。如果 A_LOG1 损坏了,归档进程可以对 B_LOG1 进行归档。如果你开启了归档,已经归档的重做日志文件将包含每个在线重做日志文件组的备份。

 

 

Online Redo Log结构

 

在线重做日志中包含许多 redo records(重做记录).一条重做记录由一组改变向量组成,每个改变向量描述了对一个数据块的修改。例如,在employees表中修改salary就会产生一条redo记录,用来描述这个表的数据段发生的变化,undo段数据块以及undo段的事务表。

重做记录包含改变的所有相关的基本元数据,具体如下:

改变时的SCN和时间戳
产生这个变化的事务的ID
事务提交的SCN和时间戳(如果已经提交)
产生变化的操作类型
被修改的数据段的名字和类型

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

相关专题

更多
Java 桌面应用开发(JavaFX 实战)
Java 桌面应用开发(JavaFX 实战)

本专题系统讲解 Java 在桌面应用开发领域的实战应用,重点围绕 JavaFX 框架,涵盖界面布局、控件使用、事件处理、FXML、样式美化(CSS)、多线程与UI响应优化,以及桌面应用的打包与发布。通过完整示例项目,帮助学习者掌握 使用 Java 构建现代化、跨平台桌面应用程序的核心能力。

37

2026.01.14

php与html混编教程大全
php与html混编教程大全

本专题整合了php和html混编相关教程,阅读专题下面的文章了解更多详细内容。

19

2026.01.13

PHP 高性能
PHP 高性能

本专题整合了PHP高性能相关教程大全,阅读专题下面的文章了解更多详细内容。

37

2026.01.13

MySQL数据库报错常见问题及解决方法大全
MySQL数据库报错常见问题及解决方法大全

本专题整合了MySQL数据库报错常见问题及解决方法,阅读专题下面的文章了解更多详细内容。

19

2026.01.13

PHP 文件上传
PHP 文件上传

本专题整合了PHP实现文件上传相关教程,阅读专题下面的文章了解更多详细内容。

16

2026.01.13

PHP缓存策略教程大全
PHP缓存策略教程大全

本专题整合了PHP缓存相关教程,阅读专题下面的文章了解更多详细内容。

6

2026.01.13

jQuery 正则表达式相关教程
jQuery 正则表达式相关教程

本专题整合了jQuery正则表达式相关教程大全,阅读专题下面的文章了解更多详细内容。

3

2026.01.13

交互式图表和动态图表教程汇总
交互式图表和动态图表教程汇总

本专题整合了交互式图表和动态图表的相关内容,阅读专题下面的文章了解更多详细内容。

45

2026.01.13

nginx配置文件详细教程
nginx配置文件详细教程

本专题整合了nginx配置文件相关教程详细汇总,阅读专题下面的文章了解更多详细内容。

9

2026.01.13

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号