首頁 資料庫 mysql教程 OverviewoftheOnlineRedoLog---在线重做日志概述

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

Jun 07, 2016 pm 04:13 PM

对于 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

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

與MySQL中使用索引相比,全表掃描何時可以更快? 與MySQL中使用索引相比,全表掃描何時可以更快? Apr 09, 2025 am 12:05 AM

全表掃描在MySQL中可能比使用索引更快,具體情況包括:1)數據量較小時;2)查詢返回大量數據時;3)索引列不具備高選擇性時;4)複雜查詢時。通過分析查詢計劃、優化索引、避免過度索引和定期維護表,可以在實際應用中做出最優選擇。

可以在 Windows 7 上安裝 mysql 嗎 可以在 Windows 7 上安裝 mysql 嗎 Apr 08, 2025 pm 03:21 PM

是的,可以在 Windows 7 上安裝 MySQL,雖然微軟已停止支持 Windows 7,但 MySQL 仍兼容它。不過,安裝過程中需要注意以下幾點:下載適用於 Windows 的 MySQL 安裝程序。選擇合適的 MySQL 版本(社區版或企業版)。安裝過程中選擇適當的安裝目錄和字符集。設置 root 用戶密碼,並妥善保管。連接數據庫進行測試。注意 Windows 7 上的兼容性問題和安全性問題,建議升級到受支持的操作系統。

說明InnoDB全文搜索功能。 說明InnoDB全文搜索功能。 Apr 02, 2025 pm 06:09 PM

InnoDB的全文搜索功能非常强大,能够显著提高数据库查询效率和处理大量文本数据的能力。1)InnoDB通过倒排索引实现全文搜索,支持基本和高级搜索查询。2)使用MATCH和AGAINST关键字进行搜索,支持布尔模式和短语搜索。3)优化方法包括使用分词技术、定期重建索引和调整缓存大小,以提升性能和准确性。

InnoDB中的聚類索引和非簇索引(次級索引)之間的差異。 InnoDB中的聚類索引和非簇索引(次級索引)之間的差異。 Apr 02, 2025 pm 06:25 PM

聚集索引和非聚集索引的區別在於:1.聚集索引將數據行存儲在索引結構中,適合按主鍵查詢和範圍查詢。 2.非聚集索引存儲索引鍵值和數據行的指針,適用於非主鍵列查詢。

mysql:簡單的概念,用於輕鬆學習 mysql:簡單的概念,用於輕鬆學習 Apr 10, 2025 am 09:29 AM

MySQL是一個開源的關係型數據庫管理系統。 1)創建數據庫和表:使用CREATEDATABASE和CREATETABLE命令。 2)基本操作:INSERT、UPDATE、DELETE和SELECT。 3)高級操作:JOIN、子查詢和事務處理。 4)調試技巧:檢查語法、數據類型和權限。 5)優化建議:使用索引、避免SELECT*和使用事務。

mysql 和 mariadb 可以共存嗎 mysql 和 mariadb 可以共存嗎 Apr 08, 2025 pm 02:27 PM

MySQL 和 MariaDB 可以共存,但需要謹慎配置。關鍵在於為每個數據庫分配不同的端口號和數據目錄,並調整內存分配和緩存大小等參數。連接池、應用程序配置和版本差異也需要考慮,需要仔細測試和規劃以避免陷阱。在資源有限的情況下,同時運行兩個數據庫可能會導致性能問題。

mysql用戶和數據庫的關係 mysql用戶和數據庫的關係 Apr 08, 2025 pm 07:15 PM

MySQL 數據庫中,用戶和數據庫的關係通過權限和表定義。用戶擁有用戶名和密碼,用於訪問數據庫。權限通過 GRANT 命令授予,而表由 CREATE TABLE 命令創建。要建立用戶和數據庫之間的關係,需創建數據庫、創建用戶,然後授予權限。

說明不同類型的MySQL索引(B樹,哈希,全文,空間)。 說明不同類型的MySQL索引(B樹,哈希,全文,空間)。 Apr 02, 2025 pm 07:05 PM

MySQL支持四種索引類型:B-Tree、Hash、Full-text和Spatial。 1.B-Tree索引適用於等值查找、範圍查詢和排序。 2.Hash索引適用於等值查找,但不支持範圍查詢和排序。 3.Full-text索引用於全文搜索,適合處理大量文本數據。 4.Spatial索引用於地理空間數據查詢,適用於GIS應用。

See all articles