ITPub博客

首页 > IT基础架构 > 网络安全 > 有关重做日志的状态及switch logfile时的不正常案例分析

有关重做日志的状态及switch logfile时的不正常案例分析

原创 网络安全 作者:shiyihai 时间:2006-12-06 17:15:25 0 删除 编辑

首先回顾一下有关重做日志的状态:
V$logfile:
INVALID - File is inaccessible
STALE - File's contents are incomplete
DELETED - File is no longer used
null - File is in use

V$log:
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 might or might not be archived.

如下的案例是一个手工强制切换日志的例子,其过程如下:
在windows xp上,9206版本。执行完alter system switch logfile后一直挂着,v$session_wait中switch logfile command的事件。具体为:
SQL> select * from v$session_wait where sid=11;

SID SEQ# EVENT P1TEXT P1 P1RAW P2TEXT P2 P2RAW P3TEXT P3 P3RAW WAIT_TIME SECONDS_IN_WAIT STATE
---------- ---------- ---------------------------------------------------------------- ---------------------------------------------------------------- ---------- -------- ---------------------------------------------------------------- ---------- -------- ---------------------------------------------------------------- ---------- -------- ---------- --------------- -------------------
11 1124 switch logfile command 0 00 0 00 0 00 0 517 WAITING

SQL>
SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
1 1 0 104857600 1 YES CLEARING 11809968 2006-12-1 1
2 1 190 104857600 1 NO CURRENT 12328406 2006-12-6 1
3 1 189 104857600 1 YES ACTIVE 12327853 2006-12-6 1

SQL>

发觉日志组1的状态为CLEARING,对其执行clear命令:
SQL> alter database clear logfile 'C:ORACLEORADATAORA9IREDO01.LOG';

Database altered
SQL> select * from v$logfile;

GROUP# STATUS TYPE MEMBER
---------- ------- ------- --------------------------------------------------------------------------------
3 ONLINE C:ORACLEORADATAORA9IREDO03.LOG
2 ONLINE C:ORACLEORADATAORA9IREDO02.LOG
1 ONLINE C:ORACLEORADATAORA9IREDO01.LOG

SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
1 1 0 104857600 1 YES UNUSED 11809968 2006-12-1 1
2 1 194 104857600 1 NO CURRENT 12374486 2006-12-6 1
3 1 193 104857600 1 YES INACTIVE 12374339 2006-12-6 1

SQL> alter system switch logfile;

System altered

SQL> alter system switch logfile;

System altered

SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- -----------
1 1 195 104857600 1 YES ACTIVE 12379388 2006-12-6 1
2 1 194 104857600 1 YES ACTIVE 12374486 2006-12-6 1
3 1 196 104857600 1 NO CURRENT 12379391 2006-12-6 1

SQL>


一切正常!

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/38542/viewspace-882078/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    235
  • 访问量
    1669329