Online Redo Log有什么作用
Oracle 数据库通过在线重做日志文件来确保数据不丢失。特别是当实例失败后, oracle数据库可以通过在线重做日志文件恢复已经提交但尚未写到数据文件中的数据。
Oracle 数据库把每个事务先同步写到 redo log buffer,然后再写到在线重做日志文件中。日志的内容包括未提交的事务,undo数据,模式对象管理声明。
Oracle 数据库使用在线重做日志仅仅用于恢复。数据库管理员也可以使用 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