1. 程式人生 > >oracle日誌檔案頭解析

oracle日誌檔案頭解析

首先,日誌檔案的格式如下:

redo logfile的結構 block 0: file header block 1: redo header block 2: redo record 1 block 3: redo record 2 ... ... block N: redo record n

使用dbfsize(oracle自帶工具)可以檢視redo logfile資訊

SQL> col member for a40 SQL> select member from v$logfile;

MEMBER ---------------------------------------- /u01/app/oradata/QXY/redo03.log /u01/app/oradata/QXY/redo02.log /u01/app/oradata/QXY/redo01.log

SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [[email protected] ~]$ [[email protected] ~]$ dbfsize /u01/app/oradata/QXY/redo01.log

Database file: /u01/app/oradata/QXY/redo01.log Database file type: file system Database file size: 102400 512 byte blocks  <=====含義是redo塊的大小是512位元組,一共有102400個塊 [

[email protected] ~]$

所以redo檔案的大小為 [[email protected] ~]$ bc bc 1.06.95 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. 512*102400 52428800 52428800/1024/1024 50              <========一個redo檔案的大小為50MB

SQL> col member for a40 SQL> select a.member, b.bytes from v$logfile a, v$log b where a.group#=b.group#;

MEMBER                                        BYTES ---------------------------------------- ---------- /u01/app/oradata/QXY/redo03.log            52428800 /u01/app/oradata/QXY/redo02.log            52428800 /u01/app/oradata/QXY/redo01.log            52428800    <=======redo大小50MB

SQL>

1、解讀redo logfile的檔案頭

解析redo logfile header block(redo檔案的第一個塊)
[[email protected] ~]$ dd if=/u01/app/oradata/QXY/redo01.log bs=512 count=1 | od -x
1+0 records in
1+0 records out
512 bytes (512 B) copied, 3.0992e-05 s, 16.5 MB/s
0000000 2200 0000 0000 ffc0 0000 0000 0000 0000     <======第一行
0000020 c867 0000 0200 0000 9000 0001 7c7d 7a7b              二
0000040 81a0 0000 0000 0000 0000 0000 0000 0000              三
0000060 0000 0000 0000 0000 0000 0000 0000 0000              四
*
0001000
[[email protected] ~]$ 
第一行的 2200     ----表示file type,0x22代表redo logfile
第二行的 0200     ----表示redo block 大小,轉換成十進位制為512
第二行的 9000 0001 -----大小端轉換後是00019000,轉換成十進位制為102400
第二行的 7c7d 7a7b -----代表邏輯號

SQL> select to_number('0200','xxxx') from dual;

TO_NUMBER('0200','XXXX')
------------------------
                     512

SQL> select to_number('00019000','xxxxxxxx') from dual;

TO_NUMBER('00019000','XXXXXXXX')
--------------------------------
                          102400

SQL> 

可以看到通過dd+od的方式讀取的redo logfile的第一塊的內容和dbfsize看到的資料一致,redo logfile 檔案頭主要
描述該該檔案是什麼型別的檔案,每個塊大小是多少,一共有多少個塊等。

2、解讀redo logfile的redo header(第二個塊)

[[email protected] ~]$ dd if=/u01/app/oradata/QXY/redo01.log skip=1 bs=512 count=1 | od -x  <=====skip=1,也就是跳過redo logfile的檔案頭塊(第一個塊)
1+0 records in
1+0 records out
512 bytes (512 B) copied, 3.5083e-05 s, 14.6 MB/s
0000000 2201 0000 0001 0000 0001 0000 8000 6f2c
0000020 0000 0000 0000 0b20 f07a fc4a 5851 0059
0000040 0000 0000 448a 0000 9000 0001 0200 0000
0000060 0001 0002 80c2 ff13 0000 0000 0000 0000
0000100 0000 0000 0000 0000 0000 0000 0000 0000
0000120 0000 0000 0000 0000 0000 0000 6854 6572
0000140 6461 3020 3030 2c31 5320 7165 2023 3030
0000160 3030 3030 3030 3130 202c 4353 204e 7830
0000200 3030 3030 3130 6637 3639 3331 302d 3078
0000220 3030 3030 3731 6666 3463 0063 4804 0000
0000240 ea1c 3ad1 9613 017f 0000 0000 0006 0000
0000260 0001 0000 9613 017f 0000 0000 ea1c 3ad1
0000300 fc4c 017f 0000 0000 4967 3ad3 0000 0208
0000320 9613 017f 0000 0000 ea1c 3ad1 fc4a 017f
0000340 0000 0000 28da 3ad2 0000 0000 0000 0080
0000360 0000 0000 0000 0000 0000 0000 0002 0000
0000400 0000 0000 0000 0000 0000 0000 0000 0000
0000420 0000 0000 0000 0000 0000 0000 9392 017f
0000440 0000 0000 e8f9 3ad1 0000 0000 0000 0000
0000460 0000 0000 0000 0000 0000 0000 0000 0000
*
0000700 5b73 a77c 06b1 482f 5802 3aaa a734 35fa
0000720 5e8c 05f2 25fe 9da5 996b 149e 5f26 1e03
0000740 0005 0000 0000 0000 0000 0000 0000 0000
0000760 0000 0000 0000 0000 0000 0000 0000 0000
0001000
[[email protected] ~]$

