Oracle重做日志管理
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的状态变为正常 就可以了。)

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

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

Oracle database paging uses ROWNUM pseudo-columns or FETCH statements to implement: ROWNUM pseudo-columns are used to filter results by row numbers and are suitable for complex queries. The FETCH statement is used to get the specified number of first rows and is suitable for simple queries.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

The steps to open an Oracle database are as follows: Open the Oracle database client and connect to the database server: connect username/password@servername Use the SQLPLUS command to open the database: SQLPLUS
