CURRENT
指当前的日志文件,在进行实例恢复时是必须的;ACTIVE
是指活动的非当前日志,在进行实例恢复时会被用到。Active
状态意味着,Checkpoint
尚未完成,因此该日志文件不能被覆盖。INACTIVE
是非活动日志,在实例恢复时不再需要,但在介质恢复时可能需要。UNUSED
表示该日志从未被写入,可能是刚添加的,或RESETLOGS
后被重置。
查看Redo log的状态,可用如下语句:
select group#, status from v$log;
1.redo
的inactive
和active
状态跟是否完成归档没有关系
2.redo
的active
与dirty buffer
是有关联的,即:redo
的active
和inactive
主要取决于相对应的脏块是否写入数据文件,如果相对应的脏块已经被DBWR
写入数据文件,那么redo
由active
变为inactive
。
3.在active
状态下的redo
,可能已经完成了归档(仍在等待脏块的写入,所以还未变为inactive
),也可能还没有完成归档。
4.在inactive
状态下的redo
,可能已经完成了归档,也可能还未完成归档。
5.Log status:
UNUSED - Online redo log has never been written to. This is the state of a redo log that was just added, or just after a RESETLOGS, when it is not the current redo log.
CURRENT - Current redo log. This implies that the redo log is active. The redo log could be open or closed.
ACTIVE - Log is active but is not the current log. It is needed for crash recovery. It may be in use for block recovery. It may or may not be archived.
CLEARING - Log is being re-created as an empty log after an ALTER DATABASE CLEAR LOGFILE statement. After the log is cleared, the status changes to UNUSED.
CLEARING_CURRENT - Current log is being cleared of a closed thread. The log can stay in this status if there is some failure in the switch such as an I/O error writing the new log header.
INACTIVE - Log is no longer needed for instance recovery. It may be in use for media recovery. It may or may not be archived.
CURRENT:
The online redo log is active, that is, needed for instance recovery, and it is the log to which the database is currently writing. The redo log can be open orclosed.
ACTIVE:
The online redo log is active and required for instance recovery, but is not the log to which the database is currently writing. It may be in use for blockrecovery, and may or may not be archived.Once perform “alter system checkpoint”,the log will be change inactive.
INACTIVE:
The log is no longer needed for instance recovery. It may be in use for media recovery,and may or may not be archived.
UNUSED:
The online redo log has never been written to.
CLEARING:
The log is being re-created as an empty log after an ALTER DATABASECLEAR LOGFILE statement. After the log is cleared, then the status changes to UNUSED.
CLEARING_CURRENT:
Current log is being cleared of a closed thread. The log can stay in this status if there is some failure in the switch such as an I/O error writing thenew log header. . .
The ALTER DATABASE CLEAR LOGFILE
statement can fail with an I/O error due to media failure when it is not possible to:
Relocate the redo log file onto alternative media by re-creating it under the currently configured redo log filename
Reuse the currently configured log filename to re-create the redo log file because the name itself is invalid or unusable (for example, due to media failure)
In these cases, the ALTER DATABASE CLEAR LOGFILE
statement (before receiving the I/O error) would have successfully informed the control file that the log was being cleared and did not require archiving. The I/O error occurred at the step in which the CLEAR LOGFILE
statement attempts to create the newredo log file and write zeros to it.
This fact is reflected in V$LOG.CLEARING_CURRENT
.
-- 查看Redo log的状态和具体文件,可用如下语句:
SQL> select group#,bytes/1024/1024||'M',status from v$log;
GROUP# BYTES/1024/1024||'M' STATUS
---------- ----------------------------------------- ----------------
1 50M UNUSED
2 50M INACTIVE
3 50M CURRENT
SQL> select group#,member from v$logfile;
GROUP# MEMBER
---------- --------------------------------------------------
3 /u01/oradata/orcl/redo03.log
2 /u01/oradata/orcl/redo02.log
1 /u01/oradata/orcl/redo01.log