offset 0~1  :2201    ----表示redo logfile block,redo block的第一個塊都是這個值
offset 4~5  :0001    ----表示redo log block nuber號
offset 8~9  :0001    ----表示redo log sequence 號
offset 12~13:8000    ----表示offset值
上面部分內容結合在一起,就是redo的RBA資訊
RBA = logseq+log block number +offset = 0x000001.00000001.0008

offset 14~15: 6f2c   ----表示checksum
offset 20~23:0000 0b20   ----表示db version , 對應redo dump裡面的 Compatibility Vsn = 186646528=0xb200000
offset 24~27: f07a fc4a   ----表示DB ID值,大小端轉換後為fc4af07a,轉換10進製為4232769658
offset 28~33: 5851 0059 0000  ----代表DB Name,轉換後為QXY


下面對上面資訊轉換說明
SQL> select to_number('fc4af07a','xxxxxxxx') from dual;  <====對應offset 24~27 表示DBID

TO_NUMBER('FC4AF07A','XXXXXXXX')
--------------------------------
                      4232769658

SQL> 
SQL> select dbid from v$database;

      DBID
----------
4232769658

SQL> 
SQL> 

SQL> select utl_raw.cast_to_varchar2('51585900') from dual;  <======對應offset28~33

UTL_RAW.CAST_TO_VARCHAR2('51585900')
--------------------------------------------------------------------------------
QXY

SQL> 

====下面是redo dump的資訊來進一步說明
SQL> 
SQL> alter system dump logfile '/u01/app/oradata/QXY/redo01.log';

System altered.

SQL>

<=====redo 檔案頭資訊
DUMP OF REDO FROM FILE '/u01/app/oradata/QXY/redo01.log'
 Opcodes *.*
 RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
 SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
 Times: creation thru eternity
 FILE HEADER: 
        Compatibility Vsn = 186646528=0xb200000   <=====對應offset 20~23
        Db ID=4232769658=0xfc4af07a, Db Name='QXY'<=====分別對應offset 24~33
...
... <====先省略
...


接著看redo header的資訊
offset 36~37 :448a   ----表示control seq的值,轉換成10進製為17546
offset 40~43 :9000 0001  ----表示file size,單位是redo block個數,轉換成10進製為102400
offset 44~45 :0200      ----表示redo block size的大小,轉換成10進製為512
offset 48~49 :0001     ----表示file number號,代表當前是redo的第一個檔案
offset 50~51 :0002     ----表示file type的值,redo檔案都是0002.
offset 52~55 :80c2 ff13  ---表示Activation ID的值,轉換成10進位制
offset 92~103:6854 6572 6461 3020 3030 2c31 -----代表"Thread 0001,"字元

轉換如下:
SQL> select utl_raw.cast_to_varchar2('54687265616420303030312c') from dual;

UTL_RAW.CAST_TO_VARCHAR2('54687265616420303030312C')
--------------------------------------------------------------------------------
Thread 0001,

SQL> 

offset 104~121: 5320 7165 2023 3030 3030 3030 3030 3130 202c   -----代表log seq號 "Seq# 0000000001,"

轉換如下:
SQL> select utl_raw.cast_to_varchar2('205365712320303030303030303030312c20') from dual;

UTL_RAW.CAST_TO_VARCHAR2('205365712320303030303030303030312C20')
--------------------------------------------------------------------------------
 Seq# 0000000001,

SQL> 

offset 122~153: 4353 204e 7830 3030 3030 3130 6637 3639 3331 302d 3078 3030 3030 3731 6666 3463  ----代表SCN的範圍

