【BBED】 SYSTEM檔案頭損壞的恢復(4)
【BBED】 SYSTEM檔案頭損壞的恢復
1.1 BLOG文件結構圖
1.2 前言部分
1.2.1 導讀和注意事項
各位技術愛好者,看完本文後,你可以掌握如下的技能,也可以學到一些其它你所不知道的知識,~O(∩_∩)O~:
① BBED恢復SYSTEM檔案頭
② BBED檢視檔案頭的資訊
Tips:
① 若文章程式碼格式有錯亂,推薦使用QQ、搜狗或360瀏覽器,也可以下載pdf格式的文件來檢視,pdf文件下載地址: (提取碼:ed9b)
② 本篇BLOG中命令的輸出部分需要特別關注的地方我都用灰色背景和粉紅色字型來表示,比如下邊的例子中,thread 1的最大歸檔日誌號為33,thread 2的最大歸檔日誌號為43是需要特別關注的地方;而命令一般使用黃色背景和紅色字型標注;對程式碼或程式碼輸出部分的注釋一般採用藍色字型表示。
List of Archived Logs in backup set 11
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- ------------------- ---------- ---------
1 32 1621589 2015-05-29 11:09:52 1625242 2015-05-29 11:15:48
1 33 1625242 2015-05-29 11:15:48 1625293 2015-05-29 11:15:58
2 42 1613951 2015-05-29 10:41:18 1625245 2015-05-29 11:15:49
2 43 1625245 2015-05-29 11:15:49 1625253 2015-05-29 11:15:53
[ZFXXDB1:root]:/>lsvg -o
T_XDESK_APP1_vg
rootvg
[ZFXXDB1:root]:/>
00:27:22 SQL> alter tablespace idxtbs read write;
====》2097152*512/1024/1024/1024=1G
本文如有錯誤或不完善的地方請大家多多指正,ITPUB留言或QQ皆可,您的批評指正是我寫作的最大動力。
1.2.2 相關參考文章連結
【推薦】 【BBED】 sys.bootstrap$ 物件的恢復:http://blog.itpub.net/26736162/viewspace-2083621/
【推薦】 【BBED】丟失歸檔檔案情況下的恢復:http://blog.itpub.net/26736162/viewspace-2079337/
【推薦】 【BBED】編譯及基本命令(1):http://blog.itpub.net/26736162/viewspace-2075216/
1.2.3 本文簡介
本文的實驗過程主要是為了學習BBED,大家學完做完這1篇還有之前的3篇blog,那麼BBED基本算是入門了,恭喜。
1.3 相關知識點掃盲(摘自網路)
---------------------------------------------------------------------------------------------------------------------
第二章 實驗部分
2.1 實驗環境介紹
專案 |
db |
db 型別 |
單例項 |
db version |
11.2.0.4.0 |
db 儲存 |
FS |
主機IP地址/hosts配置 |
192.168.59.129 |
OS版本及kernel版本 |
AIX 7.1 64位 |
歸檔模式 |
Archive Mode |
ORACLE_SID |
oralhr |
2.2 實驗目標
破壞SYSTEM的檔案頭,然後利用SYSAUX檔案的檔案頭來恢復SYSTEM檔案頭。
2.3 實驗過程
2.3.1 冷備system檔案
[ZHLHRDB2:oracle]:/oracle>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 14 16:10:07 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SYS@oralhr> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@oralhr> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
[ZHLHRDB2:oracle]:/oracle>cp /oracle/app/oracle/datafile/oralhr/system01.dbf /oracle/app/oracle/datafile/oralhr/system01.dbf_bk
[ZHLHRDB2:oracle]:/oracle>
[ZHLHRDB2:oracle]:/oracle>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 14 16:34:04 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SYS@oralhr> startup
ORACLE instance started.
Total System Global Area 3089920000 bytes
Fixed Size 2250360 bytes
Variable Size 721422728 bytes
Database Buffers 2348810240 bytes
Redo Buffers 17436672 bytes
Database mounted.
Database opened.
SYS@oralhr>
SYS@oralhr> set line 9999 pagesize 9999
SYS@oralhr> col name format a80
SYS@oralhr> select file#||' '||name||' '||bytes name from v$datafile;
NAME
--------------------------------------------------------------------------------
1 /oracle/app/oracle/datafile/oralhr/system01.dbf 786432000
2 /oracle/app/oracle/datafile/oralhr/sysaux01.dbf 576716800
3 /oracle/app/oracle/datafile/oralhr/undotbs01.dbf 78643200
4 /oracle/app/oracle/datafile/oralhr/users01.dbf 310640640
SYS@oralhr>
2.3.2 模擬故障
[ZHLHRDB2:oracle]:/home/oracle>l
total 208
-rwxrwxrwx 1 oracle dba 57 Apr 05 17:01 bbed.par
-rwxrwxrwx 1 oracle dba 52224 Apr 14 15:55 bifile.bbd
-rwxrwxrwx 1 oracle asmadmin 5715 Apr 06 15:34 ctl.sql
-rwxrwxrwx 1 oracle dba 302 Apr 14 10:32 file.txt
drwxrwxrwx 8 oracle dba 4096 Apr 13 17:16 gdul
-rwxrwxrwx 1 oracle dba 21008 Apr 14 16:35 log.bbd
drwxrwxrwx 4 oracle dba 256 Apr 12 15:52 oracle_bk
drwxrwxrwx 4 oracle dba 256 Apr 05 16:54 rman_bak
-rwxrwxrwx 1 oracle dba 757 Apr 11 10:02 rman_bk_db_archive_lhr.sh
-rwxrwxrwx 1 oracle dba 1023 Apr 08 11:25 rman_bk_db_lhr.sh
[ZHLHRDB2:oracle]:/home/oracle>cat file.txt
1 /oracle/app/oracle/datafile/oralhr/system01.dbf 786432000
2 /oracle/app/oracle/datafile/oralhr/sysaux01.dbf 566231040
3 /oracle/app/oracle/datafile/oralhr/undotbs01.dbf 78643200
4 /oracle/app/oracle/datafile/oralhr/users01.dbf 310640640
5 /oracle/app/oracle/datafile/oralhr/system01.dbf_bk 786432000
[ZHLHRDB2:oracle]:/home/oracle>bbed PASSWORD=blockedit mode=edit blocksize=8192 listfile=/home/oracle/file.txt
BBED: Release 2.0.0.0.0 - Limited Production on Thu Apr 14 16:36:00 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> info
File# Name Size(blks)
----- ---- ----------
1 /oracle/app/oracle/datafile/oralhr/system01.dbf 96000
2 /oracle/app/oracle/datafile/oralhr/sysaux01.dbf 69120
3 /oracle/app/oracle/datafile/oralhr/undotbs01.dbf 9600
4 /oracle/app/oracle/datafile/oralhr/users01.dbf 37920
5 /oracle/app/oracle/datafile/oralhr/system01.dbf_bk 96000
BBED> help copy
COPY [ DBA | FILE | FILENAME | BLOCK ] TO [ DBA | FILE | FILENAME | BLOCK ]
BBED> set count 128
COUNT 128
BBED> copy file 1 block 111 to file 1 block 1
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) Y
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 377 Offsets: 0 to 127 Dba:0x00400179
------------------------------------------------------------------------
1ea20000 0040006f 000000e2 00000104 fa4c0000 00000001 03450080 00000000
00000000 0000f800 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes="" per="" line="">
BBED> sum apply
Check value for File 1, Block 380:
current = 0xfa4c, required = 0xfa4c
BBED>
BBED>
重啟資料庫:
SYS@oralhr> startup force
ORACLE instance started.
Total System Global Area 3089920000 bytes
Fixed Size 2250360 bytes
Variable Size 721422728 bytes
Database Buffers 2348810240 bytes
Redo Buffers 17436672 bytes
Database mounted.
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/oracle/app/oracle/datafile/oralhr/system01.dbf'
ORA-01210: data file header is media corrupt
SYS@oralhr>
告警日誌:
Fri Apr 15 08:52:22 2016
ALTER DATABASE OPEN
Read of datafile '/oracle/app/oracle/datafile/oralhr/system01.dbf' (fno 1) header failed with ORA-01210
Hex dump of (file 1, block 1) in trace file /oracle/app/oracle/diag/rdbms/oralhr/oralhr/trace/oralhr_ora_7602280.trc
Corrupt block relative dba: 0x00400001 (file 1, block 1)
Bad header found during datafile header read
Data in bad block:
type: 30 format: 2 rdba: 0x0040006f
last change scn: 0x0000.000000e2 seq: 0x1 flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x00e21e01
check value in block header: 0xfa4c
computed block checksum: 0x0
Rereading datafile 1 header failed with ORA-01210
Errors in file /oracle/app/oracle/diag/rdbms/oralhr/oralhr/trace/oralhr_ora_7602280.trc:
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/oracle/app/oracle/datafile/oralhr/system01.dbf'
ORA-01210: data file header is media corrupt
ORA-1122 signalled during: ALTER DATABASE OPEN...
Fri Apr 15 08:52:23 2016
Checker run found 1 new persistent data failures
ORA-01210: data file header is media corrupt 檔案頭有介質損壞,下邊用BBED來恢復。
2.3.3 故障恢復
[ZHLHRDB2:oracle]:/home/oracle>bbed PASSWORD=blockedit mode=edit blocksize=8192 listfile=/home/oracle/file.txt
BBED: Release 2.0.0.0.0 - Limited Production on Thu Apr 14 16:42:59 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> info
File# Name Size(blks)
----- ---- ----------
1 /oracle/app/oracle/datafile/oralhr/system01.dbf 96000
2 /oracle/app/oracle/datafile/oralhr/sysaux01.dbf 69120
3 /oracle/app/oracle/datafile/oralhr/undotbs01.dbf 9600
4 /oracle/app/oracle/datafile/oralhr/users01.dbf 37920
5 /oracle/app/oracle/datafile/oralhr/system01.dbf_bk 96000
BBED> set count 128
COUNT 128
BBED>
BBED> set dba 1,1
DBA 0x00400001 (4194305 1,1)
BBED> map /v
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Dba:0x00400001
------------------------------------------------------------
BBED-00400: invalid blocktype (30)
BBED>
可以看到dba 1,1是一個非法的塊型別,下邊利用BBED將SYSAUX上的FILE HEADER複製到SYSTEM上,然後修改檔案頭相關的內容:
BBED> copy file 2 block 1 to file 1 block 1
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 0 to 511 Dba:0x00400001
------------------------------------------------------------------------
0ba20000 00800001 00000000 00000104 ed220000 00000000 0b200400 1793c969
4f52414c 48520000 0000093b 00011300 00002000 00020003 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000716 00000000 3155becc 362e0deb 000e20dc 00007f18 00000000
00000000 00000000 00000004 000000a6 3630b88e 000000a5 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000001 00065359 53415558 00000000 00000000
00000000 00000000 00000000 00000000 00000002 00000000 00000000 00000000
00000000 0000b7e0 00000000 00000000 00000000 00000000 00000000 00000000
3155bebd 00000001 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 0013e5a8 0000c388 363142ec 00010000 0000002d 00000002 00100000
<32 bytes="" per="" line="">
BBED> sum apply
Check value for File 1, Block 1:
current = 0xed22, required = 0xed22
BBED> map /v
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Dba:0x00400001
------------------------------------------------------------
Data File Header
struct kcvfh, 860 bytes @0
struct kcvfhbfh, 20 bytes @0
struct kcvfhhdr, 76 bytes @20
ub4 kcvfhrdb @96
struct kcvfhcrs, 8 bytes @100
ub4 kcvfhcrt @108
ub4 kcvfhrlc @112
struct kcvfhrls, 8 bytes @116
ub4 kcvfhbti @124
struct kcvfhbsc, 8 bytes @128
ub2 kcvfhbth @136
ub2 kcvfhsta @138
struct kcvfhckp, 160 bytes @484
ub4 kcvfhcpc @140
ub4 kcvfhrts @144
ub4 kcvfhccc @148
struct kcvfhbcp, 160 bytes @152
ub4 kcvfhbhz @312
struct kcvfhxcd, 16 bytes @316
sword kcvfhtsn @332
ub2 kcvfhtln @336
text kcvfhtnm[30] @338
ub4 kcvfhrfn @368
struct kcvfhrfs, 8 bytes @372
ub4 kcvfhrft @380
struct kcvfhafs, 8 bytes @384
ub4 kcvfhbbc @392
ub4 kcvfhncb @396
ub4 kcvfhmcb @400
ub4 kcvfhlcb @404
ub4 kcvfhbcs @408
ub2 kcvfhofb @412
ub2 kcvfhnfb @414
ub4 kcvfhprc @416
struct kcvfhprs, 8 bytes @420
struct kcvfhprfs, 8 bytes @428
ub4 kcvfhtrt @444
ub4 tailchk @8188
BBED>
BBED> p kcvfh
struct kcvfh, 860 bytes @0
struct kcvfhbfh, 20 bytes @0
ub1 type_kcbh @0 0x0b
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x00800001
ub4 bas_kcbh @8 0x00000000
ub2 wrp_kcbh @12 0x0000
ub1 seq_kcbh @14 0x01
ub1 flg_kcbh @15 0x04 (KCBHFCKV)
ub2 chkval_kcbh @16 0xed22
ub2 spare3_kcbh @18 0x0000
struct kcvfhhdr, 76 bytes @20
ub4 kccfhswv @20 0x00000000
ub4 kccfhcvn @24 0x0b200400
ub4 kccfhdbi @28 0x1793c969
text kccfhdbn[0] @32 O
text kccfhdbn[1] @33 R
text kccfhdbn[2] @34 A
text kccfhdbn[3] @35 L
text kccfhdbn[4] @36 H
text kccfhdbn[5] @37 R
text kccfhdbn[6] @38
text kccfhdbn[7] @39
ub4 kccfhcsq @40 0x0000093b
ub4 kccfhfsz @44 0x00011300
s_blkz kccfhbsz @48 0x00
ub2 kccfhfno @52 0x0002
ub2 kccfhtyp @54 0x0003
ub4 kccfhacid @56 0x00000000
ub4 kccfhcks @60 0x00000000
text kccfhtag[0] @64
text kccfhtag[1] @65
text kccfhtag[2] @66
text kccfhtag[3] @67
text kccfhtag[4] @68
text kccfhtag[5] @69
text kccfhtag[6] @70
text kccfhtag[7] @71
text kccfhtag[8] @72
text kccfhtag[9] @73
text kccfhtag[10] @74
text kccfhtag[11] @75
text kccfhtag[12] @76
text kccfhtag[13] @77
text kccfhtag[14] @78
text kccfhtag[15] @79
text kccfhtag[16] @80
text kccfhtag[17] @81
text kccfhtag[18] @82
text kccfhtag[19] @83
text kccfhtag[20] @84
text kccfhtag[21] @85
text kccfhtag[22] @86
text kccfhtag[23] @87
text kccfhtag[24] @88
text kccfhtag[25] @89
text kccfhtag[26] @90
text kccfhtag[27] @91
text kccfhtag[28] @92
text kccfhtag[29] @93
text kccfhtag[30] @94
text kccfhtag[31] @95
ub4 kcvfhrdb @96 0x00000000
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00000716
ub2 kscnwrp @104 0x0000
ub4 kcvfhcrt @108 0x3155becc
ub4 kcvfhrlc @112 0x362e0deb
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0x000e20dc
ub2 kscnwrp @120 0x0000
ub4 kcvfhbti @124 0x00000000
struct kcvfhbsc, 8 bytes @128
ub4 kscnbas @128 0x00000000
ub2 kscnwrp @132 0x0000
ub2 kcvfhbth @136 0x0000
ub2 kcvfhsta @138 0x0004 (KCVFHOFZ)
struct kcvfhckp, 160 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x0013e5a8
ub2 kscnwrp @488 0x0000
ub4 kcvcptim @492 0x363142ec
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x0000002d
ub4 kcrbabno @504 0x00000002
ub2 kcrbabof @508 0x0010
ub1 kcvcpetb[0] @512 0x02
ub1 kcvcpetb[1] @513 0x00
ub1 kcvcpetb[2] @514 0x00
ub1 kcvcpetb[3] @515 0x00
ub1 kcvcpetb[4] @516 0x00
ub1 kcvcpetb[5] @517 0x00
ub1 kcvcpetb[6] @518 0x00
ub1 kcvcpetb[7] @519 0x00
ub1 kcvcpetb[8] @520 0x00
ub1 kcvcpetb[9] @521 0x00
ub1 kcvcpetb[10] @522 0x00
ub1 kcvcpetb[11] @523 0x00
ub1 kcvcpetb[12] @524 0x00
ub1 kcvcpetb[13] @525 0x00
ub1 kcvcpetb[14] @526 0x00
ub1 kcvcpetb[15] @527 0x00
ub1 kcvcpetb[16] @528 0x00
ub1 kcvcpetb[17] @529 0x00
ub1 kcvcpetb[18] @530 0x00
ub1 kcvcpetb[19] @531 0x00
ub1 kcvcpetb[20] @532 0x00
ub1 kcvcpetb[21] @533 0x00
ub1 kcvcpetb[22] @534 0x00
ub1 kcvcpetb[23] @535 0x00
ub1 kcvcpetb[24] @536 0x00
ub1 kcvcpetb[25] @537 0x00
ub1 kcvcpetb[26] @538 0x00
ub1 kcvcpetb[27] @539 0x00
ub1 kcvcpetb[28] @540 0x00
ub1 kcvcpetb[29] @541 0x00
ub1 kcvcpetb[30] @542 0x00
ub1 kcvcpetb[31] @543 0x00
ub1 kcvcpetb[32] @544 0x00
ub1 kcvcpetb[33] @545 0x00
ub1 kcvcpetb[34] @546 0x00
ub1 kcvcpetb[35] @547 0x00
ub1 kcvcpetb[36] @548 0x00
ub1 kcvcpetb[37] @549 0x00
ub1 kcvcpetb[38] @550 0x00
ub1 kcvcpetb[39] @551 0x00
ub1 kcvcpetb[40] @552 0x00
ub1 kcvcpetb[41] @553 0x00
ub1 kcvcpetb[42] @554 0x00
ub1 kcvcpetb[43] @555 0x00
ub1 kcvcpetb[44] @556 0x00
ub1 kcvcpetb[45] @557 0x00
ub1 kcvcpetb[46] @558 0x00
ub1 kcvcpetb[47] @559 0x00
ub1 kcvcpetb[48] @560 0x00
ub1 kcvcpetb[49] @561 0x00
ub1 kcvcpetb[50] @562 0x00
ub1 kcvcpetb[51] @563 0x00
ub1 kcvcpetb[52] @564 0x00
ub1 kcvcpetb[53] @565 0x00
ub1 kcvcpetb[54] @566 0x00
ub1 kcvcpetb[55] @567 0x00
ub1 kcvcpetb[56] @568 0x00
ub1 kcvcpetb[57] @569 0x00
ub1 kcvcpetb[58] @570 0x00
ub1 kcvcpetb[59] @571 0x00
ub1 kcvcpetb[60] @572 0x00
ub1 kcvcpetb[61] @573 0x00
ub1 kcvcpetb[62] @574 0x00
ub1 kcvcpetb[63] @575 0x00
ub1 kcvcpetb[64] @576 0x00
ub1 kcvcpetb[65] @577 0x00
ub1 kcvcpetb[66] @578 0x00
ub1 kcvcpetb[67] @579 0x00
ub1 kcvcpetb[68] @580 0x00
ub1 kcvcpetb[69] @581 0x00
ub1 kcvcpetb[70] @582 0x00
ub1 kcvcpetb[71] @583 0x00
ub1 kcvcpetb[72] @584 0x00
ub1 kcvcpetb[73] @585 0x00
ub1 kcvcpetb[74] @586 0x00
ub1 kcvcpetb[75] @587 0x00
ub1 kcvcpetb[76] @588 0x00
ub1 kcvcpetb[77] @589 0x00
ub1 kcvcpetb[78] @590 0x00
ub1 kcvcpetb[79] @591 0x00
ub1 kcvcpetb[80] @592 0x00
ub1 kcvcpetb[81] @593 0x00
ub1 kcvcpetb[82] @594 0x00
ub1 kcvcpetb[83] @595 0x00
ub1 kcvcpetb[84] @596 0x00
ub1 kcvcpetb[85] @597 0x00
ub1 kcvcpetb[86] @598 0x00
ub1 kcvcpetb[87] @599 0x00
ub1 kcvcpetb[88] @600 0x00
ub1 kcvcpetb[89] @601 0x00
ub1 kcvcpetb[90] @602 0x00
ub1 kcvcpetb[91] @603 0x00
ub1 kcvcpetb[92] @604 0x00
ub1 kcvcpetb[93] @605 0x00
ub1 kcvcpetb[94] @606 0x00
ub1 kcvcpetb[95] @607 0x00
ub1 kcvcpetb[96] @608 0x00
ub1 kcvcpetb[97] @609 0x00
ub1 kcvcpetb[98] @610 0x00
ub1 kcvcpetb[99] @611 0x00
ub1 kcvcpetb[100] @612 0x00
ub1 kcvcpetb[101] @613 0x00
ub1 kcvcpetb[102] @614 0x00
ub1 kcvcpetb[103] @615 0x00
ub1 kcvcpetb[104] @616 0x00
ub1 kcvcpetb[105] @617 0x00
ub1 kcvcpetb[106] @618 0x00
ub1 kcvcpetb[107] @619 0x00
ub1 kcvcpetb[108] @620 0x00
ub1 kcvcpetb[109] @621 0x00
ub1 kcvcpetb[110] @622 0x00
ub1 kcvcpetb[111] @623 0x00
ub1 kcvcpetb[112] @624 0x00
ub1 kcvcpetb[113] @625 0x00
ub1 kcvcpetb[114] @626 0x00
ub1 kcvcpetb[115] @627 0x00
ub1 kcvcpetb[116] @628 0x00
ub1 kcvcpetb[117] @629 0x00
ub1 kcvcpetb[118] @630 0x00
ub1 kcvcpetb[119] @631 0x00
ub1 kcvcpetb[120] @632 0x00
ub1 kcvcpetb[121] @633 0x00
ub1 kcvcpetb[122] @634 0x00
ub1 kcvcpetb[123] @635 0x00
ub1 kcvcpetb[124] @636 0x00
ub1 kcvcpetb[125] @637 0x00
ub1 kcvcpetb[126] @638 0x00
ub1 kcvcpetb[127] @639 0x00
ub1 kcvcpetb[128] @640 0x00
ub4 kcvfhcpc @140 0x000000a6
ub4 kcvfhrts @144 0x3630b88e
ub4 kcvfhccc @148 0x000000a5
struct kcvfhbcp, 160 bytes @152
struct kcvcpscn, 8 bytes @152
ub4 kscnbas @152 0x00000000
ub2 kscnwrp @156 0x0000
ub4 kcvcptim @160 0x00000000
ub2 kcvcpthr @164 0x0000
union u, 12 bytes @168
struct kcvcprba, 12 bytes @168
ub4 kcrbaseq @168 0x00000000
ub4 kcrbabno @172 0x00000000
ub2 kcrbabof @176 0x0000
ub1 kcvcpetb[0] @180 0x00
ub1 kcvcpetb[1] @181 0x00
ub1 kcvcpetb[2] @182 0x00
ub1 kcvcpetb[3] @183 0x00
ub1 kcvcpetb[4] @184 0x00
ub1 kcvcpetb[5] @185 0x00
ub1 kcvcpetb[6] @186 0x00
ub1 kcvcpetb[7] @187 0x00
ub1 kcvcpetb[8] @188 0x00
ub1 kcvcpetb[9] @189 0x00
ub1 kcvcpetb[10] @190 0x00
ub1 kcvcpetb[11] @191 0x00
ub1 kcvcpetb[12] @192 0x00
ub1 kcvcpetb[13] @193 0x00
ub1 kcvcpetb[14] @194 0x00
ub1 kcvcpetb[15] @195 0x00
ub1 kcvcpetb[16] @196 0x00
ub1 kcvcpetb[17] @197 0x00
ub1 kcvcpetb[18] @198 0x00
ub1 kcvcpetb[19] @199 0x00
ub1 kcvcpetb[20] @200 0x00
ub1 kcvcpetb[21] @201 0x00
ub1 kcvcpetb[22] @202 0x00
ub1 kcvcpetb[23] @203 0x00
ub1 kcvcpetb[24] @204 0x00
ub1 kcvcpetb[25] @205 0x00
ub1 kcvcpetb[26] @206 0x00
ub1 kcvcpetb[27] @207 0x00
ub1 kcvcpetb[28] @208 0x00
ub1 kcvcpetb[29] @209 0x00
ub1 kcvcpetb[30] @210 0x00
ub1 kcvcpetb[31] @211 0x00
ub1 kcvcpetb[32] @212 0x00
ub1 kcvcpetb[33] @213 0x00
ub1 kcvcpetb[34] @214 0x00
ub1 kcvcpetb[35] @215 0x00
ub1 kcvcpetb[36] @216 0x00
ub1 kcvcpetb[37] @217 0x00
ub1 kcvcpetb[38] @218 0x00
ub1 kcvcpetb[39] @219 0x00
ub1 kcvcpetb[40] @220 0x00
ub1 kcvcpetb[41] @221 0x00
ub1 kcvcpetb[42] @222 0x00
ub1 kcvcpetb[43] @223 0x00
ub1 kcvcpetb[44] @224 0x00
ub1 kcvcpetb[45] @225 0x00
ub1 kcvcpetb[46] @226 0x00
ub1 kcvcpetb[47] @227 0x00
ub1 kcvcpetb[48] @228 0x00
ub1 kcvcpetb[49] @229 0x00
ub1 kcvcpetb[50] @230 0x00
ub1 kcvcpetb[51] @231 0x00
ub1 kcvcpetb[52] @232 0x00
ub1 kcvcpetb[53] @233 0x00
ub1 kcvcpetb[54] @234 0x00
ub1 kcvcpetb[55] @235 0x00
ub1 kcvcpetb[56] @236 0x00
ub1 kcvcpetb[57] @237 0x00
ub1 kcvcpetb[58] @238 0x00
ub1 kcvcpetb[59] @239 0x00
ub1 kcvcpetb[60] @240 0x00
ub1 kcvcpetb[61] @241 0x00
ub1 kcvcpetb[62] @242 0x00
ub1 kcvcpetb[63] @243 0x00
ub1 kcvcpetb[64] @244 0x00
ub1 kcvcpetb[65] @245 0x00
ub1 kcvcpetb[66] @246 0x00
ub1 kcvcpetb[67] @247 0x00
ub1 kcvcpetb[68] @248 0x00
ub1 kcvcpetb[69] @249 0x00
ub1 kcvcpetb[70] @250 0x00
ub1 kcvcpetb[71] @251 0x00
ub1 kcvcpetb[72] @252 0x00
ub1 kcvcpetb[73] @253 0x00
ub1 kcvcpetb[74] @254 0x00
ub1 kcvcpetb[75] @255 0x00
ub1 kcvcpetb[76] @256 0x00
ub1 kcvcpetb[77] @257 0x00
ub1 kcvcpetb[78] @258 0x00
ub1 kcvcpetb[79] @259 0x00
ub1 kcvcpetb[80] @260 0x00
ub1 kcvcpetb[81] @261 0x00
ub1 kcvcpetb[82] @262 0x00
ub1 kcvcpetb[83] @263 0x00
ub1 kcvcpetb[84] @264 0x00
ub1 kcvcpetb[85] @265 0x00
ub1 kcvcpetb[86] @266 0x00
ub1 kcvcpetb[87] @267 0x00
ub1 kcvcpetb[88] @268 0x00
ub1 kcvcpetb[89] @269 0x00
ub1 kcvcpetb[90] @270 0x00
ub1 kcvcpetb[91] @271 0x00
ub1 kcvcpetb[92] @272 0x00
ub1 kcvcpetb[93] @273 0x00
ub1 kcvcpetb[94] @274 0x00
ub1 kcvcpetb[95] @275 0x00
ub1 kcvcpetb[96] @276 0x00
ub1 kcvcpetb[97] @277 0x00
ub1 kcvcpetb[98] @278 0x00
ub1 kcvcpetb[99] @279 0x00
ub1 kcvcpetb[100] @280 0x00
ub1 kcvcpetb[101] @281 0x00
ub1 kcvcpetb[102] @282 0x00
ub1 kcvcpetb[103] @283 0x00
ub1 kcvcpetb[104] @284 0x00
ub1 kcvcpetb[105] @285 0x00
ub1 kcvcpetb[106] @286 0x00
ub1 kcvcpetb[107] @287 0x00
ub1 kcvcpetb[108] @288 0x00
ub1 kcvcpetb[109] @289 0x00
ub1 kcvcpetb[110] @290 0x00
ub1 kcvcpetb[111] @291 0x00
ub1 kcvcpetb[112] @292 0x00
ub1 kcvcpetb[113] @293 0x00
ub1 kcvcpetb[114] @294 0x00
ub1 kcvcpetb[115] @295 0x00
ub1 kcvcpetb[116] @296 0x00
ub1 kcvcpetb[117] @297 0x00
ub1 kcvcpetb[118] @298 0x00
ub1 kcvcpetb[119] @299 0x00
ub1 kcvcpetb[120] @300 0x00
ub1 kcvcpetb[121] @301 0x00
ub1 kcvcpetb[122] @302 0x00
ub1 kcvcpetb[123] @303 0x00
ub1 kcvcpetb[124] @304 0x00
ub1 kcvcpetb[125] @305 0x00
ub1 kcvcpetb[126] @306 0x00
ub1 kcvcpetb[127] @307 0x00
ub1 kcvcpetb[128] @308 0x00
ub4 kcvfhbhz @312 0x00000000
struct kcvfhxcd, 16 bytes @316
ub4 space_kcvmxcd[0] @316 0x00000000
ub4 space_kcvmxcd[1] @320 0x00000000
ub4 space_kcvmxcd[2] @324 0x00000000
ub4 space_kcvmxcd[3] @328 0x00000000
sword kcvfhtsn @332 1
ub2 kcvfhtln @336 0x0006
text kcvfhtnm[0] @338 S
text kcvfhtnm[1] @339 Y
text kcvfhtnm[2] @340 S
text kcvfhtnm[3] @341 A
text kcvfhtnm[4] @342 U
text kcvfhtnm[5] @343 X
text kcvfhtnm[6] @344
text kcvfhtnm[7] @345
text kcvfhtnm[8] @346
text kcvfhtnm[9] @347
text kcvfhtnm[10] @348
text kcvfhtnm[11] @349
text kcvfhtnm[12] @350
text kcvfhtnm[13] @351
text kcvfhtnm[14] @352
text kcvfhtnm[15] @353
text kcvfhtnm[16] @354
text kcvfhtnm[17] @355
text kcvfhtnm[18] @356
text kcvfhtnm[19] @357
text kcvfhtnm[20] @358
text kcvfhtnm[21] @359
text kcvfhtnm[22] @360
text kcvfhtnm[23] @361
text kcvfhtnm[24] @362
text kcvfhtnm[25] @363
text kcvfhtnm[26] @364
text kcvfhtnm[27] @365
text kcvfhtnm[28] @366
text kcvfhtnm[29] @367
ub4 kcvfhrfn @368 0x00000002
struct kcvfhrfs, 8 bytes @372
ub4 kscnbas @372 0x00000000
ub2 kscnwrp @376 0x0000
ub4 kcvfhrft @380 0x00000000
struct kcvfhafs, 8 bytes @384
ub4 kscnbas @384 0x00000000
ub2 kscnwrp @388 0x0000
ub4 kcvfhbbc @392 0x00000000
ub4 kcvfhncb @396 0x00000000
ub4 kcvfhmcb @400 0x00000000
ub4 kcvfhlcb @404 0x00000000
ub4 kcvfhbcs @408 0x00000000
ub2 kcvfhofb @412 0x0000
ub2 kcvfhnfb @414 0x0000
ub4 kcvfhprc @416 0x3155bebd
struct kcvfhprs, 8 bytes @420
ub4 kscnbas @420 0x00000001
ub2 kscnwrp @424 0x0000
struct kcvfhprfs, 8 bytes @428
ub4 kscnbas @428 0x00000000
ub2 kscnwrp @432 0x0000
ub4 kcvfhtrt @444 0x00000000
BBED>
2.3.3.1 修改檔案頭的資訊
我們需要修改的地方有十個,分別是:
ub4 rdba_kcbh @4 0x00800001
ub4 kccfhfsz @44 0x00011300
ub2 kccfhfno @52 0x0002
ub4 kcvfhrdb @96 0x00000000
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00000716
ub2 kscnwrp @104 0x0000
ub4 kcvfhcrt @108 0x3155becc
ub2 kcvfhsta @138 0x0004 (KCVFHOFZ)
sword kcvfhtsn @332 1
text kcvfhtnm[3] @341 A
text kcvfhtnm[4] @342 U
text kcvfhtnm[5] @343 X
ub4 kcvfhrfn @368 0x00000002
一、 ub4 rdba_kcbh 相對資料塊地址
ub4 rdba_kcbh @4 0x00800001
原資訊:
BBED> set dba 1,1
DBA 0x00400001 (4194305 1,1)
BBED> p kcvfhbfh
struct kcvfhbfh, 20 bytes @0
ub1 type_kcbh @0 0x0b
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x00800001
ub4 bas_kcbh @8 0x00000000
ub2 wrp_kcbh @12 0x0000
ub1 seq_kcbh @14 0x01
ub1 flg_kcbh @15 0x04 (KCBHFCKV)
ub2 chkval_kcbh @16 0xed22
ub2 spare3_kcbh @18 0x0000
BBED>
BBED> d count 128 offset 4
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 4 to 131 Dba:0x00400001
------------------------------------------------------------------------
00800001 00000000 00000104 ed220000 00000000 0b200400 1793c969 4f52414c
48520000 0000093b 00011300 00002000 00020003 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000716 00000000 3155becc 362e0deb 000e20dc 00007f18 00000000 00000000
<32 bytes="" per="" line="">
BBED>
該引數值代表當前資料塊在資料庫中的位置,轉換為2進位制後前10位代表檔案號,後22位代表塊號,轉換表格如下:
|
原值 |
新值 |
儲存16進位制 |
0x00800001 |
0x00400001 |
可讀16進位制 |
0x00800001 |
0x00400001 |
2進位制 |
0123456789 0123456789012345678901 --------------------------------- 0000000010 0000000000000000000001 |
0123456789 0123456789012345678901 --------------------------------- 0000000001 0000000000000000000001 |
表示意義 |
FILE 2 BLOCK 1 |
FILE 1 BLOCK 1 |
我們用計算器可以算得需要修改後的16進位制,由於是AIX平臺,儲存和可讀的順序是一致的,這裡很慚愧,第一次看到這的時候實在看不懂檔案2是如何得到的,因為源資料不是這樣寫的,後來在公司老貓的幫助下,我才弄懂了這裡的轉換關係,所以我分享給大家,也感謝老貓的幫助。
轉換:
BBED> set dba 1,1 offset 4
DBA 0x00400001 (4194305 1,1)
OFFSET 4
BBED> modify /x 00400001
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 4 to 131 Dba:0x00400001
------------------------------------------------------------------------
00400001 00000000 00000104 ed220000 00000000 0b200400 1793c969 4f52414c
48520000 0000093b 00011300 00002000 00020003 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000716 00000000 3155becc 362e0deb 000e20dc 00007f18 00000000 00000000
<32 bytes="" per="" line="">
BBED> p kcvfhbfh
struct kcvfhbfh, 20 bytes @0
ub1 type_kcbh @0 0x0b
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x00400001
ub4 bas_kcbh @8 0x00000000
ub2 wrp_kcbh @12 0x0000
ub1 seq_kcbh @14 0x01
ub1 flg_kcbh @15 0x04 (KCBHFCKV)
ub2 chkval_kcbh @16 0xed22
ub2 spare3_kcbh @18 0x0000
BBED>
BBED> sum apply
Check value for File 1, Block 1:
current = 0xede2, required = 0xede2
二、 檔案大小和檔案號
BBED> p kcvfhhdr
struct kcvfhhdr, 76 bytes @20
ub4 kccfhswv @20 0x00000000
ub4 kccfhcvn @24 0x0b200400
ub4 kccfhdbi @28 0x1793c969
text kccfhdbn[0] @32 O
text kccfhdbn[1] @33 R
text kccfhdbn[2] @34 A
text kccfhdbn[3] @35 L
text kccfhdbn[4] @36 H
text kccfhdbn[5] @37 R
text kccfhdbn[6] @38
text kccfhdbn[7] @39
ub4 kccfhcsq @40 0x0000093b
ub4 kccfhfsz @44 0x00011300
s_blkz kccfhbsz @48 0x00
ub2 kccfhfno @52 0x0002
ub2 kccfhtyp @54 0x0003
ub4 kccfhacid @56 0x00000000
ub4 kccfhcks @60 0x00000000
text kccfhtag[0] @64
text kccfhtag[1] @65
text kccfhtag[2] @66
text kccfhtag[3] @67
text kccfhtag[4] @68
text kccfhtag[5] @69
text kccfhtag[6] @70
text kccfhtag[7] @71
text kccfhtag[8] @72
text kccfhtag[9] @73
text kccfhtag[10] @74
text kccfhtag[11] @75
text kccfhtag[12] @76
text kccfhtag[13] @77
text kccfhtag[14] @78
text kccfhtag[15] @79
text kccfhtag[16] @80
text kccfhtag[17] @81
text kccfhtag[18] @82
text kccfhtag[19] @83
text kccfhtag[20] @84
text kccfhtag[21] @85
text kccfhtag[22] @86
text kccfhtag[23] @87
text kccfhtag[24] @88
text kccfhtag[25] @89
text kccfhtag[26] @90
text kccfhtag[27] @91
text kccfhtag[28] @92
text kccfhtag[29] @93
text kccfhtag[30] @94
text kccfhtag[31] @95
BBED>
1、 ub4 kccfhfsz 檔案大小
ub4 kccfhfsz @44 0x00011300
具體轉換過程參考如下表格:
|
原值 |
新值 |
儲存16進位制 |
0x00011300 |
0x00017700 |
可讀16進位制 |
0x00011300 |
0x00017700 |
可讀10進位制(blocks) |
70400 |
96000 |
DB FILE SIZE |
576716800 |
786432000 |
OS FILE SIZE |
576724992 |
786440192 |
演算法 |
十六進位制11300轉換10進製為70400,代表塊數,70400*8192=576716800byte ,加上一個資料塊代表OS檔案的大小:576716800+8192=576724992
|
從OS獲取檔案大小,從而反推DB基本的檔案大小,OS檔案大小786440192,786440192-8192=786432000為DB基本檔案大小,786432000/8192=96000為資料庫的blocks數,轉換16進製為0x00017700 |
檔案大小 |
[ZHLHRDB2:oracle]:/oracle>cd /oracle/app/oracle/datafile/oralhr [ZHLHRDB2:oracle]:/oracle/app/oracle/datafile/oralhr>l sys* -rw-r----- 1 oracle asmadmin 576724992 Apr 15 08:45 sysaux01.dbf -rw-r----- 1 oracle asmadmin 786440192 Apr 15 09:31 system01.dbf -rw-r----- 1 oracle dba 786440192 Apr 14 10:02 system01.dbf_bk |
修改:
[ZHLHRDB2:oracle]:/oracle>cd /oracle/app/oracle/datafile/oralhr
[ZHLHRDB2:oracle]:/oracle/app/oracle/datafile/oralhr>l sys*
-rw-r----- 1 oracle asmadmin 576724992 Apr 15 08:45 sysaux01.dbf
-rw-r----- 1 oracle asmadmin 786440192 Apr 15 09:31 system01.dbf
-rw-r----- 1 oracle dba 786440192 Apr 14 10:02 system01.dbf_bk
BBED> set dba 1,1 offset 44 count 64
DBA 0x00400001 (4194305 1,1)
OFFSET 44
COUNT 64
BBED> d
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 44 to 107 Dba:0x00400001
------------------------------------------------------------------------
00011300 00002000 00020003 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000716 00000000
<32 bytes="" per="" line="">
BBED> m /x 00017700
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 44 to 107 Dba:0x00400001
------------------------------------------------------------------------
00017700 00002000 00020003 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000716 00000000
<32 bytes="" per="" line="">
BBED> sum apply
Check value for File 1, Block 1:
current = 0x89e2, required = 0x89e2
BBED> d
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 44 to 107 Dba:0x00400001
------------------------------------------------------------------------
00017700 00002000 00020003 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000716 00000000
<32 bytes="" per="" line="">
BBED>
2、 ub2 kccfhfno 檔案號
ub2 kccfhfno @52 0x0002
比較簡單,原sysaux為2號檔案,我們需要修改為1號檔案:
BBED> set dba 1,1 offset 52 count 64
DBA 0x00400001 (4194305 1,1)
OFFSET 52
COUNT 64
BBED> d
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 52 to 115 Dba:0x00400001
------------------------------------------------------------------------
00020003 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000716 00000000 3155becc 362e0deb
<32 bytes="" per="" line="">
BBED> m /x 00010003
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 52 to 115 Dba:0x00400001
------------------------------------------------------------------------
00010003 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000716 00000000 3155becc 362e0deb
<32 bytes="" per="" line="">
BBED> sum apply
Check value for File 1, Block 1:
current = 0x89e1, required = 0x89e1
BBED>
三、 ub4 kcvfhrdb bootstrap$ 物件的地址
ub4 kcvfhrdb @96 0x00000000
該部分資訊為sys.bootstrap$ 物件的地址,在10g中固定DBA為1,377, 但在11g中dba為1,520,這裡看到為0,說明2號檔案上不存在該物件, 其轉換形式和rdba_kcbh部分是一樣的,不再贅述。
11g中儲存在1號檔案520塊:
BBED> info
File# Name Size(blks)
----- ---- ----------
1 /oracle/app/oracle/datafile/oralhr/system01.dbf 96000
2 /oracle/app/oracle/datafile/oralhr/sysaux01.dbf 69120
3 /oracle/app/oracle/datafile/oralhr/undotbs01.dbf 9600
4 /oracle/app/oracle/datafile/oralhr/users01.dbf 37920
5 /oracle/app/oracle/datafile/oralhr/system01.dbf_bk 96000
BBED>
BBED>
BBED> set dba 5,1 offset 96 count 64
DBA 0x01400001 (20971521 5,1)
OFFSET 96
COUNT 64
BBED> print kcvfhrdb
ub4 kcvfhrdb @96 0x00400208
====》 0000000001 0000000000001000001000, 1號檔案520塊,下邊我們進行修改:
BBED> set dba 1,1 offset 96 count 64
DBA 0x00400001 (4194305 1,1)
OFFSET 96
COUNT 64
BBED> d
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 96 to 159 Dba:0x00400001
------------------------------------------------------------------------
00000000 00000716 00000000 3155becc 362e0deb 000e20dc 00007f18 00000000
00000000 00000000 00000004 000000a6 3630b88e 000000a5 00000000 00000000
<32 bytes="" per="" line="">
BBED> modify /x 00400208
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 96 to 159 Dba:0x00400001
------------------------------------------------------------------------
00400208 00000716 00000000 3155becc 362e0deb 000e20dc 00007f18 00000000
00000000 00000000 00000004 000000a6 3630b88e 000000a5 00000000 00000000
<32 bytes="" per="" line="">
BBED> sum apply
Check value for File 1, Block 1:
current = 0x8ba9, required = 0x8ba9
BBED>
四、 ub4 kscnbas 檔案建立SCN號
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00000716
ub2 kscnwrp @104 0x0000
SYS@oralhr> set line 9999
SYS@oralhr> col name format a60
SYS@oralhr> SELECT d.FILE#,d.CREATION_CHANGE#,to_char(d.CREATION_CHANGE#,'xxxxxxxxxxxx') scn_hx,d.NAME FROM v$datafile d ;
FILE# CREATION_CHANGE# SCN_HX NAME
---------- ---------------- -------------------------- ------------------------------------------------------------
1 8 8 /oracle/app/oracle/datafile/oralhr/system01.dbf
2 1814 716 /oracle/app/oracle/datafile/oralhr/sysaux01.dbf
3 923586 e17c2 /oracle/app/oracle/datafile/oralhr/undotbs01.dbf
4 16050 3eb2 /oracle/app/oracle/datafile/oralhr/users01.dbf
SYS@oralhr>
====》 2號檔案的scn為1814轉換為16進位制後就是716,和bbed查詢出來的一致,下邊修改1號檔案的scn
BBED> p kcvfhcrs
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00000716
ub2 kscnwrp @104 0x0000
BBED> set dba 1,1 offset 100 count 64
DBA 0x00400001 (4194305 1,1)
OFFSET 100
COUNT 64
BBED> m /x 00000008
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 100 to 163 Dba:0x00400001
------------------------------------------------------------------------
00000008 00000000 3155becc 362e0deb 000e20dc 00007f18 00000000 00000000
00000000 00000004 000000a6 3630b88e 000000a5 00000000 00000000 00000000
<32 bytes="" per="" line="">
BBED> sum apply
Check value for File 1, Block 1:
current = 0x8cb7, required = 0x8cb7
BBED> p kcvfhcrs
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00000008
ub2 kscnwrp @104 0x0000
BBED>
五、 ub4 kcvfhcrt 檔案建立時間
BBED> p kcvfhcrt
ub4 kcvfhcrt @108 0x3155becc
BBED>
SYS@oralhr> set line 9999
SYS@oralhr> col name format a60
SYS@oralhr> col scn_hx format a15
SYS@oralhr> col time_hx format a15
SYS@oralhr> select file#,name,CREATION_CHANGE#,scn_hx,CREATION_TIME_N,to_char(CREATION_TIME_N,'xxxxxxxxxxxx') time_hx,CREATION_TIME_D from (
2 SELECT d.FILE#,
3 d.NAME,
4 d.CREATION_CHANGE#,
5 to_char(d.CREATION_CHANGE#,'xxxxxxxxxxxx') scn_hx,
6 ((to_char(d.CREATION_TIME, 'YYYY') - 1988) * 12 * 31 * 24 * 3600 +
7 (to_char(d.CREATION_TIME, 'MM') - 1) * 31 * 24 * 3600 +
8 (to_char(d.CREATION_TIME, 'dd') - 1) * 24 * 3600 +
9 (to_char(d.CREATION_TIME, 'hh24')) * 3600 +
10 (to_char(d.CREATION_TIME, 'mi')) * 60 +
11 to_char(d.CREATION_TIME, 'ss')) CREATION_TIME_N,
12 to_char(d.CREATION_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATION_TIME_D
13 FROM v$datafile d);
FILE# NAME CREATION_CHANGE# SCN_HX CREATION_TIME_N TIME_HX CREATION_TIME_D
---------- ------------------------------------------------------------ ---------------- --------------- --------------- --------------- ------------------------------
1 /oracle/app/oracle/datafile/oralhr/system01.dbf 8 8 827702981 3155bec5 2013-10-01 21:29:41
2 /oracle/app/oracle/datafile/oralhr/sysaux01.dbf 1814 716 827702988 3155becc 2013-10-01 21:29:48
3 /oracle/app/oracle/datafile/oralhr/undotbs01.dbf 923586 e17c2 827712502 3155e3f6 2013-10-02 00:08:22
4 /oracle/app/oracle/datafile/oralhr/users01.dbf 16050 3eb2 827703010 3155bee2 2013-10-01 21:30:10
SYS@oralhr>
BBED> p kcvfhcrt
ub4 kcvfhcrt @108 0x3155becc
BBED> set dba 1,1 offset 108
DBA 0x00400001 (4194305 1,1)
OFFSET 108
BBED>
BBED> m /x 3155BEC5
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 108 to 171 Dba:0x00400001
------------------------------------------------------------------------
3155bec5 362e0deb 000e20dc 00007f18 00000000 00000000 00000000 00000004
000000a6 3630b88e 000000a5 00000000 00000000 00000000 00000000 00000000
<32 bytes="" per="" line="">
BBED>
BBED> sum apply
Check value for File 1, Block 1:
current = 0x8cbe, required = 0x8cbe
BBED>
六、 ub2 kcvfhsta 檔案頭部狀態
ub2 kcvfhsta @138 0x0004 (KCVFHOFZ)
表示檔案的狀態,對於檔案1,正常關閉的值為8192,16進製為2000
BBED> set dba 1,1 offset 138 count 64
DBA 0x00400001 (4194305 1,1)
OFFSET 138
COUNT 64
BBED> d
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 138 to 201 Dba:0x00400001
------------------------------------------------------------------------
00040000 00a63630 b88e0000 00a50000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes="" per="" line="">
BBED> m /x 2000
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 138 to 201 Dba:0x00400001
------------------------------------------------------------------------
20000000 00a63630 b88e0000 00a50000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes="" per="" line="">
BBED> sum apply
Check value for File 1, Block 1:
current = 0xacba, required = 0xacba
BBED>
七、 kcvfhtsn 表空間號
sword kcvfhtsn @332 1
system為0號表空間:
SYS@oralhr> select ts#,name from v$tablespace;
TS# NAME
---------- ------------------------------------------------------------
0 SYSTEM
1 SYSAUX
2 UNDOTBS1
4 USERS
3 TEMP
BBED> p kcvfhtsn
sword kcvfhtsn @332 1
BBED> set dba 1,1 offset 332 count 64
DBA 0x00400001 (4194305 1,1)
OFFSET 332
COUNT 64
BBED> m /x 00000000
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 332 to 395 Dba:0x00400001
------------------------------------------------------------------------
00000000 00065359 53415558 00000000 00000000 00000000 00000000 00000000
00000000 00000002 00000000 00000000 00000000 00000000 0000b7e0 00000000
<32 bytes="" per="" line="">
BBED> sum apply
Check value for File 1, Block 1:
current = 0xacbb, required = 0xacbb
BBED> p kcvfhtsn
sword kcvfhtsn @332 0
BBED>
八、 p kcvfhtnm 表空間名
text kcvfhtnm[3] @341 A
text kcvfhtnm[4] @342 U
text kcvfhtnm[5] @343 X
BBED> p kcvfhtnm
text kcvfhtnm[0] @338 S
text kcvfhtnm[1] @339 Y
text kcvfhtnm[2] @340 S
text kcvfhtnm[3] @341 A
text kcvfhtnm[4] @342 U
text kcvfhtnm[5] @343 X
text kcvfhtnm[6] @344
text kcvfhtnm[7] @345
text kcvfhtnm[8] @346
text kcvfhtnm[9] @347
text kcvfhtnm[10] @348
text kcvfhtnm[11] @349
text kcvfhtnm[12] @350
text kcvfhtnm[13] @351
text kcvfhtnm[14] @352
text kcvfhtnm[15] @353
text kcvfhtnm[16] @354
text kcvfhtnm[17] @355
text kcvfhtnm[18] @356
text kcvfhtnm[19] @357
text kcvfhtnm[20] @358
text kcvfhtnm[21] @359
text kcvfhtnm[22] @360
text kcvfhtnm[23] @361
text kcvfhtnm[24] @362
text kcvfhtnm[25] @363
text kcvfhtnm[26] @364
text kcvfhtnm[27] @365
text kcvfhtnm[28] @366
text kcvfhtnm[29] @367
BBED>
我們需要修改為SYSTEM,可以查詢ASCII碼錶,或者從其它庫中獲取,注意這個值不存在大小端的轉換:
BBED> set dba 1,1 offset 338 count 64
DBA 0x00400001 (4194305 1,1)
OFFSET 338
COUNT 64
BBED> d /v
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 338 to 401 Dba:0x00400001
-------------------------------------------------------
53595341 55580000 00000000 00000000 l SYSAUX..........
00000000 00000000 00000000 00000000 l ................
00020000 00000000 00000000 00000000 l ................
00000000 b7e00000 00000000 00000000 l ................
<16 bytes="" per="" line="">
BBED> set dba 5,1 offset 338 count 64
DBA 0x01400001 (20971521 5,1)
OFFSET 338
COUNT 64
BBED> d /v
File: /oracle/app/oracle/datafile/oralhr/system01.dbf_bk (5)
Block: 1 Offsets: 338 to 401 Dba:0x01400001
-------------------------------------------------------
53595354 454d0000 00000000 00000000 l SYSTEM..........
00000000 00000000 00000000 00000000 l ................
00010000 00000000 00000000 00000000 l ................
00000000 b7e00000 00000000 00000000 l ................
BBED> set dba 5,1 offset 341 count 64
DBA 0x01400001 (20971521 5,1)
OFFSET 341
COUNT 64
BBED> d /v
File: /oracle/app/oracle/datafile/oralhr/system01.dbf_bk (5)
Block: 1 Offsets: 341 to 404 Dba:0x01400001
-------------------------------------------------------
54454d00 00000000 00000000 00000000 l TEM.............
00000000 00000000 00000000 00000100 l ................
00000000 00000000 00000000 00000000 l ................
00b7e000 00000000 00000000 00000000 l ................
<16 bytes="" per="" line="">
BBED> set dba 1,1 offset 341 count 64
DBA 0x00400001 (4194305 1,1)
OFFSET 341
COUNT 64
BBED> d /v
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 341 to 404 Dba:0x00400001
-------------------------------------------------------
41555800 00000000 00000000 00000000 l AUX.............
00000000 00000000 00000000 00000200 l ................
00000000 00000000 00000000 00000000 l ................
00b7e000 00000000 00000000 00000000 l ................
<16 bytes="" per="" line="">
BBED> m /x 54454d00
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 341 to 404 Dba:0x00400001
------------------------------------------------------------------------
54454d00 00000000 00000000 00000000 00000000 00000000 00000000 00000200
00000000 00000000 00000000 00000000 00b7e000 00000000 00000000 00000000
<32 bytes="" per="" line="">
BBED> sum apply
Check value for File 1, Block 1:
current = 0xbcbb, required = 0xbcbb
BBED> set dba 1,1 offset 338 count 64
DBA 0x00400001 (4194305 1,1)
OFFSET 338
COUNT 64
BBED> d /v
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 338 to 401 Dba:0x00400001
-------------------------------------------------------
53595354 454d0000 00000000 00000000 l SYSTEM..........
00000000 00000000 00000000 00000000 l ................
00020000 00000000 00000000 00000000 l ................
00000000 b7e00000 00000000 00000000 l ................
<16 bytes="" per="" line="">
BBED>
九、 ub4 kcvfhrfn 相對檔案號
ub4 kcvfhrfn @368 0x00000002
代表相對檔案號,需要修改為1號:
BBED> p kcvfhrfn
ub4 kcvfhrfn @368 0x00000002
BBED> set dba 1,1 offset 368 count 64
DBA 0x00400001 (4194305 1,1)
OFFSET 368
COUNT 64
BBED> m /x 00000001
File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)
Block: 1 Offsets: 368 to 431 Dba:0x00400001
------------------------------------------------------------------------
00000001 00000000 00000000 00000000 00000000 0000b7e0 00000000 00000000
00000000 00000000 00000000 00000000 3155bebd 00000001 00000000 00000000
<32 bytes="" per="" line="">
BBED> sum apply
Check value for File 1, Block 1:
current = 0xbcb8, required = 0xbcb8
BBED> p kcvfhrfn
ub4 kcvfhrfn @368 0x00000001
BBED>
2.3.3.2 嘗試open資料庫
在以上所有修改完畢後就可以嘗試啟動資料庫了:
SYS@oralhr> select open_mode from v$database;
OPEN_MODE
----------------------------------------
MOUNTED
SYS@oralhr> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/oracle/app/oracle/datafile/oralhr/system01.dbf'
SYS@oralhr> recover datafile 1;
Media recovery complete.
SYS@oralhr> alter database open;
Database altered.
SYS@oralhr>
由於沒有修改檔案頭與檢查點有關的內容,故需要做recover操作,由於歸檔日誌都在,所以直接recover datafile 1恢復即可。
open的過程中的告警日誌:
Fri Apr 15 10:51:33 2016
alter database open
Errors in file /oracle/app/oracle/diag/rdbms/oralhr/oralhr/trace/oralhr_ora_7602280.trc:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/oracle/app/oracle/datafile/oralhr/system01.dbf'
ORA-1113 signalled during: alter database open...
Fri Apr 15 10:51:33 2016
Checker run found 1 new persistent data failures
Fri Apr 15 10:54:28 2016
ALTER DATABASE RECOVER datafile 1
Media Recovery Start
Serial Media Recovery started
Recovery of Online Redo Log: Thread 1 Group 3 Seq 45 Reading mem 0
Mem# 0: /oracle/app/oracle/datafile/oralhr/redo03.log
Media Recovery Complete (oralhr)
Completed: ALTER DATABASE RECOVER datafile 1
Fri Apr 15 10:54:40 2016
alter database open
Beginning crash recovery of 1 threads
parallel recovery started with 7 processes
Started redo scan
Completed redo scan
read 16 KB redo, 15 data blocks need recovery
Started redo application at
Thread 1: logseq 45, block 14177
Recovery of Online Redo Log: Thread 1 Group 3 Seq 45 Reading mem 0
Mem# 0: /oracle/app/oracle/datafile/oralhr/redo03.log
Completed redo application of 0.01MB
Completed crash recovery at
Thread 1: logseq 45, block 14209, scn 1332897
15 data blocks read, 15 data blocks written, 16 redo k-bytes read
Fri Apr 15 10:54:41 2016
LGWR: STARTING ARCH PROCESSES
Fri Apr 15 10:54:41 2016
ARC0 started with pid=33, OS id=23003154
ARC0: Archival started
LGWR: STARTING ARCH PROCESSES COMPLETE
Thread 1 advanced to log sequence 46 (thread open)
ARC0: STARTING ARCH PROCESSES
Thread 1 opened at log sequence 46
Current log# 1 seq# 46 mem# 0: /oracle/app/oracle/datafile/oralhr/redo01.log
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Fri Apr 15 10:54:41 2016
SMON: enabling cache recovery
Fri Apr 15 10:54:41 2016
ARC1 started with pid=34, OS id=39977044
Fri Apr 15 10:54:41 2016
ARC2 started with pid=35, OS id=24707290
Fri Apr 15 10:54:41 2016
ARC3 started with pid=36, OS id=34668790
ARC1: Archival started
ARC2: Archival started
ARC3: Archival started
ARC0: STARTING ARCH PROCESSES COMPLETE
ARC1: Becoming the 'no FAL' ARCH
ARC1: Becoming the 'no SRL' ARCH
ARC2: Becoming the heartbeat ARCH
[7602280] Successfully onlined Undo Tablespace 2.
Undo initialization finished serial:0 start:890311400 end:890311459 diff:59 (0 seconds)
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Database Characterset is AL32UTF8
Archived Log entry 40 added for thread 1 sequence 45 ID 0x1793c569 dest 1:
No Resource Manager plan active
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
Fri Apr 15 10:54:41 2016
QMNC started with pid=37, OS id=34537504
Completed: alter database open
Fri Apr 15 10:54:42 2016
Starting background process CJQ0
Fri Apr 15 10:54:42 2016
CJQ0 started with pid=40, OS id=21037310
Fri Apr 15 10:59:43 2016
Starting background process SMCO
Fri Apr 15 10:59:43 2016
SMCO started with pid=41, OS id=28967004
2.4 實驗總結
其實重要的不在於恢復的過程,而在於對BBED工具的瞭解,透過BBED來了解檔案頭塊的內容和格式,對於這個案例我們可以直接將備份的檔案頭copy到1號檔案的檔案頭實現恢復。
About Me
.............................................................................................................................................
● 本文作者:小麥苗,部分內容整理自網路,若有侵權請聯絡小麥苗刪除
● 本文在itpub(http://blog.itpub.net/26736162/abstract/1/)、部落格園(http://www.cnblogs.com/lhrbest)和個人微信公眾號(xiaomaimiaolhr)上有同步更新
● 本文itpub地址:http://blog.itpub.net/26736162/viewspace-2084329/
● 本文部落格園地址:http://www.cnblogs.com/lhrbest
● 本文pdf版、個人簡介及小麥苗雲盤地址:http://blog.itpub.net/26736162/viewspace-1624453/
● 資料庫筆試面試題庫及解答:http://blog.itpub.net/26736162/viewspace-2134706/
● DBA寶典今日頭條號地址:
.............................................................................................................................................
● QQ群號:230161599(滿)、618766405
● 微信群:可加我微信,我拉大家進群,非誠勿擾
● 聯絡我請加QQ好友(646634621),註明新增緣由
● 於 2016-04-14 10:00~ 2016-04-15 19:00 在魔都完成
● 文章內容來源於小麥苗的學習筆記,部分整理自網路,若有侵權或不當之處還請諒解
● 版權所有,歡迎分享本文,轉載請保留出處
.............................................................................................................................................
● 小麥苗的微店:
● 小麥苗出版的資料庫類叢書:http://blog.itpub.net/26736162/viewspace-2142121/
.............................................................................................................................................
使用微信客戶端掃描下面的二維碼來關注小麥苗的微信公眾號(xiaomaimiaolhr)及QQ群(DBA寶典),學習最實用的資料庫技術。
小麥苗的微信公眾號 小麥苗的DBA寶典QQ群1 小麥苗的DBA寶典QQ群2 小麥苗的微店
.............................................................................................................................................
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2084329/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- system資料檔案頭損壞修復
- system表空間檔案損壞----完全恢復
- 深入解析:段頭塊損壞bbed異常恢復
- bbed 與檔案頭恢復
- System File1 File Header(資料庫System檔案1檔案頭)損壞情況的恢復Header資料庫
- 損壞控制檔案的恢復方法
- 單個控制檔案損壞的恢復
- SQL Server ldf 檔案損壞恢復SQLServer
- 資料檔案丟失損壞的恢復--
- 某個控制檔案損壞的恢復案例
- REDO檔案丟失或者損壞的恢復
- UNDO 表空間檔案損壞的恢復
- 一次控制檔案損壞的恢復
- 恢復之單個控制檔案損壞
- 線上日誌檔案損壞恢復方法
- 備份與恢復--重建控制檔案後資料檔案損壞的恢復
- u盤檔案損壞怎麼恢復資料 u盤恢復損壞資料的有效方法
- Oracle不同檔案丟失/損壞的恢復方法Oracle
- 所有控制檔案損壞的恢復--resetlogs方式
- 所有控制檔案損壞的恢復--noresetlogs方式
- ORACLE 10g中使用BBED修復損壞資料檔案Oracle 10g
- rman 恢復---歸檔丟失and資料檔案損壞
- 一次日誌檔案損壞的恢復
- 磁碟損壞造成RMAN備份檔案有壞塊的恢復案例
- 備份&恢復之十三:損壞全部控制檔案
- 某個資料檔案損壞完全恢復(三)
- index損壞恢復Index
- inactive狀態日誌組檔案損壞的恢復
- 磁碟損壞導致資料檔案丟失的恢復
- 一次控制檔案損壞後的恢復經歷
- INDEX表空間檔案丟失或者損壞的恢復Index
- coreldraw檔案丟失(損壞)的恢復處理辦法
- 【RMAN】如果控制檔案損壞那麼如何恢復?恢復控制檔案的方式有哪幾種?
- 控制檔案損壞恢復(20100402)
- 備份&恢復之十二:損壞單個控制檔案
- Oracle資料檔案損壞恢復例項二則Oracle
- u盤檔案損壞怎麼恢復資料 u盤損壞無法讀取怎麼恢復資料
- REDO日誌損壞,非歸檔模式資料檔案恢復模式