Oracle 联机重做日志文件(online redo log file) 详述
几乎所有的发生在oracle的内部变化都记录在online redo log file中,oracle使用 这些 redo log groups 去恢复数据库,因此它们是
几乎所有的发生在Oracle的内部变化都记录在online redo log file中,oracle使用 这些 redo log groups 去恢复数据库,因此它们是非常的重要。
联机重做日志文件的主要工作是:
备份数据,
1:记录所有的数据改变
2:提供了一种恢复机制
3:一定是被组织成组的
4:至少有两组联机重做日志文件
每一个redo log 是被分配到 组中, oralce 一次值写一个 online redo log 组, 一旦 这个组中的联机重做日志被填满,oracle 将转换写到下一个联机重做日志组中因此oracle在多个组之间写是一个循环操作。
每一个联机重做日志文件被分配一个唯一的序列号(sequence number)。除非重建数据库,否则 联机重做日志文件的序列号不会出现重复。
我们可以有多个 联机重组偶日志文件在一个组中, 这意味着每一个联机重做日志组包含至少两个 联机重做日志文件, 在组中的每一个文件 成为一个member,每一个 member 应该被分配在不同的磁盘,,为了包含这些组文件丢失,oracle 往组里面的member中并发的写信息,一个组的联机重做日志文件是一模一样的,通过LGWR 进程向所有 online redo log file 组中写信息。
组中的每一个member 具有相同的大小,oracle数据在往 redo log file 组中写信息的时候首先分配一个 log sequence numbers,多路复用:一个组里至少两个 member ,避免了redo log files 的单点故障 ,redo log files 中 一个组中包含多个 member,每个组都有一个编号。
当数据库创建的时候 联机重做日志文件即被创建,数据库不能缺少联机重做日志文件, 如果 一个组中的所有的member 丢失了, 数据库也就损坏了,因此保存和备份这些文件是非常重要的, 有两种重做日志 , 第一种: 联机重做日志 第二种:归档日志。
什么时候LGWR写 redo log file?
1:当一个事务commit的时候
2:每三秒钟写
3:当 redo log buffer 变成 1/3满的时候要写
4:当 redo log buffer 的大小操作 1M 的信息 要执行写操作
5:在DBWn 一个checkpoints 执行前写。
DBWn 这个进程的作用 查 (把redo log files的信息回写 到 datafiles中)
一定是先写重做日志,再写到数据文件中。
联机重做日子文件如何工作:
循环使用, 理解 log switch 的定义。(就是切换不同的组进行写),log switch 引发了 checkpoints 把内存中脏数据回写到数据库文件中叫一个checkpoints
强迫 日志切换(LOG Switches) 和 checkpoints
V$log;这个视图是与联机重做日志文件的视图。
1 :通过v$logfile 查找 数据库的 redo log file 和组;
SQL> col member format a50;
SQL> select group#,type,member from v$logfile;
GROUP# TYPE MEMBER
---------- ------- --------------------------------------------------
3 ONLINE D:\APP\TOPWQP\ORADATA\ORCL\REDO03.LOG
2 ONLINE D:\APP\TOPWQP\ORADATA\ORCL\REDO02.LOG
1 ONLINE D:\APP\TOPWQP\ORADATA\ORCL\REDO01.LOG
2 : 手动切换日志的命令
例如:如下例子 第一次查询 组号为 2 的组的status 是 current , 如下执行了 alter system switch logfile 命令后 再次进行查询 oracle当前写的组号为 3, 表示进行了 log switch 日志组切换操作,这是通过手工的方式进行切换。
SQL> select group#,thread#,sequence#,status from v$log;
GROUP# THREAD# SEQUENCE# STATUS
---------- ---------- ---------- ----------------
1 1 442 INACTIVE
2 1 443 CURRENT
3 1 441 INACTIVE
SQL> alter system switch logfile;
系统已更改。
SQL> select group#,thread#,sequence#,status from v$log;
GROUP# THREAD# SEQUENCE# STATUS
---------- ---------- ---------- ----------------
1 1 442 INACTIVE
2 1 443 ACTIVE
3 1 444 CURRENT

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.
