search
HomeDatabaseMysql TutorialOracle重做日志管理

Oracle重做日志操作是为了记录数据的改变,提供数据库的恢复,下面就为您介绍重做日志的运行流程,希望对您能够有所帮助。 一、ORACLE引入重做日志目的:记录数据的改变,提供数据库的恢复。 1、日志文件需要分组,同一个重做日志组的每个成员所存的信息完全

Oracle重做日志操作是为了记录数据的改变,提供数据库的恢复,下面就为您介绍重做日志的运行流程,希望对您能够有所帮助。

一、ORACLE引入重做日志目的:记录数据的改变,提供数据库的恢复。

1、日志文件需要分组,同一个重做日志组的每个成员所存的信息完全相同。(当为当前联机日志组添加成员时,造成该组的成员间数据不完全一样,因此添加成员时应注意被添加组是否处于CURRENT状态,如果是则可Alter system swtich logfile 来改变当前使用的日志组)

2、每个组中的重做日志文件均被称为成员

3、每组最好有2、3个成员,分别放置不同的物理磁盘,这样安全性较高。

4、最少需要两个重做日志组

二、Oracle重做日志的运行流程:

Oracle重做日志按照有序循环的方式被使用,即当一组日志文件被填满后,循环覆盖下一组日志文件,不断循环。此时称为日志切换。检查点操作也在此时发生,检查点操作是用来实现同步的,它会写数据文件的头信息、控制文件。在归档模式下,当一组日志文件被填满后,ARCH(归档写进程)将这组复制到归档日志文件中。(在ARCH正在写的重做日志文件LGWR是不可以写的)

1、Oracle重做日志文件的定稿是依靠LGWR后台进程

2、.LGWR正在写的重做日志组称为:当前重做日志组。

3、重做日志文件------联机日志文件;归档日志文件------脱机日志文件

三、查询重做日志组:

1、日志组:

select group#, sequence#, members, bytes, status, archived from v$log;

Status列中各值的意义:

Current:当前组。

Inactive:实例恢复已不需要这组日志了

Activie:这组日志是活动的,但非当前组。例如正在归档。

Unused:此组从未被写过。是日志刚被添加到DB中的状态。

2、日志文件:

Select * from v$logfile;

Status列中各值的含义:

空白:此文件正在使用。

Stale:该文件内容是不完全的。

Invalid:该文件不可以被访问。例如刚建立

Deleted:该文件已不再有用。

四、创建与删除重做日志文件组:

1、添加删除重做日志文件组:

Alter database add logfile (‘d:\**.log’, ‘e:\**.log’ ) size15m;

(这样创建的2个重做日志文件都会是同一组)

Alter database drop logfile group 4;

删除指定组号的重做日志组(删除后实际文件并未删除,需手动删除)

删除过程中出现的各种限制条件如下:

current log group当前日志组不可删除,要删除当前日志组需要先对当前日志组进行切换,使用命令为alter system switch logfile;

active log group活动的日志组不可删除

no archived log group没有归档的日志组不可删除(前提是已运行在归档模式下)

2、添加/删除重做日志文件:

Alter database add logfile member‘d:\red004.log’ to group 1,‘d:\red005.log’ to group2;

Alter database drop logfile member ‘d:\red004.log’;
删除时遇到的限制条件:

不能删除当前组的成员,如要删除则:强制性切换重做日志的命令:alter system switch logfile;

active log group活动的日志成员不可删除

no archived log group没有归档的日志成员不可删除(前提是已运行在归档模式下)

at least one member per group当日志成员中只有一个成员

特例:

有的时候在删除重做日志文件redo log file时,会出现如下错误

ERROR位于第1行:

ORA-00362:要求输入成员以组成组4中的有效日志文件

ORA-01517:日志成员: 'C:\ORACLE\ORADATA\GXCNC\REDO041.LOG'

(之所以不能drop logfile member from group 2,是因为group 2的其他redo log file的状态不对。这种情况,应该作几次alter system switch logfile ,使group 2的其他redo log file的状态变为正常 就可以了。)

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 different storage engines available in MySQL?What are the different storage engines available in MySQL?Apr 26, 2025 am 12:27 AM

MySQLoffersvariousstorageengines,eachsuitedfordifferentusecases:1)InnoDBisidealforapplicationsneedingACIDcomplianceandhighconcurrency,supportingtransactionsandforeignkeys.2)MyISAMisbestforread-heavyworkloads,lackingtransactionsupport.3)Memoryengineis

What are some common security vulnerabilities in MySQL?What are some common security vulnerabilities in MySQL?Apr 26, 2025 am 12:27 AM

Common security vulnerabilities in MySQL include SQL injection, weak passwords, improper permission configuration, and unupdated software. 1. SQL injection can be prevented by using preprocessing statements. 2. Weak passwords can be avoided by forcibly using strong password strategies. 3. Improper permission configuration can be resolved through regular review and adjustment of user permissions. 4. Unupdated software can be patched by regularly checking and updating the MySQL version.

How can you identify slow queries in MySQL?How can you identify slow queries in MySQL?Apr 26, 2025 am 12:15 AM

Identifying slow queries in MySQL can be achieved by enabling slow query logs and setting thresholds. 1. Enable slow query logs and set thresholds. 2. View and analyze slow query log files, and use tools such as mysqldumpslow or pt-query-digest for in-depth analysis. 3. Optimizing slow queries can be achieved through index optimization, query rewriting and avoiding the use of SELECT*.

How can you monitor MySQL server health and performance?How can you monitor MySQL server health and performance?Apr 26, 2025 am 12:15 AM

To monitor the health and performance of MySQL servers, you should pay attention to system health, performance metrics and query execution. 1) Monitor system health: Use top, htop or SHOWGLOBALSTATUS commands to view CPU, memory, disk I/O and network activities. 2) Track performance indicators: monitor key indicators such as query number per second, average query time and cache hit rate. 3) Ensure query execution optimization: Enable slow query logs, record and optimize queries whose execution time exceeds the set threshold.

Compare and contrast MySQL and MariaDB.Compare and contrast MySQL and MariaDB.Apr 26, 2025 am 12:08 AM

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

How does MySQL's licensing compare to other database systems?How does MySQL's licensing compare to other database systems?Apr 25, 2025 am 12:26 AM

MySQL uses a GPL license. 1) The GPL license allows the free use, modification and distribution of MySQL, but the modified distribution must comply with GPL. 2) Commercial licenses can avoid public modifications and are suitable for commercial applications that require confidentiality.

When would you choose InnoDB over MyISAM, and vice versa?When would you choose InnoDB over MyISAM, and vice versa?Apr 25, 2025 am 12:22 AM

The situations when choosing InnoDB instead of MyISAM include: 1) transaction support, 2) high concurrency environment, 3) high data consistency; conversely, the situation when choosing MyISAM includes: 1) mainly read operations, 2) no transaction support is required. InnoDB is suitable for applications that require high data consistency and transaction processing, such as e-commerce platforms, while MyISAM is suitable for read-intensive and transaction-free applications such as blog systems.

Explain the purpose of foreign keys in MySQL.Explain the purpose of foreign keys in MySQL.Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

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 Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

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

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.