oracle 聯機重做日誌檔案
一、Oracle中的幾類日誌檔案
Redo log files -->聯機重做日誌
Archive log files -->歸檔日誌
Alert log files -->告警日誌
Trace files -->跟蹤日誌
user_dump_dest -->使用者跟蹤日誌
backupground_dump_dest -->程式跟蹤日誌
--檢視後臺程式相關目錄
SQL> show parameter dump
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
background_core_dump string partial
background_dump_dest string /u01/app/oracle/admin/orcl/bdump
core_dump_dest string /u01/app/oracle/admin/orcl/cdump
max_dump_file_size string UNLIMITED
shadow_core_dump string partial
user_dump_dest string /u01/app/oracle/admin/orcl/udump
關於Oracle 常用目錄及路徑請參考:Oracle 常用目錄結構(10g)
關於Oracle 體系結構請參考:Oracle例項和Oracle資料庫(Oracle體系結構)
二、聯機重做日誌的規劃管理
1.聯機重做日誌
記錄了資料的所有變化(DML,DDL或管理員對資料所作的結構性更改等)
提供恢復機制(對於意外刪除或當機利用日誌檔案實現資料恢復)
可以被分組管理
2.聯機重做日誌組
由一個或多個相同的聯機日誌檔案組成一個聯機重做日誌組
至少兩個日誌組,每組一個成員(建議每組兩個成員,分散放開到不同的磁碟)
由LGWR後臺程式同時將日誌內容寫入到一個組的所有成員
LGWR的觸發條件
在事務提交的時候(COMMIT)
Redo Log Buffer 三分之一滿
Redo Log Buffer 多於一兆的變化記錄
在DBWn寫入資料檔案之前
3.聯機重做日誌成員
重做日誌組內的每一個聯機日誌檔案稱為一個成員
一個組內的每一個成員具有相同的日誌序列號(log sequence number),且成員的大小相同
每次日誌切換時,Oracle伺服器分配一個新的LSN號給即將寫入日誌的日誌檔案組
LSN號用於唯一區分每一個聯機日誌組和歸檔日誌
處於歸檔模式的聯機日誌,LSN號在歸檔時也被寫入到歸檔日誌之中
4.日誌檔案的工作方式
日誌檔案採用按順序迴圈寫的方式
當一組聯機日誌組寫滿,LGWR則將日誌寫入到下一組,當最後一組寫滿則從第一組開始寫入
寫入下一組的過程稱為日誌切換
切換時發生檢查點過程
檢查點的資訊同時寫入到控制檔案
5.聯機日誌檔案的規劃
總原則
分散放開,多路複用
日誌所在的磁碟應當具有較高的I/O
一般日誌組大小應滿足自動切換間隔至少15-20分鐘左右業務需求
建議使用rdo結尾的日誌檔名,避免誤刪日誌檔案。如redo1.rdo,redo2.rdo
規劃樣例
Redo Log Group1 Redo Log Group2 Redo Log Group3
Member1 Member1 Member1 -->Physical Disk 1
Member2 Member2 Member2 -->Physical Disk 2
Member3 Member3 Member3 -->Physical Disk 3
6.日誌切換和檢查點切換
ALTER SYSTEM SWITCH LOGFILE; --強制手動切換
ALTER SYSTEM CHECKPOINT;
強制設定檢查點間隔
ALTER SYSTEM SET FAST_START_MTTR_TARGET = n
7.新增日誌檔案組
ALTER DATABASE ADD LOGFILE [GROUP n]
('$ORACLE_BASE/oradata/u01/logn1.rdo',
'$ORACLE_BASE/oradata/u01/logn2.rdo')
SIZE mM;
8.新增日誌成員
ALTER DATABASE ADD LOGFILE MEMBER
'$ORACLE_BASE/oradata/u01/logn1.rdo' TO GROUP 1,
'$ORACLE_BASE/oradata/u01/logn2.rdo' TO GROUP 2;
9.刪除日誌成員
不能刪除組內的唯一一個成員
不能刪除處於active 和current 狀態組內的成員
刪除處於active 和current 狀態組內的成員,應使用日誌切換使其處於INACTIVE狀態後再刪除
對於組內如果一個成員為NULL 值,一個為INVALID,且組處入INACTIVE,僅能刪除INVALID狀態成員
刪除日誌成員,物理檔案並沒有真正刪除,需要手動刪除
刪除日誌檔案後,控制檔案被更新
對於處於歸檔模式下的資料庫,刪除成員時確保日誌已被歸檔,檢視v$log檢視獲得歸檔資訊
ALTER DATABASE DROP LOGFILE MEMBER '$ORACLE_BASE/oradata/u01/logn1.rdo'
10.刪除日誌組
一個例項至少需要兩個聯機日誌檔案組
活動或當前的日誌組不能被刪除
組內成員狀態有NULL 值或INVALID狀態並存,組不可刪除
日誌組被刪除後,物理檔案需要手動刪除(對於非OMF)
ALTER DATABASE DROP LOGFILE GROUP n
11.日誌的重定位及重新命名
所需許可權
ALTER DATABASE 系統許可權
複製檔案到目的位置作業系統許可權(寫許可權)
CURRENT狀態組內的成員不能被重新命名
建議該行為之前備份資料庫
重新命名或重定位之後建議立即備份控制檔案
重定位及重新命名的兩種方法
新增一個新成員到日誌組,然後刪除一箇舊的成員
使用ALTER DATABASE RENAME FILE 命令(不區分歸檔與非歸檔模式)
複製聯機日誌檔案到新路徑:ho cp
執行ALTER DATABASE RENAME FILE '
對於處於CURRENT狀態的需要改名且不切換的情況下
辦法是切換到MOUNT狀態下再執行上述操作
12.清空日誌檔案組
ALTER DATABASE CLEAR LOGIFLE GROUP n
ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP n --使用unarchived 避免歸檔
13.日誌週期迴圈及切換分析
Group 1 Group 2 Group 3
Current Inactive Inactive
---------- Log Switch -------------
Active Current Inactive
---------- Log Switch -------------
Active Active Current
---------- Log Switch -------------
Current Inactive Inactive
--Active 和Current 稱之為在一個迴圈週期之內(按順序寫日誌)
--Inactive 稱為一個週期之外(一個新的迴圈)
--新一輪迴圈開始如在歸檔狀態則先歸檔再清空,否則直接清空日誌
--資料庫啟動時Active 和Current 狀態的日誌不能丟失,否則出錯
14.日誌的監視
檢視日誌檢視中的物理日誌檔案是否存在、位置、大小等
SELECT 'ho cp '||member FROM v$logfile;
檢視日誌檔案所處的磁碟空間是否足夠
SQL> ho df -h
檢視組內是否存在多個成員,如為單一成員應考慮增加日誌成員
日誌切換的間隔時間,應滿足15-20分鐘業務需求,如果切換間隔很短,應當增加日誌檔案的大小
增加方法,先刪除日誌組,再重建該組(對於current和active的需要切換再做處理)
--檢視切換時間間隔(下面的示例中為手工切換的時間,不作考慮)
SQL> SELECT TO_CHAR(first_time,'yyyy-mm-dd hh24:mi:ss'),group# FROM v$log;
TO_CHAR(FIRST_TIME, GROUP#
------------------- ----------
2010-07-20 09:43:18 1
2010-07-19 22:44:30 2
2010-07-19 22:44:32 3
15.日誌的異常處理(參照演示中9小節)
不一致的情況(啟動時)
ALTER DATABASE CLEAR LOGFILE GROUP n
ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP n
三、與日誌有關的動態效能檢視
V$LOG
V$LOGFILE
V$LOG中STATUS的狀態值
UNUSED: 從未對該聯機日誌寫入任何內容,一般為新增加聯機日誌檔案或是使用resetlog後的狀態
CURRENT:當前重做日誌檔案,表示該重做日誌檔案為活動狀態,能夠被開啟和關閉
ACTIVE:處於活動狀態,不屬於當前日誌,崩潰恢復需要該狀態,可用於塊恢復,可能歸檔,也可能未歸檔
CLEARING:表示在執行alter database clear logfile命令後正將該日誌重建為一個空日誌,重建後狀態變為unused
CLEARING_CURRENT:當前日誌處於關閉執行緒的清除狀態。如日誌某些故障或寫入新日誌標頭時發生I/O錯誤
INACTIVE:例項恢復不在需要聯機重做檔案日誌組,可能歸檔也可能未歸檔
V$LOGFILE中STATUS的狀態值
INVALID :表明該檔案不可訪問
STALE :表明檔案內容不完全
DELETED : 表明該檔案不再使用
NULL :表明檔案正在使用
四、演示
--1.檢視當前資料庫的日誌
SQL> SELECT * FROM v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 5 52428800 1 NO CURRENT 2758062 19-JUL-10
2 1 3 52428800 2 YES INACTIVE 2695010 16-JUL-10
3 1 4 104857600 2 YES INACTIVE 2716552 18-JUL-10
SQL> SELECT * FROM v$logfile ORDER BY group#;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------------------------------- ---
1 ONLINE /u01/app/Oracle/oradata/orcl/redo01.log NO
2 STALE ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO
2 STALE ONLINE /u01/app/oracle/oradata/orcl/redo2.log NO
3 STALE ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO
3 STALE ONLINE /u01/app/oracle/oradata/orcl/redo3.log NO
--2.新增日誌組
SQL> SELECT * FROM v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------------------------------- ---
2 STALE ONLINE /u01/app/oracle/oradata/orcl/redo2.log NO
2 STALE ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO
3 STALE ONLINE /u01/app/oracle/oradata/orcl/redo3.log NO
3 STALE ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO
4 ONLINE /u01/app/oracle/oradata/orcl/redo4.log NO
4 ONLINE /u01/app/oracle/oradata/orcl/redo04.log NO
--3.新增日誌成員
SQL> ALTER DATABASE ADD LOGFILE MEMBER '/u01/app/oracle/oradata/orcl/redo1.log' TOGROUP 1;
Database altered.
SQL> SELECT * FROM v$logfile WHERE group# = 1 ;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------------------------------- ---
1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO
1 INVALID ONLINE /u01/app/oracle/oradata/orcl/redo1.log NO
--4.刪除日誌成員
SQL> ALTER DATABASE DROP LOGFILE MEMBER '/u01/app/oracle/oradata/orcl/redo01.log';
ALTER DATABASE DROP LOGFILE MEMBER '/u01/app/oracle/oradata/orcl/redo01.log'
*
ERROR at line 1: --redo01.log處於NULL狀態且該日誌組為current狀態不能刪除
ORA-00362: member is required to form a valid logfile in group 1
ORA-01517: log member: '/u01/app/oracle/oradata/orcl/redo01.log'
SQL> ALTER DATABASE DROP LOGFILE MEMBER '/u01/app/oracle/oradata/orcl/redo04.log';
Database altered.
SQL> ALTER DATABASE DROP LOGFILE MEMBER '/u01/app/oracle/oradata/orcl/redo4.log';
ALTER DATABASE DROP LOGFILE MEMBER '/u01/app/oracle/oradata/orcl/redo4.log'
*
ERROR at line 1: --最後一個日誌成員不能被刪除
ORA-00361: cannot remove last log member /u01/app/oracle/oradata/orcl/redo4.log for group 4
--5.日誌切換
SQL> SELECT * FROM v$log; --當前的日誌組處於CURRENT狀態
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 5 52428800 2 NO CURRENT 2758062 19-JUL-10
2 1 3 52428800 2 YES INACTIVE 2695010 16-JUL-10
3 1 4 104857600 2 YES INACTIVE 2716552 18-JUL-10
4 1 0 31457280 1 YES UNUSED 0
SQL> ALTER SYSTEM SWITCH LOGFILE; --進行日誌切換
System altered.
SQL> SELECT * FROM v$log; --原來的日誌組4的unused狀態變為current狀態
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 5 52428800 2 YES ACTIVE 2758062 19-JUL-10
2 1 3 52428800 2 YES INACTIVE 2695010 16-JUL-10
3 1 4 104857600 2 YES INACTIVE 2716552 18-JUL-10
4 1 6 31457280 1 NO CURRENT 2759277 19-JUL-10
SQL> ALTER SYSTEM SWITCH LOGFILE; --再次進行日誌切換
System altered.
SQL> SELECT * FROM v$log; --日誌組1變為current且組4變為active 狀態
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 5 52428800 2 YES ACTIVE 2758062 19-JUL-10
2 1 7 52428800 2 NO CURRENT 2759293 19-JUL-10
3 1 4 104857600 2 YES INACTIVE 2716552 18-JUL-10
4 1 6 31457280 1 YES ACTIVE 2759277 19-JUL-10
由上可得知,在日誌切換時對於unused組將優先作為下一組切換物件
--再次刪除redo01.log還是收到錯誤提示
SQL> ALTER DATABASE DROP LOGFILE MEMBER '/u01/app/Oracle/oradata/orcl/redo01.log';
ALTER DATABASE DROP LOGFILE MEMBER '/u01/app/oracle/oradata/orcl/redo01.log'
*
ERROR at line 1:
ORA-00362: member is required to form a valid logfile in group 1
ORA-01517: log member: '/u01/app/oracle/oradata/orcl/redo01.log'
SQL> ALTER SYSTEM SWITCH LOGFILE; --再次進行日誌切換
System altered.
SQL> SELECT * FROM v$log; --group1變為inactive
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 5 52428800 2 YES INACTIVE 2758062 19-JUL-10
2 1 7 52428800 2 YES ACTIVE 2759293 19-JUL-10
3 1 8 104857600 2 NO CURRENT 2759420 19-JUL-10
4 1 6 31457280 1 YES INACTIVE 2759277 19-JUL-10
--反覆多切幾次日誌之後redo01.log被成功刪除
SQL> ALTER DATABASE DROP LOGFILE MEMBER '/u01/app/oracle/oradata/orcl/redo01.log';
Database altered.
--6.刪除日誌組(CURRENT和ACTIVE狀態的不能被刪除)
SQL> SELECT * FROM v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 9 52428800 1 YES ACTIVE 2759487 19-JUL-10
2 1 11 52428800 2 NO CURRENT 2759502 19-JUL-10
3 1 8 104857600 2 YES ACTIVE 2759420 19-JUL-10
4 1 10 31457280 1 YES ACTIVE 2759499 19-JUL-10
SQL> ALTER DATABASE DROP LOGFILE GROUP 4;
ALTER DATABASE DROP LOGFILE GROUP 4
*
ERROR at line 1: --處於活動狀態的group4 用於災難恢復,不能被刪除
ORA-01624: log 4 needed for crash recovery of instance orcl (thread 1)
ORA-00312: online log 4 thread 1: '/u01/app/oracle/oradata/orcl/redo4.log'
SQL> ALTER SYSTEM SWITCH LOGFILE; --進行日誌切換
System altered.
SQL> /
System altered.
SQL> SELECT * FROM v$log; --group 4的狀態變為inactvie
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 13 52428800 1 NO CURRENT 2759720 19-JUL-10
2 1 11 52428800 2 YES ACTIVE 2759502 19-JUL-10
3 1 12 104857600 2 YES ACTIVE 2759718 19-JUL-10
4 1 10 31457280 1 YES INACTIVE 2759499 19-JUL-10
SQL> ALTER DATABASE DROP LOGFILE GROUP 4; --成功刪除group 4
Database altered.
SQL> ho ls /u01/app/oracle/oradata/orcl/redo*
/u01/app/oracle/oradata/orcl/redo01.log /u01/app/oracle/oradata/orcl/redo1.log
/u01/app/oracle/oradata/orcl/redo02.log /u01/app/oracle/oradata/orcl/redo2.log
/u01/app/oracle/oradata/orcl/redo03.log /u01/app/oracle/oradata/orcl/redo3.log
/u01/app/oracle/oradata/orcl/redo04.log /u01/app/oracle/oradata/orcl/redo4.log
SQL> ho rm /u01/app/oracle/oradata/orcl/redo04.log --刪除物理檔案
SQL> ho rm /u01/app/oracle/oradata/orcl/redo4.log --刪除物理檔案
--7.日誌的重定位及重新命名(僅演示ALTER DATABASE RENAME FILE 命令)
SQL> SELECT name,log_mode FROM v$database;
NAME LOG_MODE
--------- ------------
ORCL ARCHIVELOG
SQL> SELECT * FROM v$logfile ORDER BY group#;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------------------------------- ---
1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO
2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO
2 ONLINE /u01/app/oracle/oradata/orcl/redo2.log NO
3 STALE ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO
3 STALE ONLINE /u01/app/oracle/oradata/orcl/redo3.log NO
SQL> ho cp /u01/app/oracle/oradata/orcl/redo01.log /u01/app/oracle/oradata/redo01.rdo
SQL> ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl/redo01.log'
2 TO '/u01/app/oracle/oradata/redo01.rdo';
Database altered.
SQL> SELECT * FROM v$logfile WHERE group# = 1;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------------------------------- ---
1 ONLINE /u01/app/oracle/oradata/redo01.rdo NO
--8.清空日誌檔案組(只有非active 和非current狀態的組才能被清空)
SQL> SELECT * FROM v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 13 52428800 1 YES ACTIVE 2759720 19-JUL-10
2 1 14 52428800 2 NO CURRENT 2761383 19-JUL-10
3 1 12 104857600 2 YES INACTIVE 2759718 19-JUL-10
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1;
ALTER DATABASE CLEAR LOGFILE GROUP 1
*
ERROR at line 1: --active 狀態不能被清空
ORA-01624: log 1 needed for crash recovery of instance orcl (thread 1)
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/redo1.rdo'
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 2;
ALTER DATABASE CLEAR LOGFILE GROUP 2
*
ERROR at line 1: --current 狀態不能被清空
ORA-01624: log 2 needed for crash recovery of instance orcl (thread 1)
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/orcl/redo2.log'
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/orcl/redo02.log'
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 3;
Database altered.
SQL> SELECT * FROM v$log; --group 3被清空後狀態變為unused
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 13 52428800 1 YES INACTIVE 2759720 19-JUL-10
2 1 14 52428800 2 NO CURRENT 2761383 19-JUL-10
3 1 0 104857600 2 YES UNUSED 2759718 19-JUL-10
--9.日誌異常處理
--啟動時提示日誌不一致
SQL> startup
Oracle instance started.
Total System Global Area 251658240 bytes
Fixed Size 1218796 bytes
Variable Size 83887892 bytes
Database Buffers 163577856 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-00341:log 1 of thread 1,wrong log # in header
ORA-00312:online log 1 thread 1:'/u01/app/oracle/oradata/orcl/redo1a.rdo'
ORA-00312:online log 1 thread 1:'/u01/app/oracle/oradata/orcl/redo1b.rdo'
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1;
Database altered.
SQL> ALTER DATABASE OPEN;
Database opened.
--日誌檔案丟失(非current狀態日誌組)
SQL> startup
ORACLE instance started.
Total System Global Area 251658240 bytes
Fixed Size 1218796 bytes
Variable Size 88082196 bytes
Database Buffers 159383552 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/orcl/redo1a.rdo'
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/orcl/redo1b.rdo'
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1;
Database altered.
SQL> ALTER DATABASE OPEN;
Database altered.
--日誌檔案丟失(current狀態日誌組)
SQL> startup
ORACLE instance started.
Total System Global Area 251658240 bytes
Fixed Size 1218796 bytes
Variable Size 83887892 bytes
Database Buffers 163577856 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl/redo3a.rdo'
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl/redo3b.rdo'
--檢視告警日誌
SQL> ho tail -n 30 /u01/app/oracle/admin/orcl/bdump/alert_orcl.log
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl/redo3a.rdo'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Tue Jul 20 10:45:58 2010
Errors in file /u01/app/oracle/admin/orcl/bdump/orcl_lgwr_4112.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl/redo3b.rdo'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl/redo3a.rdo'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Tue Jul 20 10:45:58 2010
ARC0: STARTING ARCH PROCESSES
Tue Jul 20 10:45:58 2010
ARC1: Becoming the 'no FAL' ARCH
ARC1: Becoming the 'no SRL' ARCH
Tue Jul 20 10:45:58 2010
ARC2: Archival started
ARC0: STARTING ARCH PROCESSES COMPLETE
ARC0: Becoming the heartbeat ARCH
ARC2 started with pid=18, OS id=4137
Tue Jul 20 10:45:58 2010
ORA-313 signalled during: ALTER DATABASE OPEN...
--檢視物理日誌檔案是否存在
SQL> ho ls /u01/app/oracle/oradata/orcl/redo3a.rdo
ls: /u01/app/oracle/oradata/orcl/redo3a.rdo: No such file or directory
SQL> ho ls /u01/app/oracle/oradata/orcl/redo3b.rdo
ls: /u01/app/oracle/oradata/orcl/redo3b.rdo: No such file or directory
--嘗試使用清空日誌組命令
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 3;
ALTER DATABASE CLEAR LOGFILE GROUP 3
*
ERROR at line 1: --系統處於非歸檔模式,且group 3狀態為CURRENT
ORA-00350: log 3 of instance orcl (thread 1) needs to be archived
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl/redo3a.rdo'
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl/redo3b.rdo'
--嘗試使用不歸檔清空日誌
SQL> ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 3;
ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 3
*
ERROR at line 1:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl/redo3b.rdo'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl/redo3a.rdo'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
--使用帶控制檔案的介質恢復
SQL> RECOVER DATABASE USING BACKUP CONTROLFILE;
ORA-00279: change 2835232 generated at 07/20/2010 10:40:23 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2010_07_20/o1_mf_1_39_%u_.arc
ORA-00280: change 2835232 for thread 1 is in sequence #39
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00308: cannot open archived log '/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2010_07_20/o1_mf_1_39_%u_.arc'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
--使用resetlogs選項開啟資料庫
SQL> ALTER DATABASE OPEN RESETLOGS;
Database altered.
SQL> SELECT * FROM v$log; --系統重建group 3
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 2 31457280 2 NO CURRENT 2835234 20-JUL-10
2 1 1 31457280 2 YES INACTIVE 2835233 20-JUL-10
3 1 0 31457280 2 YES UNUSED 0
SQL> SELECT * FROM v$logfile; --為group 3增加了兩個成員redo3a.rdo ,redo3b.rdo
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ------------------------------------------------------- ---
2 ONLINE /u01/app/oracle/oradata/orcl/redo2a.rdo NO
2 ONLINE /u01/app/oracle/oradata/orcl/redo2b.rdo NO
1 ONLINE /u01/app/oracle/oradata/orcl/redo1a.rdo NO
3 ONLINE /u01/app/oracle/oradata/orcl/redo3a.rdo NO
3 ONLINE /u01/app/oracle/oradata/orcl/redo3b.rdo NO
1 ONLINE /u01/app/oracle/oradata/orcl/redo1b.rdo NO
對於CURRENT組的也可以使用隱藏引數來解決
步驟:
alter system set "_allow_resetlogs_corruption" = true scope = spfile;
recover database using bakcup controlfile;
alter database open resetlogs;
shutdown immediate;
startup mount;
alter database open resetlogs;
alter system reset "_allow_resetlogs_corruption" scope = spfile sid = '*'
對於歸檔模式下的日誌檔案丟失,同樣可以按上述步驟處理
有關閃回特性請參考 Oracle教程
Oracle 閃回特性(FLASHBACK DATABASE)
Oracle 閃回特性(FLASHBACK DROP & RECYCLEBIN)
Oracle 閃回特性(Flashback Query、Flashback Table)
Oracle 閃回特性(Flashback Version、Flashback Transaction)
有關基於使用者管理的備份和備份恢復的概念請參考:
Oracle 基於使用者管理恢復的處理(詳細描述了介質恢復及其處理)
有關RMAN的恢復與管理請參考:
有關Oracle體系結構請參考:
Oracle 例項和Oracle資料庫(Oracle體系結構)
Oracle 聯機重做日誌檔案(ONLINE LOG FILE)
Oracle 歸檔日誌
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22969361/viewspace-1102899/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle11g redo log 建立、新增、刪除(重做日誌組,重做日誌檔案)Oracle
- 記錄一則clear重做日誌檔案的案例
- 重做日誌管理
- MySQL 修改InnoDB重做日誌檔案的數量或大小MySql
- MySQL重做日誌(redo log)MySql
- 達夢資料庫DM8之REDOLOG重做日誌檔案管理資料庫
- oracle歸檔日誌Oracle
- 歸檔oracle alert日誌Oracle
- Oracle歸檔日誌清理Oracle
- Archived Redo Logs歸檔重做日誌介紹及其優點Hive
- Oracle使用備份檔案集恢復歸檔日誌Oracle
- 【Oracle】如何修改資料檔案和日誌檔案的路徑Oracle
- 分析Oracle資料庫日誌檔案(三)EPOracle資料庫
- 分析Oracle資料庫日誌檔案(二)DOOracle資料庫
- 分析Oracle資料庫日誌檔案(一)HBOracle資料庫
- 【Oracle】歸檔日誌管理-設定歸檔日誌路徑以及歸檔日誌冗餘Oracle
- 在Oracle中,如何定時刪除歸檔日誌檔案?Oracle
- 【LOG】Oracle資料庫清理日誌、跟蹤檔案利器Oracle資料庫
- 【REDO】Oracle 日誌挖掘,分析歸檔日誌線上日誌主要步驟Oracle
- 【MySQL日誌】MySQL日誌檔案初級管理MySql
- MySQL重做日誌恢復資料的流程MySql
- java專案日誌配置檔案Java
- oracle11G歸檔日誌管理Oracle
- oracle rman備份歸檔日誌需要先切換日誌嗎Oracle
- 日誌檔案過大清理
- sybase iq日誌檔案管理
- MySQL InnoDB日誌檔案配置MySql
- oracle dg 歸檔日誌恢復情況Oracle
- oracle 刪除過期的歸檔日誌Oracle
- 【SQL】Oracle 歸檔日誌暴增原因分析SQLOracle
- Oracle歸檔日誌暴增排查優化Oracle優化
- oracle alert日誌Oracle
- SpringBoot指定日誌檔案和日誌Profile功能Spring Boot
- Laravel 指定日誌檔案記錄任意日誌Laravel
- 探究MySQL中的日誌檔案MySql
- 日誌檔案使用小結(轉)
- mysql的日誌檔案詳解MySql
- lumen 日誌按天生成檔案
- tempdb日誌檔案暴增分析