search
HomeDatabaseMysql TutorialOracle 联机重做日志文件(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

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools