Redo Log

来源:互联网 发布:ie9 解析json乱码 编辑:程序博客网 时间:2024/04/29 01:37

redo log的concept手册上的内容

Redo entries record data that you can use to reconstruct all changes madeto the database, including the rollback segments. Therefore, the online redolog also protects rollback data. When you recover the database using redo data,Oracle reads the change vectors in the redo records and applies the changes tothe relevant blocks.

 Redo records can also be written to an online redo log file before thecorresponding transaction is committed. If the redo log buffer fills, oranother transaction commits, LGWR flushes all of the redo log entries in theredo log buffer to an online redo log file, even though some redo records maynot be committed. If necessary, Oracle can roll back these changes.

Online redo log files that are required for instance recovery are called active online redo log files.Online redo log files that are not required for instance recovery are calledinactive.

当数据库处于归档状态下的时候,当在线重做日志满的时候,要等到ARCn将日志归档之后才可以被重新使用或者覆盖的写;

当数据非归档模式的时候,当最后一个重做日志文件满的时候,会去写第一个active的文件。

Log switch是oracle写完一个在线重做日志文件之后去写另一个的时候的点。通常情况下日志切换时发生在当前的在线重做日志文件被写满的完成的时候而去继续写另一个现在重做日志文件的时候。然后你也可以指定日志切换,不论当前日志是否写满,你可以强制手动的的进行日志切换。

在每一次日志切换发生并且LGWR开始写它的时候,oracle都会发配给在线重做日志文件一个logsequence number。

每一个在线重做日志文件和归档日志文件都由它的日志序列号标示着。当需要恢复的时候,oracle会以logsequence number升序的方式应用日志文件。

创建在线重做日志文件组

The following statement adds a new group of redo logs to the database:ALTER DATABASE  ADD LOGFILE ('/oracle/dbs/log1c.rdo', '/oracle/dbs/log2c.rdo') SIZE 500K;You can also specify the number that identifies the group using the GROUP option:ALTER DATABASE ADD LOGFILE GROUP 10 ('/oracle/dbs/log1c.rdo', '/oracle/dbs/log2c.rdo')SIZE 500K;

创建在线日志成员

添加一个新的重做日志文件成员到重做日志文件组2

ALTER DATABASE ADD LOGFILE MEMBER '/oracle/dbs/log2b.rdo' TO GROUP 2;

注意文件的名字是必须指定的,但是大小不需要,初始的大小由组内已经存在的成员的大小决定。

 

重命名在线重做日志成员的步骤

1.    关闭数据库

2.    拷贝

3.    Startup mount

4.    重新命名在线日志成员

ALTER DATABASERENAME FILE'/diska/logs/log1a.rdo', '/diska/logs/log2a.rdo' TO'/diskc/logs/log1c.rdo', '/diskc/logs/log2c.rdo';
 5.   打开数据库

 删除log group

在删除日志组之前,有以下3点需要注意:

一个实例至少需要2个在线重做日志文件组,无论每个组里有多少成员;

只有在重做日志文件组是inactive的情况下才可以删除,如果你需要删除当前组,那么你需要强制进行日志切换;

如果是归档模式的话,确保在你删除之前已经进行了归档,可以查看v$log来查看是否发生了。

The following statement drops redo log group number 3:

ALTER DATABASE DROP LOGFILE GROUP 3;
如果你没有使用oracle管理文件的特性,那么你需要在确保一切正确的情况下手动删除物理文件;如果使用的是oracle管理文件的特性的话,那么oracle会自动删除文件。

 

删除日志组成员和删除日志组一样要注意离线归档等;

The following statement drops the redo log /oracle/dbs/log3c.rdo:

ALTERDATABASE DROP LOGFILE MEMBER '/oracle/dbs/log3c.rdo';

Clearing an Online Redo Log File

 

The following statement clears the log files in redo log groupnumber 3:

 

ALTER DATABASE CLEAR LOGFILE GROUP 3;

 

This statement overcomes two situations where dropping redo logsis not possible:

     * If there are onlytwo log groups

    * The corrupt redo logfile belongs to the current group

 

If the corrupt redo log file has not been archived, use theUNARCHIVED keyword in the statement.

 ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 3;

 This statement clears the corrupted redo logs and avoidsarchiving them. The cleared redo logs are available for use even though theywere not archived.

 If you clear a log file that is needed for recovery of a backup,then you can no longer recover from that backup. Oracle writes a message in thealert log describing the backups from which you cannot recover.



原创粉丝点击