16、重做日誌檔案的狀態及重做日誌組的狀態說明
一、日誌檔案的狀態包括:
1、NULL -File is in use
2、STALE-contents of the file are incomplete
3、INVALID-File is inaccessible
4、DELETED-File is no longer used
二、重做日誌組的狀態包括:
1、CURRENT-Current redo log.This implies that the redo log is active.The redo log could be open or closed.
2、UNUSED-Online redo log has never been written to.This is the status of a redo log that was just added.or just after a RESETLOGS.when it is not the current redo log
3、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
4、INACTIVE-Log is no longer needed for instance recovery. It may be in use for media recovery. It might or might not be archived.
5、CLEARING-這個日誌正在被重建,重建後為空的日誌,當日志被cleared後,狀態變為unused,使用alter data clear logfile 可以進行重建操作
6、CALERING_CURRENT-對於一個關閉的thread,重建當前日誌,當日志撤換過程中在寫新的重做日誌時發生i/o錯誤出現錯誤的會出現這種狀態的重做日誌
三、狀態變化過程及應用
SQL> alter database clear logfile group 1;
資料庫已更改。
SQL> select group#,sequence#,status,archived from v$log;
GROUP# SEQUENCE# STATUS ARC
---------- ---------- ---------------- ---
1 0 UNUSED YES --執行clear命令後,狀態為unused
2 173 CURRENT NO
3 171 INACTIVE YES
SQL> drop table t;
表已丟棄。
SQL> create table t as select * from dba_objects;
表已建立。
SQL> insert into t select * from t;
已建立25745行。
SQL> insert into t select * from t;
已建立51490行。
SQL> insert into t select * from t;
已建立102980行。
SQL> insert into t select * from t;
已建立205960行。
SQL> insert into t select * from t;
已建立411920行。
SQL> insert into t select * from t;
已建立823840行。
SQL> select group#,sequence#,status,archived from v$log;
GROUP# SEQUENCE# STATUS ARC
---------- ---------- ---------------- ---
1 174 INACTIVE YES
2 176 CURRENT NO --活動且當前
3 175 ACTIVE NO --活動
SQL> commit;
提交完成。
SQL> select group#,sequence#,status,archived from v$log;
GROUP# SEQUENCE# STATUS ARC
---------- ---------- ---------------- ---
1 174 INACTIVE YES
2 176 CURRENT NO
3 175 INACTIVE YES --提交後發現已經歸檔
SQL> insert into t select * from t;
已建立1647680行。
SQL> alter system switch logfile;
系統已更改。
SQL> select group#,sequence#,status,archived from v$log;
GROUP# SEQUENCE# STATUS ARC
---------- ---------- ---------------- ---
1 177 ACTIVE NO
2 176 ACTIVE YES
3 178 CURRENT NO
--幾秒之後
SQL> select group#,sequence#,status,archived from v$log;
GROUP# SEQUENCE# STATUS ARC
---------- ---------- ---------------- ---
1 177 INACTIVE YES --發現歸檔了,並且狀態變為inactive
2 179 CURRENT NO
3 178 ACTIVE YES
--此時非正常關閉
--那麼需要例程恢復,看看應用到那些線上重做日誌
SQL> shutdown abort;
ORACLE 例程已經關閉。
SQL> startup mount;
ORACLE 例程已經啟動。
Total System Global Area 319888364 bytes
Fixed Size 453612 bytes
Variable Size 192937984 bytes
Database Buffers 125829120 bytes
Redo Buffers 667648 bytes
資料庫裝載完畢。
SQL> select group#,sequence#,status,archived from v$log;
GROUP# SEQUENCE# STATUS ARC
---------- ---------- ---------------- ---
1 177 INACTIVE YES
2 179 CURRENT NO
3 178 ACTIVE YES
--開啟資料庫
SQL> alter database open;
資料庫已更改。
--檢視alert日誌
ALTER DATABASE MOUNT
Sun May 21 09:33:29 2006
Successful mount of redo thread 1, with mount id 1184869413.
Sun May 21 09:33:29 2006
Database mounted in Exclusive Mode.
Completed: ALTER DATABASE MOUNT
Sun May 21 09:35:47 2006
alter database open
Sun May 21 09:35:47 2006
Beginning crash recovery of 1 threads
Sun May 21 09:35:47 2006
Started first pass scan
Sun May 21 09:35:49 2006
Completed first pass scan
112893 redo blocks read, 7011 data blocks need recovery
Sun May 21 09:35:50 2006
Started recovery at
Thread 1: logseq 178, block 159334, scn 0.0 --發現會用到這個在序號為178,因為是active
Recovery of Online Redo Log: Thread 1 Group 3 Seq 178 Reading mem 0
Mem# 0 errs 0: D:ORACLEORADATADB1REDO03.LOG
Recovery of Online Redo Log: Thread 1 Group 2 Seq 179 Reading mem 0
Mem# 0 errs 0: D:ORACLEORADATADB1REDO02.LOG
Sun May 21 09:35:53 2006
Ended recovery at
Thread 1: logseq 179, block 67445, scn 0.5728855 --179也會用到,因為當前肯定是active的
7011 data blocks read, 7011 data blocks written, 112893 redo blocks read
Crash recovery completed successfully
Sun May 21 09:35:53 2006
LGWR: Primary database is in CLUSTER CONSISTENT mode
Thread 1 advanced to log sequence 180
Thread 1 opened at log sequence 180
Current log# 1 seq# 180 mem# 0: D:ORACLEORADATADB1REDO01.LOG
Successful open of redo thread 1.
Sun May 21 09:35:53 2006
SMON: enabling cache recovery
Sun May 21 09:35:53 2006
ARC0: Evaluating archive log 2 thread 1 sequence 179
ARC0: Beginning to archive log 2 thread 1 sequence 179
Creating archive destination LOG_ARCHIVE_DEST_1: 'D:DBBKARC00179.001'
Sun May 21 09:35:55 2006
Undo Segment 1 Onlined
Undo Segment 2 Onlined
Undo Segment 3 Onlined
Undo Segment 4 Onlined
Undo Segment 5 Onlined
Undo Segment 6 Onlined
Undo Segment 7 Onlined
Undo Segment 8 Onlined
Undo Segment 9 Onlined
Undo Segment 10 Onlined
Successfully onlined Undo Tablespace 1.
Sun May 21 09:35:55 2006
SMON: enabling tx recovery
Sun May 21 09:35:56 2006
Database Characterset is ZHS16GBK
Sun May 21 09:35:58 2006
ARC0: Completed archiving log 2 thread 1 sequence 179
Sun May 21 09:36:01 2006
replication_dependency_tracking turned off (no async multimaster replication found)
Completed: alter database open
--此過程會應用到日誌序號為178,179的兩個重做日誌序號,並且把日誌序號加1置為新的current狀態,把
--之前current狀態的序號進行歸檔,然後才開啟資料庫。
--查詢後看到序號最新的已經是180了,並且之前的日誌都已經歸檔。
SQL> select group#,sequence#,status,archived from v$log;
GROUP# SEQUENCE# STATUS ARC
---------- ---------- ---------------- ---
1 180 CURRENT NO
2 179 INACTIVE YES
3 178 INACTIVE YES
--檢視未提交的記錄,發現已經回滾
SQL> select count(*) from t;
COUNT(*)
----------
1647680
四、關於stale狀態的說明
A stale redo log file is one that Oracle believes might be incomplete for some reason. This typically happens when a temporary error prevents the LGWR background process from writing to a redo log group member.
V1.STATUS GROUP_STATUS
FROM V$LOG V1, V$LOGFILE V2
WHERE V1.GROUP# = V2.GROUP# AND V2.STATUS = 'STALE';
Once the redo group becomes current again, the stale status of
the log file will go away by itself.
the query a few more times.
trace file, if one can be found in your background_dump_dest.
See if there is any pattern to the problem. Do you see any
recent errors, such as ORA-312, referencing that particular log
file? If so, there may be some corruption problem with the file
or a problem with the I/O subsystem (disk, controllers, etc.) .
If you are running any other Oracle version on any other platform
isolated incident.
verifies that its contents are valid. If that is not the case,
it issues an error such as ORA-255 ("error archiving log %s
of thread %s, sequence # %s"). Therefore, if the log group to
which the stale member belongs has been successfully archived,
it means the redo contents of the group are good, and that
archived log can be safely used for recovery. ARCH errors, if
any, will be reported in your alert.log file and in an ARCH
trace file.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/248644/viewspace-931077/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle資料庫重做日誌及歸檔日誌的工作原理說明Oracle資料庫
- 為oracle新增重做日誌組及重做日誌成員Oracle
- 聯機重做日誌、歸檔日誌、備用重做日誌
- Oracle11g redo log 建立、新增、刪除(重做日誌組,重做日誌檔案)Oracle
- 重做日誌檔案中的SCN
- 日誌的狀態
- 有關重做日誌的狀態及switch logfile時的不正常案例分析
- 重做日誌
- 線上修改重做日誌檔案的大小
- 修改Oracle重做日誌檔案的大小Oracle
- 重做日誌檔案的相關操作
- Oracle的重做日誌Oracle
- Oracle重做日誌檔案基礎Oracle
- oracle 聯機重做日誌檔案Oracle
- 手工建立多路重做日誌組
- inactive狀態日誌組檔案損壞的恢復
- 重做日誌管理
- 如何更改線上重做日誌檔案的大小
- 聯機重做日誌檔案的恢復
- 丟失所有重做日誌檔案的恢復例子丟失所有重做日誌檔案的恢復例子如下:
- 重做日誌的恢復
- 重做日誌檔案損壞測試
- 談談Oracle日誌檔案的INVALID狀態Oracle
- redo重做日誌管理
- 恢復重做日誌
- 簡述oracle日誌組的四種狀態Oracle
- 重做日誌大小的設定
- 【REDO】刪除聯機重做日誌檔案組的注意事項
- 【REDO】刪除REDO LOG重做日誌組後需要手工刪除對應的日誌檔案
- logmnr分析歸檔重做日誌
- 談談Oracle日誌檔案的INVALID狀態(上)Oracle
- 談談Oracle日誌檔案的INVALID狀態(下)Oracle
- 記錄一則clear重做日誌檔案的案例
- 丟失聯機重做日誌檔案的恢復
- MySQL重做日誌(redo log)MySql
- 重做日誌基礎操作
- oracle 恢復重做日誌Oracle
- dml操作重做日誌分析