轉換如下:
SQL> select utl_raw.cast_to_varchar2('53434e2030783030303030313766393631332d30783030303030313766666334') from dual;

UTL_RAW.CAST_TO_VARCHAR2('53434E2030783030303030313766393631332D3078303030303031
--------------------------------------------------------------------------------
SCN 0x0000017f9613-0x0000017ffc4

SQL> 


offset 154~159: 0063 4804 0000    ---表示thread nab的值
offset 160~163:ea1c 3ad1         ---表示resetlogs count的值
offset 164~167:9613 017f         ---表示resetlogs的scn值
offset 172~173: 0006              ---表示hws的值
offset 176~177:0001              ---表示eot的值
offset 180~183:9613 017f         ---low scn的值
offset 188~191:ea1c 3ad1         ---表示resetlogs的值
offset 192~195:fc4c 017f         ---next scn的值
offset 207~210:9613 017f         ---Enabled scn的值
offset 219~222:fc4a 017f         ---Thread closed scn的值


<=======檢視dump資訊

DUMP OF REDO FROM FILE '/u01/app/oradata/QXY/redo01.log'
 Opcodes *.*
 RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
 SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
 Times: creation thru eternity
 FILE HEADER:
        Compatibility Vsn = 186646528=0xb200000
        Db ID=4232769658=0xfc4af07a, Db Name='QXY'
        Activation ID=4279468226=0xff1380c2
        Control Seq=17546=0x448a, File size=102400=0x19000   <======對應offset 36~43
        File Number=1, Blksiz=512, File Type=2 LOG           <======對應offset 44~51
 descrip:"Thread 0001, Seq# 0000000001, SCN 0x0000017f9613-0x0000017ffc4c"  <======對應offset 92~153
 thread: 1 nab: 0x4804 seq: 0x00000001 hws: 0x6 eot: 0 dis: 0       <======對應offset 154~177
 resetlogs count: 0x3ad1ea1c scn: 0x0000.017f9613 (25138707)        
 prev resetlogs count: 0x3ad1e8f9 scn: 0x0000.017f9392 (25138066)
 Low  scn: 0x0000.017f9613 (25138707) 09/14/2018 16:58:04      <===對應offset 180~183
 Next scn: 0x0000.017ffc4c (25164876) 09/15/2018 17:56:55      <===對應offset 192~195
 Enabled scn: 0x0000.017f9613 (25138707) 09/14/2018 16:58:04   <===對應offset 207~210
 Thread closed scn: 0x0000.017ffc4a (25164874) 09/14/2018 21:25:46  <====對應offset219~222
 Disk cksum: 0x6f2c Calc cksum: 0x6f2c
 Terminal recovery stop scn: 0x0000.00000000
 Terminal recovery  01/01/1988 00:00:00
 Most recent redo scn: 0x0000.00000000

3、模擬redo header損壞

首先對比redo01.log的redo header和 redo02.log的redo header
[[email protected] ~]$ dd if=/u01/app/oradata/QXY/redo01.log skip=1 bs=512 count=1 | od -x   [[email protected] ~]$ dd if=/u01/app/oradata/QXY/redo02.log skip=1 bs=512 count=1 | od -x
1+0 records in                                                                        1+0 records in                                                                     
1+0 records out                                                                       1+0 records out                                                                    
512 bytes (512 B) copied, 3.4739e-05 s, 14.7 MB/s                                     512 bytes (512 B) copied, 7.4561e-05 s, 6.9 MB/s                                   
0000000 2201 0000 0001 0000 0001 0000 8000 6f79                                       0000000 2201 0000 0001 0000 0002 0000 8000 7009                                    
0000020 0000 0000 0000 0b20 f07a fc4a 5851 0059                                       0000020 0000 0000 0000 0b20 f07a fc4a 5851 0059                                    
0000040 0000 0000 44de 0000 9000 0001 0200 0000                                       0000040 0000 0000 44df 0000 9000 0001 0200 0000                                    
0000060 0001 0002 80c2 ff13 0000 0000 0000 0000                                       0000060 0002 0002 80c2 ff13 0000 0000 0000 0000                                    
0000100 0000 0000 0000 0000 0000 0000 0000 0000                                       0000100 0000 0000 0000 0000 0000 0000 0000 0000                                    
0000120 0000 0000 0000 0000 0000 0000 6854 6572                                       0000120 0000 0000 0000 0000 0000 0000 6854 6572                                    
0000140 6461 3020 3030 2c31 5320 7165 2023 3030                                       0000140 6461 3020 3030 2c31 5320 7165 2023 3030                                    
0000160 3030 3030 3030 3130 202c 4353 204e 7830                                       0000160 3030 3030 3030 3230 202c 4353 204e 7830                                    
0000200 3030 3030 3130 6637 3639 3331 302d 3078                                       0000200 3030 3030 3130 6637 6366 6334 302d 3078                                    
0000220 3030 3030 3731 6666 3463 0063 4804 0000                                       0000220 3030 3030 3831 3730 3435 0066 d6b7 0000                                    
0000240 ea1c 3ad1 9613 017f 0000 0000 0007 0000                                       0000240 ea1c 3ad1 9613 017f 0000 0000 0005 0000                                    
0000260 0001 0000 9613 017f 0000 0000 ea1c 3ad1                                       0000260 0001 0000 fc4c 017f 0000 0000 4967 3ad3                                    
0000300 fc4c 017f 0000 0000 4967 3ad3 0000 0208                                       0000300 754f 0180 0000 0000 9462 3ad3 0000 0208                                    
0000320 9613 017f 0000 0000 ea1c 3ad1 fc4a 017f                                       0000320 9613 017f 0000 0000 ea1c 3ad1 754d 0180                                    
0000340 0000 0000 28da 3ad2 0000 0000 0000 0080                                       0000340 0000 0000 92cd 3ad3 0000 0000 0000 0080                                    
0000360 0000 0000 0000 0000 0000 0000 0002 0000                                       0000360 0000 0000 0000 0000 0000 0000 0002 0000                                    
0000400 0000 0000 0000 0000 0000 0000 0000 0000                                       0000400 0000 0000 0000 0000 0000 0000 0000 0000                                    
0000420 0000 0000 0000 0000 0000 0000 9392 017f                                       0000420 0000 0000 0000 0000 0000 0000 9392 017f                                    
0000440 0000 0000 e8f9 3ad1 0000 0000 0000 0000                                       0000440 0000 0000 e8f9 3ad1 0000 0000 0000 0000                                    
0000460 0000 0000 0000 0000 0000 0000 0000 0000                                       0000460 0000 0000 0000 0000 0000 0000 0000 0000                                    
*                                                                                     *                                                                                  
0000700 5b73 a77c 06b1 482f 5802 3aaa a734 35fa                                       0000700 e84d 6c0d eac7 3c17 2203 70aa 6bf3 5e93                                    
0000720 5e8c 05f2 25fe 9da5 996b 149e 5f26 1e03                                       0000720 5e8c 05f2 25fe 9da5 996b 149e 5f26 1e03                                    
0000740 0005 0000 0000 0000 0000 0000 0000 0000                                       0000740 0005 0000 0000 0000 0000 0000 0000 0000                                    
0000760 0000 0000 0000 0000 0000 0000 0000 0000                                       0000760 0000 0000 0000 0000 0000 0000 0000 0000                                    
0001000                                                                               0001000                                                                            
[[email protected] ~]$                                                                       [[email protected] ~]$        

假如現在破壞DBID的位置,也就是redo header的offset 24~27(第二行的f07a fc4a)
轉換二進位制之後為DBID的值,如下所示:
SQL> select to_number('fc4af07a','xxxxxxxx') from dual;  <====對應offset 24~27 表示DBID

TO_NUMBER('FC4AF07A','XXXXXXXX')
--------------------------------
                      4232769658

SQL> 
SQL> select dbid from v$database;

      DBID
----------
4232769658

SQL> 

現在通過dd命令破壞redo01.log的DBID,方法如下:
echo AAAA |dd of=/u01/app/oradata/QXY/redo01.log seek=536 bs=1 count=4 conv=notrunc
其中seek=536代表跳過536個位元組,其中536=512+24,其中512為第一個塊redo file header 然後加上第二個塊的偏移量24,正好為DBID所在的位置

替換之前DBID的值如下:
[[email protected] QXY]$ dd if=/u01/app/oradata/QXY/redo01.log skip=1 bs=512 count=1 | od -x
1+0 records in
1+0 records out
512 bytes (512 B) copied, 3.4274e-05 s, 14.9 MB/s
0000000 2201 0000 0001 0000 0001 0000 8000 6f79
0000020 0000 0000 0000 0b20 f07a fc4a 5851 0059   <=====f07a fc4a
0000040 0000 0000 44de 0000 9000 0001 0200 0000
0000060 0001 0002 80c2 ff13 0000 0000 0000 0000
0000100 0000 0000 0000 0000 0000 0000 0000 0000


用4個A執行替換
[[email protected] QXY]$ echo AAAA |dd of=/u01/app/oradata/QXY/redo01.log seek=536 bs=1 count=4 conv=notrunc
4+0 records in
4+0 records out
4 bytes (4 B) copied, 4.9324e-05 s, 81.1 kB/s


再次查詢
[[email protected] QXY]$ dd if=/u01/app/oradata/QXY/redo01.log skip=1 bs=512 count=1 | od -x
1+0 records in
1+0 records out
512 bytes (512 B) copied, 4.0794e-05 s, 12.6 MB/s
0000000 2201 0000 0001 0000 0001 0000 8000 6f79
0000020 0000 0000 0000 0b20 4141 4141 5851 0059  <====這裡從原來的f07a fc4a 變成了4141 4141
0000040 0000 0000 44de 0000 9000 0001 0200 0000
0000060 0001 0002 80c2 ff13 0000 0000 0000 0000

其中41就是代表A的意思
SQL> select utl_raw.cast_to_varchar2('4141') from dual;

UTL_RAW.CAST_TO_VARCHAR2('41414141')
--------------------------------------------------------------------------------
AAAA



重新啟動資料庫報如下錯誤:
[[email protected] ~]$ o

SQL*Plus: Release 11.2.0.3.0 Production on Sat Sep 15 23:41:53 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup 
ORACLE instance started.

Total System Global Area  776646656 bytes
Fixed Size                  2232392 bytes
Variable Size             603983800 bytes
Database Buffers          163577856 bytes
Redo Buffers                6852608 bytes
Database mounted.
ORA-00366: log 1 of thread 1, checksum error in the file header
ORA-00312: online log 1 thread 1: '/u01/app/oradata/QXY/redo01.log'


SQL> 


後臺日誌錯誤如下:
starting up 1 shared server(s) ...
ORACLE_BASE from environment = /u01/app
Sat Sep 15 23:41:57 2018
ALTER DATABASE   MOUNT
Successful mount of redo thread 1, with mount id 4279599365
Database mounted in Exclusive Mode
Lost write protection disabled
Completed: ALTER DATABASE   MOUNT
Sat Sep 15 23:42:01 2018
ALTER DATABASE OPEN
Beginning crash recovery of 1 threads
 parallel recovery started with 2 processes
Started redo scan
Errors in file /u01/app/diag/rdbms/qxy/QXY/trace/QXY_ora_4176.trc:
ORA-00366: log 1 of thread 1, checksum error in the file header
ORA-00312: online log 1 thread 1: '/u01/app/oradata/QXY/redo01.log'
Aborting crash recovery due to error 366
Errors in file /u01/app/diag/rdbms/qxy/QXY/trace/QXY_ora_4176.trc:
ORA-00366: log 1 of thread 1, checksum error in the file header
ORA-00312: online log 1 thread 1: '/u01/app/oradata/QXY/redo01.log'
Errors in file /u01/app/diag/rdbms/qxy/QXY/trace/QXY_ora_4176.trc:
ORA-00366: log 1 of thread 1, checksum error in the file header
ORA-00312: online log 1 thread 1: '/u01/app/oradata/QXY/redo01.log'
ORA-366 signalled during: ALTER DATABASE OPEN...
Sat Sep 15 23:42:01 2018
Errors in file /u01/app/diag/rdbms/qxy/QXY/trace/QXY_m000_4182.trc:
ORA-00366: log 1 of thread 1, checksum error in the file header
ORA-00312: online log 1 thread 1: '/u01/app/oradata/QXY/redo01.log'
Checker run found 2 new persistent data failures



[[email protected] ~]$ more /u01/app/diag/rdbms/qxy/QXY/trace/QXY_ora_4176.trc
Trace file /u01/app/diag/rdbms/qxy/QXY/trace/QXY_ora_4176.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1
System name:    Linux
Node name:      qxy.localdomain
Release:        2.6.32-431.el6.x86_64
Version:        #1 SMP Sun Nov 10 22:19:54 EST 2013
Machine:        x86_64
VM name:        VMWare Version: 6
Instance name: QXY
Redo thread mounted by this instance: 1
Oracle process number: 19
Unix process pid: 4176, image: [email protected] (TNS V1-V3)


*** 2018-09-15 23:42:01.720
*** SESSION ID:(125.5) 2018-09-15 23:42:01.720
*** CLIENT ID:() 2018-09-15 23:42:01.720
*** SERVICE NAME:() 2018-09-15 23:42:01.720
*** MODULE NAME:([email protected] (TNS V1-V3)) 2018-09-15 23:42:01.720
*** ACTION NAME:() 2018-09-15 23:42:01.720
 
Successfully allocated 2 recovery slaves
Using 67 overflow buffers per recovery slave
Thread 1 checkpoint: logseq 4, block 83, scn 25197573
    on-disk rba: logseq 4, block 179, scn 25197821
  start recovery at logseq 4, block 179, scn 25197821
DDE rules only execution for: ORA 312
----- START Event Driven Actions Dump ----
---- END Event Driven Actions Dump ----
----- START DDE Actions Dump -----
Executing SYNC actions
----- START DDE Action: 'DB_STRUCTURE_INTEGRITY_CHECK' (Async) -----
Successfully dispatched
----- END DDE Action: 'DB_STRUCTURE_INTEGRITY_CHECK' (SUCCESS, 1 csec) -----
Executing ASYNC actions
----- END DDE Actions Dump (total 1 csec) -----
ORA-00366: log 1 of thread 1, checksum error in the file header
ORA-00312: online log 1 thread 1: '/u01/app/oradata/QXY/redo01.log'
ORA-00366: log 1 of thread 1, checksum error in the file header
ORA-00312: online log 1 thread 1: '/u01/app/oradata/QXY/redo01.log'
ORA-00366: log 1 of thread 1, checksum error in the file header
ORA-00312: online log 1 thread 1: '/u01/app/oradata/QXY/redo01.log'
[[email protected] ~]$ 
[[email protected] ~]$ 




使用dd重新修改redo01.log檔案的DBID的值
修改前:
[[email protected] QXY]$ dd if=/u01/app/oradata/QXY/redo01.log skip=1 bs=512 count=1 | od -x
1+0 records in
1+0 records out
512 bytes (512 B) copied, 7.1318e-05 s, 7.2 MB/s
0000000 2201 0000 0001 0000 0004 0000 8000 6403
0000020 0000 0000 0000 0b20 4141 4141 5851 0059   <=====41414141
0000040 0000 0000 44f3 0000 9000 0001 0200 0000
0000060 0001 0002 80c2 ff13 0000 0000 0000 0000
0000100 0000 0000 0000 0000 0000 0000 0000 0000
0000120 0000 0000 0000 0000 0000 0000 6854 6572
0000140 6461 3020 3030 2c31 5320 7165 2023 3030


修改DBID為f07a fc4a,下面使用一個正常的redo02的檔案頭的DBID覆蓋有問題redo01的DBID的值
[[email protected] QXY]$ 
[[email protected] QXY]$ dd if=redo02.log skip=536 bs=1 count=4 of=/u01/app/oradata/QXY/redo01.log seek=536 bs=1 count=4 conv=notrunc
4+0 records in
4+0 records out
4 bytes (4 B) copied, 0.000988096 s, 4.0 kB/s


修改後的值如下:
[[email protected] QXY]$ dd if=/u01/app/oradata/QXY/redo01.log skip=1 bs=512 count=1 | od -x
1+0 records in
1+0 records out
512 bytes (512 B) copied, 6.2949e-05 s, 8.1 MB/s
0000000 2201 0000 0001 0000 0004 0000 8000 6403
0000020 0000 0000 0000 0b20 f07a fc4a 5851 0059   <=====由原來的41414141變為f07a fc4a
0000040 0000 0000 44f3 0000 9000 0001 0200 0000
0000060 0001 0002 80c2 ff13 0000 0000 0000 0000
0000100 0000 0000 0000 0000 0000 0000 0000 0000



重新啟動資料庫

SQL>   shutdown immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> 
SQL> startup
ORACLE instance started.

Total System Global Area  776646656 bytes
Fixed Size                  2232392 bytes
Variable Size             603983800 bytes
Database Buffers          163577856 bytes
Redo Buffers                6852608 bytes
Database mounted.
Database opened.                      <=====資料庫正常啟動
SQL> 

4、總結

      如果能夠對redo header比較瞭解的話,就可以使用特殊手段來修復一些redo lheader損壞的情況,特別是當current的redo header出現問題,這個時候更有必要修復。如果認真對比redo01.log和redo02.log的redo header會發現兩個檔案的資料基本都是一致的,只有個別地方是每個redo file特有的。所以當一個redo logfile header損壞的情況下,可以參考他正常redo header的內容來修復損壞的redo header。