目录
数据库OPEN读取数据文件头
SQL> startup mount
ORACLE instance started.
Total System Global Area 1486495744 bytes
Fixed Size 2253384 bytes
Variable Size 436211128 bytes
Database Buffers 1040187392 bytes
Redo Buffers 7843840 bytes
Database mounted.
SQL> alter session set events '10046 trace name context forever,level 8';
Session altered.
SQL> alter database open;
Database altered.
SQL> alter session set events '10046 trace name context off';
Session altered.
SQL> select value from v$diag_info where name='Default Trace File';
VALUE
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_10511.trc
查看trace文件,打开数据库时读取数据文件头1号块(文件头0号块只存放操作系统信息,包括文件大小和数据块大小,比如8192)
WAIT #140058386675448: nam='db file sequential read' ela= 6 file#=1 block#=1 blocks=1 obj#=-1 tim=1602642408337050
WAIT #140058386675448: nam='db file sequential read' ela= 2 file#=2 block#=1 blocks=1 obj#=-1 tim=1602642408337074
WAIT #140058386675448: nam='db file sequential read' ela= 2 file#=3 block#=1 blocks=1 obj#=-1 tim=1602642408337089
WAIT #140058386675448: nam='db file sequential read' ela= 1 file#=4 block#=1 blocks=1 obj#=-1 tim=1602642408337095
WAIT #140058386675448: nam='db file sequential read' ela= 2 file#=5 block#=1 blocks=1 obj#=-1 tim=1602642408337102
WAIT #140058386675448: nam='db file sequential read' ela= 1 file#=6 block#=1 blocks=1 obj#=-1 tim=1602642408337108
WAIT #140058386675448: nam='db file sequential read' ela= 2 file#=7 block#=1 blocks=1 obj#=-1 tim=1602642408337117
WAIT #140058386675448: nam='db file sequential read' ela= 2 file#=8 block#=1 blocks=1 obj#=-1 tim=1602642408337123
WAIT #140058386675448: nam='db file sequential read' ela= 1 file#=9 block#=1 blocks=1 obj#=-1 tim=1602642408337128
WAIT #140058386675448: nam='db file sequential read' ela= 2 file#=10 block#=1 blocks=1 obj#=-1 tim=1602642408337135
WAIT #140058386675448: nam='db file sequential read' ela= 2 file#=11 block#=1 blocks=1 obj#=-1 tim=1602642408337141
WAIT #140058386675448: nam='db file sequential read' ela= 1 file#=12 block#=1 blocks=1 obj#=-1 tim=1602642408337147
损坏SYSTEM数据文件头
oracle@dblab ~]$ bbed parfile=par.txt
BBED: Release 2.0.0.0.0 - Limited Production on Wed Oct 14 10:38:00 2020
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> info
File# Name Size(blks)
----- ---- ----------
1 /u01/app/oracle/oradata/orcl/system01.dbf 96000
2 /u01/app/oracle/oradata/orcl/sysaux01.dbf 70400
3 /u01/app/oracle/oradata/orcl/undotbs01.dbf 11520
4 /u01/app/oracle/oradata/orcl/users01.dbf 4640
5 /u01/app/oracle/oradata/orcl/users02.dbf 195072
6 /u01/app/oracle/oradata/orcl/infa_tbs01.dbf 25600
7 /u01/app/oracle/oradata/orcl/infa_tbs02.dbf 1280
8 /u01/app/oracle/oradata/orcl/infa_tbs03.dbf 640
9 /u01/app/oracle/oradata/orcl/infa_idx01.dbf 1280
10 /u01/app/oracle/oradata/orcl/ogg01.dbf 2560
11 /u01/app/oracle/oradata/orcl/system02.dbf 6400
12 /u01/app/oracle/oradata/orcl/undotbs02.dbf 20480
BBED> copy file 4 block 10 to file 1 block 1;
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 0 to 511 Dba:0x00400001
------------------------------------------------------------------------
1ea20000 0a000001 203f0000 00000104 a6010000 04000000 80403600 00000000
00000000 00f80000 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 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 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
<32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0x01a6, required = 0x01a6
数据库无法正常关闭和启动
SQL> shutdown immediate
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/system01.dbf'
ORA-01210: data file header is media corrupt
SQL> startup force
ORACLE instance started.
Total System Global Area 1486495744 bytes
Fixed Size 2253384 bytes
Variable Size 436211128 bytes
Database Buffers 1040187392 bytes
Redo Buffers 7843840 bytes
Database mounted.
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/system01.dbf'
ORA-01210: data file header is media corrupt
BBED操作文件头,显示无效块结构
BBED> set file 1 block 1;
FILE# 1
BLOCK# 1
BBED> map /v
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Dba:0x00400001
------------------------------------------------------------
BBED-00400: invalid blocktype (30)
构造文件头结构
用2号文件1号块覆盖1号文件1号块
BBED> set file 2 block 1
FILE# 2
BLOCK# 1
BBED> map /v
File: /u01/app/oracle/oradata/orcl/sysaux01.dbf (2)
Block: 1 Dba:0x00800001
------------------------------------------------------------
Data File Header
struct kcvfh, 860 bytes @0
struct kcvfhbfh, 20 bytes @0
struct kcvfhhdr, 76 bytes @20
BBED> copy file 2 block 1 to file 1 block 1;
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 0 to 511 Dba:0x00400001
------------------------------------------------------------------------
0ba20000 01008000 00000000 00000104 79bf0000 00000000 0004200b 0752605b
4f52434c 00000000 39110000 00130100 00200000 02000300 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 2a070000 00000000 81c92131 8906eb3b 06200e00 00000000 00000000
00000000 00000000 00000400 28010000 78b7b63d 27010000 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 01000000 06005359 53415558 00000000 00000000
00000000 00000000 00000000 00000000 02000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
7ac92131 01000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 4ea34100 00000000 e848cf3e 01000000 86000000 61330000 10000000
<32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0xbf79, required = 0xbf79
要修复列表
1. rdba_kcbh(offset 4) 文件头block的rdba地址
2. kccfhfsz (offset 44) 文件大小
3. kccfhfno (offset 52) datafile文件号
4. kcvfhrdb (offset 96) root dba
5. kscnbas (offset 100) v$datafile.creation_change#
6. kcvfhcrt (offset 108) v$datafile.creation_time
7. kcvfhsta (offset 138) 文件状态
8. kcvfhtsn (offset 332) 表空间号v$datafile.ts#
9.kcvfhtln (offset 336) 表空间名称字符长度
10. kcvfhtnm (offset 338) 表空间名称v$tablespace.name
11. kcvfhrfn (offset 368) 相对文件号v$datafile.rfile#
12. kscnbas (offset 484) checkpoint scn
13.kcvcptim (offset 492) last checkpoint time
14.kcvfhcpc (offset 144) Datafile checkpoint count
修复文件头block的rdba地址(offset 4)
BBED> set file 1 block 1;
FILE# 1
BLOCK# 1
--可以用show all查看当前操作的文件和地址
BBED> show all
FILE# 1
BLOCK# 1
OFFSET 0
DBA 0x00400001 (4194305 1,1)
FILENAME /u01/app/oracle/oradata/orcl/system01.dbf
BIFILE bifile.bbd
LISTFILE filelist.txt
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No
BBED> map /v
File: /u01/app/oracle/oradata/orcl/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, 36 bytes @484
ub4 kcvfhcpc @140
ub4 kcvfhrts @144
ub4 kcvfhccc @148
struct kcvfhbcp, 36 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
rdba地址在结构体kcvfhbfh中
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 0xbf79
ub2 spare3_kcbh @18 0x0000
rdba地址转换(用电脑自带的calc计算器)
rdba由文件号和块号组成,共4个字节,文件号占10bit,块号占22bit
将0x00800001转换为2进制如下:
0000 0000 1000 0000 0000 0000 0000 0001(这里是2号文件1号块,因为上面用2号文件1号块覆盖的1号文件1号块)
1号文件1号块是0000 0000 0100 0000 0000 0000 0000 0001,对应的16进制为0x00400001
BBED> set offset 4
OFFSET 4
BBED> dump /v count 16
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 4 to 19 Dba:0x00400001
-------------------------------------------------------
01008000 00000000 00000104 79bf0000 l ............y
<16 bytes per line>
BBED> modify /x 010040 --注意linux平台为小端,要调整
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 4 to 19 Dba:0x00400001
------------------------------------------------------------------------
01004000 00000000 00000104 79bf0000
<32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0xbfb9, required = 0xbfb9
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 0xbfb9
ub2 spare3_kcbh @18 0x0000
修复文件头文件大小(offset 44)
BBED> p kcvfhhdr
ub4 kccfhfsz @44 0x00011300
[oracle@dblab orcl]$ ll system01*
-rw-r----- 1 oracle oinstall 786440192 Oct 14 15:15 system01.dbf
SQL> select (786440192-8192)/8192 from dual; --除去0号块大小
(786440192-8192)/8192
---------------------
96000
转换为16进制
SQL> select to_char(96000,'xxxxxxxxxxx') from dual;
TO_CHAR(9600
------------
17700
BBED> set offset 44
OFFSET 44
BBED> dump /v count 16
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 44 to 59 Dba:0x00400001
-------------------------------------------------------
00130100 00200000 02000300 00000000 l ..... ..........
<16 bytes per line>
BBED> modify /x 007701
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 44 to 59 Dba:0x00400001
------------------------------------------------------------------------
00770100 00200000 02000300 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0xdbb9, required = 0xdbb9
修复文件头文件号(offset 52)
将文件号从2号改成1号
BBED> p kcvfhhdr
ub2 kccfhfno @52 0x0002
BBED> set offset 52
OFFSET 52
BBED> dump /v count 16
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 52 to 67 Dba:0x00400001
-------------------------------------------------------
02000300 00000000 00000000 00000000 l ................
<16 bytes per line>
BBED> modify /x 01
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 52 to 67 Dba:0x00400001
------------------------------------------------------------------------
01000300 00000000 00000000 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0xdbba, required = 0xdbba
修复文件头root数据块号(offset 96)
修改root数据块号为1号520块
SQL> select to_char(520,'xxxxxxxxxxxxxxxxxxx') from dual;
TO_CHAR(520,'XXXXXXX
--------------------
208
0000 0000 0100 0000 0000 0010 0000 1000
转换为16进制为0x00400208
如果数据库正常打开的话,可以根据下面语句查看
select fhrdb,FHFNO from x$kcvfh order by 2;
FHRDB FHFNO
---------- ----------
4194824 1
SQL> select to_char(4194824,'xxxxxxxxx') from dual;
TO_CHAR(41
----------
400208
SQL> select dbms_utility.data_block_address_file(TO_NUMBER('400208','XXXXXXXX')) file_id,2 dbms_utility.data_block_address_block(TO_NUMBER('400208', 'XXXXXXXX'))block_id from dual;
FILE_ID BLOCK_ID
---------- ----------
1 520 =>1号文件520号块
BBED> set offset 96
OFFSET 96
BBED> dump /v count 16
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 96 to 111 Dba:0x00400001
-------------------------------------------------------
00000000 2a070000 00000000 81c92131 l ....*........
<16 bytes per line>
BBED> modify /x 080240
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 96 to 111 Dba:0x00400001
------------------------------------------------------------------------
08024000 2a070000 00000000 81c92131
<32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0xd9f2, required = 0xd9f2
修复文件创建SCN(offset 100)
BBED> p kcvfhcrs
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x0000072a
ub2 kscnwrp @104 0x0000
从v$database视图中查看文件创建时scn(信息来自控制文件)
SQL> select FILE#,CREATION_CHANGE# from v$datafile;
1 7
2 1834
3 923328
4 16143
5 971384
6 987012
7 1395171
8 1395438
9 1395738
10 1503813
11 1860850
12 3041912
12 rows selected.
SQL> select to_char(1834,'xxxxxxxxxxx') from dual;
72a
BBED> set offset 100
OFFSET 100
BBED> dump /v count 16
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 100 to 115 Dba:0x00400001
-------------------------------------------------------
2a070000 00000000 81c92131 8906eb3b l *.........
<16 bytes per line>
BBED> modify /x 07000000
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 100 to 115 Dba:0x00400001
------------------------------------------------------------------------
07000000 00000000 81c92131 8906eb3b
<32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0xdedf, required = 0xdedf
修复文件创建时间(offset 108)
SQL> select file#,
2 to_char(creation_time, 'yyyy-mm-dd hh24:mi:ss') creation_time_file,
3 (to_char(creation_time, 'yyyy') - 1988) * 12 * 31 * 24 * 3600 +
4 (to_char(creation_time, 'mm') - 1) * 31 * 24 * 3600 +
5 (to_char(creation_time, 'dd') - 1) * 24 * 3600 +
6 to_char(creation_time, 'hh24') * 3600 + to_char(creation_time, 'mi') * 60 + to_char(creation_time, 'ss') creation_name_scn
7 from v$datafile
8 order by 1;
1 2013-08-24 11:37:33 824297853
2 2013-08-24 11:37:37 824297857
3 2013-08-24 12:07:19 824299639
4 2013-08-24 11:37:49 824297869
5 2019-04-11 22:05:54 1005343554
6 2019-05-14 09:21:03 1008235263
7 2019-06-11 16:24:48 1010679888
8 2019-06-11 16:24:58 1010679898
9 2019-06-11 16:25:54 1010679954
10 2019-07-18 14:42:33 1013956953
11 2020-03-14 01:07:06 1034989626
12 2020-03-14 01:30:54 1034991054
SQL> select to_char(824297853,'xxxxxxxxxxxx') from dual;
3121c97d
BBED> set offset 108
OFFSET 108
BBED> dump /v count 16
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 108 to 123 Dba:0x00400001
-------------------------------------------------------
81c92131 8906eb3b 06200e00 00000000 l ........
<16 bytes per line>
BBED> modify /x 7dc92131
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 108 to 123 Dba:0x00400001
------------------------------------------------------------------------
7dc92131 8906eb3b 06200e00 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0xde23, required = 0xde23
修复文件状态(offset 138)
BBED> p offset 138
kcvfh.kcvfhsta
--------------
ub2 kcvfhsta @138 0x0004 (KCVFHOFZ)
当一个datafile处于fuzzy状态的时候,其kcvfhsta为0x04,这里是abort关闭,状态是04,不修改,如果是正常关闭,则是0x2000
修复文件头的表空间号(offset 332)
1号文件表空间号为0,根据下面语句查出
SQL> select FILE#,TS# from v$datafile;
1 0
2 1
3 2
4 4
5 4
6 6
7 6
8 6
9 7
10 8
11 0
12 2
12 rows selected.
BBED> p kcvfhtsn
sword kcvfhtsn @332 1
BBED> set offset 332
OFFSET 332
BBED> dump /v count 16
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 332 to 347 Dba:0x00400001
-------------------------------------------------------
01000000 06005359 53415558 00000000 l ......SYSAUX....
<16 bytes per line>
BBED> modify /x 00
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 332 to 347 Dba:0x00400001
------------------------------------------------------------------------
00000000 06005359 53415558 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0xde22, required = 0xde22
修复表空间长度(offset 336)
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
本例不用修改
修复表空间名称(offset 338)
将338~343的SYSAUX改为SYSTEM
SQL> select dump('SYSTEM',16) from dual;
Typ=96 Len=6: 53,59,53,54,45,4d
BBED> dump /v count 16
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 338 to 353 Dba:0x00400001
-------------------------------------------------------
53595341 55580000 00000000 00000000 l SYSAUX..........<16 bytes per line>
BBED> set offset 338
OFFSET 338
BBED> dump /v count 16
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 338 to 353 Dba:0x00400001
-------------------------------------------------------
53595341 55580000 00000000 00000000 l SYSAUX..........<16 bytes per line>
BBED> set offset 341 --修改AUX为TEM
OFFSET 341
BBED> dump /v count 16
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 341 to 356 Dba:0x00400001
-------------------------------------------------------
41555800 00000000 00000000 00000000 l AUX.............<16 bytes per line>
BBED> modify /x 54454d
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 341 to 356 Dba:0x00400001
------------------------------------------------------------------------
54454d00 00000000 00000000 00000000 <32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0xde32, required = 0xde32
修复相对文件号(offset 368)
SQL> select FILE#,RFILE# from v$datafile;
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
BBED> set offset 368
OFFSET 368
BBED> dump /v count 16
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 368 to 383 Dba:0x00400001
-------------------------------------------------------
02000000 00000000 00000000 00000000 l ................<16 bytes per line>
BBED> modify /x 01
File: /u01/app/oracle/oradata/orcl/system01.dbf (1)
Block: 1 Offsets: 368 to 383 Dba:0x00400001
------------------------------------------------------------------------
01000000 00000000 00000000 00000000 <32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0xde31, required = 0xde31
修复检查点SCN(offset 484)
SQL> select file#,
2 CREATION_CHANGE#,
3 CHECKPOINT_CHANGE#,
4 UNRECOVERABLE_CHANGE#,
5 LAST_CHANGE#,
6 OFFLINE_CHANGE#
7 from v$datafile
8 order by 1;
FILE# CREATION_CHANGE# CHECKPOINT_CHANGE# UNRECOVERABLE_CHANGE# LAST_CHANGE# OFFLINE_CHANGE#
---------- ---------------- ------------------ --------------------- ------------ ---------------
1 7 4301646 0 925701
2 1834 4301646 0 925701
3 923328 4301646 0 925701
4 16143 4301646 0 925701
5 971384 4301646 0 0
6 987012 4301646 0 0
7 1395171 4301646 0 0
8 1395438 4301646 0 0
9 1395738 4301646 0 0
10 1503813 4301646 0 0
11 1860850 4301646 0 0
12 3041912 4301646 0 0
SQL> select to_char(4301646,'xxxxxxxxxxxxxxxx') from dual;
41a34e
BBED> p kcvfhckp
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x0041a34e
本例不用改
修复检查点时间(offset 492)
SQL> select file#,
2 to_char(CHECKPOINT_TIME, 'yyyy-mm-dd hh24:mi:ss') CHECKPOINT_TIME_file,
3 (to_char(CHECKPOINT_TIME, 'yyyy') - 1988) * 12 * 31 * 24 * 3600 +
4 (to_char(CHECKPOINT_TIME, 'mm') - 1) * 31 * 24 * 3600 +
(to_char(CHECKPOINT_TIME, 'dd') - 1) * 24 * 3600 +
to_char(CHECKPOINT_TIME, 'hh24') * 3600 +
to_char(CHECKPOINT_TIME, 'mi') * 60 + to_char(CHECKPOINT_TIME, 'ss') CHECKPOINT_TIME_scn
from v$datafile
9 order by 1;
FILE# CHECKPOINT_TIME_FIL CHECKPOINT_TIME_SCN
---------- ------------------- -------------------
1 2020-10-14 10:26:48 1053772008
2 2020-10-14 10:26:48 1053772008
3 2020-10-14 10:26:48 1053772008
4 2020-10-14 10:26:48 1053772008
5 2020-10-14 10:26:48 1053772008
6 2020-10-14 10:26:48 1053772008
7 2020-10-14 10:26:48 1053772008
8 2020-10-14 10:26:48 1053772008
9 2020-10-14 10:26:48 1053772008
10 2020-10-14 10:26:48 1053772008
11 2020-10-14 10:26:48 1053772008
12 2020-10-14 10:26:48 1053772008
SQL> select to_char(1053772008,'xxxxxxxxxxxxxxxxxxxxxxx') from dual;
TO_CHAR(1053772008,'XXXX
------------------------
3ecf48e8
BBED> p kcvfhckp
ub4 kcvcptim @492 0x3ecf48e8
此例不用修改
dbv检查下文件头修改是否都正确
[oracle@dblab ~]$ dbv file=/u01/app/oracle/oradata/orcl/system01.dbf start=1 end=2
DBVERIFY: Release 11.2.0.4.0 - Production on Wed Oct 14 19:32:05 2020
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/orcl/system01.dbf
DBVERIFY - Verification complete
Total Pages Examined : 2
Total Pages Processed (Data) : 0
Total Pages Failing (Data) : 0
Total Pages Processed (Index) : 0
Total Pages Failing (Index) : 0
Total Pages Processed (Other) : 2
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 0
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 1860436 (0.1860436)
打开数据库
SQL> alter database open;
Database altered