[20170309]dg環境下線上日誌損壞13.txt

lfree發表於2017-03-09

[20170309]dg環境下線上日誌損壞13.txt

http://blog.itpub.net/267265/viewspace-2134665/
http://blog.itpub.net/267265/viewspace-2134481/

--//按照如下連結,複製備用日誌到主庫,修改檔案頭偏移0x230 日誌組號.以及hws,eot對應位置,欺騙oracle是正常的日誌檔案.
http://blog.itpub.net/267265/viewspace-2134816/

--//看了一些文件,在論壇問一下,感覺修改組號以及eot=1就ok了,hws不用修改.到現在還不理解hws表示什麼??
--//我在論壇問hws等表示什麼?連結
http://www.itpub.net/thread-2084723-1-1.html
eot : End Of Thread: indicates if this is the last log
hws = Hdr Write Seq#
dis : DISabled - true if thread disabled at end of this log
--//再次感謝劉工的解答. eot=1明顯表示當前日誌,而備用日誌這裡是0,感覺修改這裡才是關鍵.
--//測試看看這樣的情況:

1.環境:

--//首先還原環境,我包括異常關機的冷備份,複製回來,刪除主庫的線上日誌以及備用日誌.

SYS@book> @ &r/ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SYS@book> @ &r/logfile
GROUP# STATUS TYPE    MEMBER                          IS_ GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARC STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ------ ------- ------------------------------- --- ------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ -------------------
     1        ONLINE  /mnt/ramdisk/book/redo01.log    NO       1       1       695    52428800       512       1 NO  CURRENT      13276910949 2017-02-28 14:40:12 2.814750E+14
     2        ONLINE  /mnt/ramdisk/book/redo02.log    NO       2       1       693    52428800       512       1 YES INACTIVE     13276889179 2017-02-27 08:59:01  13276910486 2017-02-28 14:40:06
     3        ONLINE  /mnt/ramdisk/book/redo03.log    NO       3       1       694    52428800       512       1 YES ACTIVE       13276910486 2017-02-28 14:40:06  13276910949 2017-02-28 14:40:12
     4        STANDBY /mnt/ramdisk/book/redostb01.log NO
     5        STANDBY /mnt/ramdisk/book/redostb02.log NO
     6        STANDBY /mnt/ramdisk/book/redostb03.log NO
     7        STANDBY /mnt/ramdisk/book/redostb04.log NO
7 rows selected.

--//一些操作參考,不再重複:
http://blog.itpub.net/267265/viewspace-2134816/

2.複製備用日誌到主機:
$ scp /mnt/ramdisk/book/redostb01.log oracle@192.168.100.78:/mnt/ramdisk/book/redo01.log
oracle@192.168.100.78's password:
redostb01.log      100%   50MB  25.0MB/s   00:02

--//注意這樣因為redo的檔案頭不一樣,oracle不會認為那個檔案group#1的.

3.修改備用日誌檔案.

$ bvi80 -s 512 -b 512 /mnt/ramdisk/book/redo01.log
00000200  01 22 00 00 01 00 00 00 B7 02 00 00 00 80 9C B5 ................
00000210  00 00 00 00 00 04 20 0B 6E 21 B7 4F 42 4F 4F 4B ...... .n!.OBOOK
00000220  00 00 00 00 2D 8D 00 00 00 90 01 00 00 02 00 00 ....-...........
00000230  04 00 02 00 6E D8 B7 4F 00 00 00 00 00 00 00 00 ....n..O........
          ~~
00000240  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000250  00 00 00 00 00 00 00 00 00 00 00 00 54 68 72 65 ............Thre
00000260  61 64 20 30 30 30 31 2C 20 53 65 71 23 20 30 30 ad 0001, Seq# 00
00000270  30 30 30 30 30 36 39 35 2C 20 53 43 4E 20 30 78 00000695, SCN 0x
00000280  30 30 30 33 31 37 35 64 39 35 36 35 2D 30 78 66 0003175d9565-0xf
00000290  66 66 66 66 66 66 66 66 66 66 66 00 FF FF FF FF fffffffffff.....
000002A0  B0 1E 71 35 06 20 0E 00 00 00 00 00 02 00 00 00 ..q5. ..........
000002B0  01 00 00 00 65 95 5D 17 03 00 00 00 4C BB DB 37 ....e.].....L..7
000002C0  FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 02 ................
                                              ~~
000002D0  06 20 0E 00 00 00 00 00 B0 1E 71 35 65 95 5D 17 . ........q5e.].
000002E0  03 00 00 00 4C BB DB 37 00 00 00 00 00 20 82 00 ....L..7..... ..
000002F0  00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 ................
00000300  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000310  00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 ................
00000320  00 00 00 00 7A C9 21 31 00 00 00 00 00 00 00 00 ....z.!1........
00000330  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000340  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000350  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000360  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000370  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000380  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000390  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003A0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003B0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003C0  12 E9 26 F7 7B 40 C0 80 DC 71 6E 8A 26 4C 32 9F ..&.{@...qn.&L2.
000003D0  27 F7 6C 1F 74 8A 40 20 48 9C 47 0B 46 31 76 E0 '.l.t.@ H.G.F1v.
000003E0  05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000003F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000400 }

--//修改0x230處 0x04=>0x01. 將group#=1
--//修改0x2CA處 0x00=>0x01. 將eot=1.
--//9CB5 0400 0100 0000 0100  重新做異或操作

$ xor.sh a.txt
9CB5
0400
0100
0000
0100
xor result: 98B5

--//修改0x14,0x15 9CB5=>98B5
--//做異或參考連結:http://blog.itpub.net/267265/viewspace-2134945/

SYS@book> alter system dump logfile '/mnt/ramdisk/book/redo01.log' validate;
System altered.

DUMP OF REDO FROM FILE '/mnt/ramdisk/book/redo01.log'
Opcodes *.*
RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
VALIDATE ONLY
FILE HEADER:
    Compatibility Vsn = 186647552=0xb200400
    Db ID=1337401710=0x4fb7216e, Db Name='BOOK'
    Activation ID=1337448558=0x4fb7d86e
    Control Seq=36141=0x8d2d, File size=102400=0x19000
    File Number=1, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000695, SCN 0x0003175d9565-0xffffffffffff"
thread: 1 nab: 0xffffffff seq: 0x000002b7 hws: 0x2 eot: 1 dis: 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
resetlogs count: 0x35711eb0 scn: 0x0000.000e2006 (925702)
prev resetlogs count: 0x3121c97a scn: 0x0000.00000001 (1)
Low  scn: 0x0003.175d9565 (13276910949) 02/28/2017 14:40:12
Next scn: 0xffff.ffffffff 01/01/1988 00:00:00
Enabled scn: 0x0000.000e2006 (925702) 11/24/2015 09:11:12
Thread closed scn: 0x0003.175d9565 (13276910949) 02/28/2017 14:40:12
Disk cksum: 0xb598 Calc cksum: 0xb598
Terminal recovery stop scn: 0x0000.00000000
Terminal recovery  01/01/1988 00:00:00
Most recent redo scn: 0x0000.00000000
Largest LWN: 0 blocks
End-of-redo stream : No
Maximize performance mode
Miscellaneous flags: 0x822000
Thread internal enable indicator: thr: 0, seq: 0 scn: 0x0000.00000000
Zero blocks: 0
Format ID is 2
redo log key is 12e926f77b40c080dc716e8a264c329f
redo log key flag is 5
Enabled redo threads: 1
END OF REDO DUMP

--//注意看~部分.

4.測試恢復:

SYS@book> recover database  ;
ORA-00279: change 13276910487 generated at 02/28/2017 14:40:06 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/archivelog/book/1_694_896605872.dbf
ORA-00280: change 13276910487 for thread 1 is in sequence #694
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00283: recovery session canceled due to errors
ORA-00338: log 1 of thread 1 is more recent than control file
ORA-00312: online log 1 thread 1: '/mnt/ramdisk/book/redo01.log'
ORA-01112: media recovery not started


SYS@book> recover database  until cancel;
ORA-00279: change 13276910949 generated at 02/28/2017 14:40:12 needed for thread 1
ORA-00289: suggestion : /u01/app/oracle/archivelog/book/1_695_896605872.dbf
ORA-00280: change 13276910949 for thread 1 is in sequence #695
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/mnt/ramdisk/book/redo01.log
Log applied.
Media recovery complete.

--//最終確定僅僅修改日誌組號以及eot標識為1.

SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE#  , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name  FROM v$datafile_header where file#=1;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME     CREATION_CHANGE# RESETLOGS_CHANGE# STATUS     CHECKPOINT_COUNT FUZ NAME                           TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ---------- ---------------- --- ------------------------------ ---------------
    1        13276911100 2017-02-28 14:42:35                7            925702 ONLINE                  839 NO  /mnt/ramdisk/book/system01.dbf SYSTEM

--//scn = 13276911100.

--//剩下的重複連結http://blog.itpub.net/267265/viewspace-2134816/操作.
--//確認這個檔案記錄的是seq#=694的日誌檔案.
$ scp /mnt/ramdisk/book/redostb02.log oracle@192.168.100.78:/mnt/ramdisk/book/redo03.log
oracle@192.168.100.78's password:
redostb02.log       100%   50MB  50.0MB/s   00:01

$ bvi80 -b 512 -s 512 /mnt/ramdisk/book/redo03.log
--//僅僅需要修改0x230處 0x0500 => 0x0300,重新計算檢查和.
2B19
0500
0300
----
2D19

--//這個過程略.
SYS@book> alter database clear  logfile group 2 ;
Database altered.

alter database clear  logfile group 4 ;
alter database clear  logfile group 5 ;
alter database clear  logfile group 6 ;
alter database clear  logfile group 7 ;

5.開啟看看:

SYS@book> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SYS@book> alter database open noresetlogs;
Database altered.
--//還第一次這樣打這個命令使用noresetlogs開啟.
--//ok,可以確定日誌組號以及eot標識就ok了.

SYS@bookdg> @ &r/dg/dg
PROCESS       PID STATUS       CLIENT_P GROUP# THREAD#  SEQUENCE#     BLOCK#     BLOCKS DELAY_MINS
--------- ------- ------------ -------- ------ ------- ---------- ---------- ---------- ----------
RFS         25707 IDLE         UNKNOWN  N/A          0          0          0          0          0
RFS         25709 IDLE         LGWR     3            1        697         19          1          0
ARCH        25658 CLOSING      ARCH     4            1        695          1        154          0
MRP0        25701 APPLYING_LOG N/A      N/A          1        697         19     102400          0
--//日誌傳輸與應用沒有問題.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2134979/,如需轉載,請註明出處,否則將追究法律責任。

相關文章