Oracle-Data File Header 块结构研究
Data File Header 块结构
使用bbed查看块头结构
BBED> show
FILE# 1
BLOCK# 1
OFFSET 0
DBA 0x00400001 (4194305 1,1)
FILENAME /oradata/three/system01.dbf
BIFILE bifile.bbd
LISTFILE /home/oracle//script/bbed/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: /oradata/three/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
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 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 0xe045
ub2 spare3_kcbh @18 0x0000
struct kcvfhhdr, 76 bytes @20
ub4 kccfhswv @20 0x00000000
ub4 kccfhcvn @24 0x0b200400
ub4 kccfhdbi @28 0x1d190da4
text kccfhdbn[0] @32 T
text kccfhdbn[1] @33 H
text kccfhdbn[2] @34 R
text kccfhdbn[3] @35 E
text kccfhdbn[4] @36 E
text kccfhdbn[5] @37
text kccfhdbn[6] @38
text kccfhdbn[7] @39
ub4 kccfhcsq @40 0x0001579d
ub4 kccfhfsz @44 0x00017200
s_blkz kccfhbsz @48 0x00
ub2 kccfhfno @52 0x0001
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 0x00400208
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00000007
ub2 kscnwrp @104 0x0000
ub4 kcvfhcrt @108 0x3121c97d
ub4 kcvfhrlc @112 0x4059b066
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0x000e2006
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 0x2004 (KCVFHOFZ)
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x0035727d
ub2 kscnwrp @488 0x0000
ub4 kcvcptim @492 0x40b9ea2f
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x0000024c
ub4 kcrbabno @504 0x00011a3b
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
ub4 kcvfhcpc @140 0x000002a9
ub4 kcvfhrts @144 0x40b61687
ub4 kcvfhccc @148 0x000002a8
struct kcvfhbcp, 36 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
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 0
ub2 kcvfhtln @336 0x0006
text kcvfhtnm[0] @338 S
text kcvfhtnm[1] @339 Y
text kcvfhtnm[2] @340 S
text kcvfhtnm[3] @341 T
text kcvfhtnm[4] @342 E
text kcvfhtnm[5] @343 M
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 0x00000001
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 0x000a
ub2 kcvfhnfb @414 0x000a
ub4 kcvfhprc @416 0x3121c97a
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
操作实践--块头损坏
故障信息
#故障1 ORA-01210\ORA-01110\ORA-01122
SQL> startup
ORACLE instance started.
Total System Global Area 914440192 bytes
Fixed Size 2258600 bytes
Variable Size 297797976 bytes
Database Buffers 608174080 bytes
Redo Buffers 6209536 bytes
Database mounted.
ORA-01122: database file 6 failed verification check
ORA-01110: data file 6: '/oradata/three/zsdba02.dbf'
ORA-01210: data file header is media corrupt
环境准备
[oracle@zstest bbed]$ dba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 15 10:41:21 2021
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, OLAP, Data Mining and Real Application Testing options
SQL> col TABLESPACE_NAME for a20
SQL> col FILE_NAME for a60
SQL> set linesize 200
SQL> select TABLESPACE_NAME,FILE_ID,STATUS,FILE_NAME,BYTES/1024/1024 from dba_data_files;
TABLESPACE_NAME FILE_ID STATUS FILE_NAME BYTES/1024/1024
------------------------ ------------ -------------------------------- ---------------
USERS 4 AVAILABLE /oradata/three/users01.dbf 552.5
UNDOTBS1 3 AVAILABLE /oradata/three/undotbs01.dbf 775
SYSAUX 2 AVAILABLE /oradata/three/sysaux01.dbf 970
SYSTEM 1 AVAILABLE /oradata/three/system01.dbf 740
ZSDBA 5 AVAILABLE /oradata/three/zsdba01.dbf 100
ZSDBA 6 AVAILABLE /oradata/three/zsdba02.dbf 50
6 rows selected.
模拟块头损坏
dd 6号数据文件
[oracle@zstest tmp]$ dd if=/dev/zero of=/oradata/three/zsdba02.dbf bs=8k count=1 seek=1 conv=notrunc
关闭数据,发现无法正常关闭,错误产生
SQL> shutdown immediate
ORA-01122: database file 6 failed verification check
ORA-01110: data file 6: '/oradata/three/zsdba02.dbf'
ORA-01210: data file header is media corrupt
强制关闭
SQL> shutdown abort;
ORACLE instance shut down.
尝试打开数据库,无法打开,错误产生
SQL> startup
ORACLE instance started.
Total System Global Area 914440192 bytes
Fixed Size 2258600 bytes
Variable Size 297797976 bytes
Database Buffers 608174080 bytes
Redo Buffers 6209536 bytes
Database mounted.
ORA-01122: database file 6 failed verification check
ORA-01110: data file 6: '/oradata/three/zsdba02.dbf'
ORA-01210: data file header is media corrupt
数据库报错日志
Hex dump of (file 6, block 1) in trace file /u01/app/oracle/diag/rdbms/three/three/trace/three_ora_22537.trc
Corrupt block relative dba: 0x01800001 (file 6, block 1)
Completely zero block found during datafile header read
Errors in file /u01/app/oracle/diag/rdbms/three/three/trace/three_ora_22537.trc:
ORA-01122: database file 6 failed verification check
ORA-01110: data file 6: '/oradata/three/zsdba02.dbf'
ORA-01210: data file header is media corrupt
bbed恢复--同一表空间恢复
bbed查看块头
发现块头无数据,证明之前dd的效果,数据文件header坏掉,同样map也无法读取当前块头,再次证明块头已损坏。
BBED> dump
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Offsets: 0 to 511 Dba:0x01800001
------------------------------------------------------------------------
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> map
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Dba:0x01800001
------------------------------------------------------------
BBED-00400: invalid blocktype (00)
复制数据块头
为了方便,复制同一个表空间的文件头
BBED> set dba 5,1
DBA 0x01400001 (20971521 5,1)
BBED> set dba 6,1
DBA 0x01800001 (25165825 6,1)
BBED> copy dba 0x01400001 to dba 0x01800001
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) Y
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Offsets: 0 to 3 Dba:0x01800001
------------------------------------------------------------------------
0ba20000
<32 bytes per line>
BBED> map
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Dba:0x01800001
------------------------------------------------------------
Data File Header
struct kcvfh, 860 bytes @0
ub4 tailchk @508
map可查看到数据块,并显示为Data File Header
修复数据块头
由于块头内容,同一表空间,部分内容不一样,需要修订,修订内容如下:
rdba_kcbh (Block address)
kccfhfsz (Filesize) 文件当前所包含数据块的个数
kccfhfno (File number) 文件号
kcvfhcrs (File created scn) 文件创建时的SCN
kcvfhrfn (Relateive file number) 相对文件号
kcvfhcrt(file create time) 文件创建时间
/*需要修改内容
ub4 rdba_kcbh @4 0x01400001
ub4 kccfhfsz @44 0x00003200
ub2 kccfhfno @52 0x0005
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00389ccb
ub2 kscnwrp @104 0x0000
ub4 kcvfhrfn @368 0x00000005
ub4 kcvfhcrt @108 0x40beff52
/
修复ub4 rdba_kcbh 4
rdba_kcbh计算方式暂时不清楚,可以通过折中方式查看
BBED> set dba 6,1
DBA 0x01800001 (25165825 6,1) <=====此处显示为rdba_kcbh值
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 0x01400001 <==== 修改此处
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 0xe2c2
ub2 spare3_kcbh @18 0x0000
BBED> set offset 4
OFFSET 4
BBED> d
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Offsets: 4 to 7 Dba:0x01800001
------------------------------------------------------------------------
01004001
<32 bytes per line>
# 通过set dba 6,1 得到rdba为01800001,由于小编码存储,实际存储为01008001
BBED> modify /x 01008001 dba 6,1 offset 4
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Offsets: 4 to 7 Dba:0x01800001
------------------------------------------------------------------------
01008001
<32 bytes per line>
BBED> sum apply
Check value for File 6, Block 1:
current = 0xe84f, required = 0xe84f
修复ub4 kccfhfsz 44
# ub4 kccfhfsz 存储为数据文件块数
# 通过查看zsdba02.dbf的实际大小,换算成块数,计算其16进制
[oracle@zstest three]$ ll
-rw-r----- 1 oracle oinstall 52428800 Oct 15 13:46 zsdba02.dbf
....
SQL> select 52428800/8192 from dual;
52428800/8192
-------------
6400
# 通过dbfsize也可查看块数
[oracle@zstest ~]$ dbfsize /oradata/three/zsdba02.dbf
Database file: /oradata/three/zsdba02.dbf
Database file type: file system
Database file size: 6400 8192 byte blocks <===== 6400个8k
SQL> select to_char(6400,'xxxxxxxxxxx') from dual;
TO_CHAR(6400,'XXXXXXXXXXX')
------------------------------------
1900
# 计算的kccfhfsz 16进制位1900,由于小编码存储,实际存储为0019000
BBED> modify /x 00190000 dba 6,1 offset 44
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Offsets: 44 to 47 Dba:0x01800001
------------------------------------------------------------------------
00019000
<32 bytes per line>
BBED> sum apply
Check value for File 6, Block 1:
current = 0xdbdf, required = 0xdbdf
修复ub2 kccfhfno 52
# ub2 kccfhfno 存储文件号,可以通过v$datafile视图查看
SQL> select FILE#,RFILE#,BYTES,BLOCKS,name from v$datafile;
FILE# RFILE# BYTES BLOCKS NAME
---------- ---------- ---------- ---------- ---------------------------------------------
1 1 775946240 94720 /oradata/three/system01.dbf
2 2 1017118720 124160 /oradata/three/sysaux01.dbf
3 3 812646400 99200 /oradata/three/undotbs01.dbf
4 4 579338240 70720 /oradata/three/users01.dbf
5 5 104857600 12800 /oradata/three/zsdba01.dbf
6 6 0 0 /oradata/three/zsdba02.dbf
6 rows selected.
SQL> select to_char(6,'xxxxxxxxxxx') from dual;
TO_CHAR(6,'XXXXXXXXXXX')
------------------------------------
6
# 文件号为6,16进制也是6,由于小编码存储,实际存储为0600
BBED> modify /x 0600 dba 6,1 offset 52
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Offsets: 52 to 67 Dba:0x01800001
------------------------------------------------------------------------
06000300 00000000 00000000 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 6, Block 1:
current = 0xdbdc, required = 0xdbdc
修复struct kcvfhcrs 100
# struct kcvfhcrs 文件创建时的SCN
# 通过查看v$datafile的CREATION_CHANGE#字段,获取文件创建时SCN,转换为16进制
SQL> select file#,to_char(creation_time,'yyyymmdd hh24miss'),CREATION_CHANGE# from v$datafile;
FILE# TO_CHAR(CREATION_TIME,'YYYYMMDDHH24MISS') CREATION_CHANGE#
---------- --------------------------------------------- ----------------
1 20130824 113733 7
2 20130824 113737 1834
3 20130824 120719 923328
4 20130824 113749 16143
5 20210805 154242 1074381
6 20211018 103706 3710155
6 rows selected.
SQL> select to_char(3710155,'xxxxxxxxxx') from dual;
TO_CHAR(3710155,'XXXXXXXXXX')
---------------------------------
389ccb
# 16进制为389ccb,由于小编码存储,实际存储为cb9c3800
BBED> modify /x cb9c3800 dba 6,1 offset 100
BBED-00209: invalid number (cb9c3800)
BBED> modify /x cb9c38 dba 6,1 offset 100
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Offsets: 100 to 611 Dba:0x01800001
------------------------------------------------------------------------
cb9c3800
BBED> sum apply
Check value for File 6, Block 1:
current = 0xbb97, required = 0xbb97
修复ub4 kcvfhrfn 368
# ub4 kcvfhrfn存储相对文件编号
SQL> col name for a40
SQL> select FILE#,RFILE#,BYTES,BLOCKS,name from v$datafile;
FILE# RFILE# BYTES BLOCKS NAME
---------- ---------- ---------- ---------- ----------------------------------------
1 1 775946240 94720 /oradata/three/system01.dbf
2 2 1017118720 124160 /oradata/three/sysaux01.dbf
3 3 812646400 99200 /oradata/three/undotbs01.dbf
4 4 579338240 70720 /oradata/three/users01.dbf
5 5 104857600 12800 /oradata/three/zsdba01.dbf
6 6 0 0 /oradata/three/zsdba02.dbf
6 rows selected.
SQL> select to_char(6,'xxxxxxxxxxx') from dual;
TO_CHAR(6,'XXXXXXXXXXX')
------------------------------------
6
# 文件号为6,16进制也是6,由于小编码存储,实际存储为0600
BBED> modify /x 0600 dba 6,1 offset 368
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Offsets: 368 to 511 Dba:0x01800001
------------------------------------------------------------------------
06000000
<32 bytes per line>
BBED> sum apply
Check value for File 6, Block 1:
current = 0xdbdf, required = 0xdbdf
修复ub4 kcvfhcrt 108
# ub4 kcvfhcrt 存储文件file create time
# 通过v$datafile视图查看creation_time字段,然后减去"19880101 000000"得出差异天数,折算为秒,换算成16进制
# 获取creation_time
SQL> select file#,to_char(creation_time,'yyyymmdd hh24miss') from v$datafile;
FILE# TO_CHAR(CREATION_TIME,'YYYYMMDDHH24MISS')
---------- ---------------------------------------------
1 20130824 113733
2 20130824 113737
3 20130824 120719
4 20130824 113749
5 20210805 154242
6 20211018 103706
6 rows selected.
# 获取差异天数
20211018 103706
19880101 000000
330917 103706 --差异天数
# 折算为秒
select 33*12*31*24*60*60 --年
+9*31*24*60*60+ --月
17*24*60*60+ --天
10*60*60+ --小时
37*60 --分钟
+6 from dual --s
;
33*12*31*24*60*60--年+9*31*24*60*60+--月14*24*60*60+--天10*60*60+--小时35*60--分
--------------------------------------------------------------------------------
1086259026
# 换算为16进制
select to_char(1086259026,'XXXXXXXX') from dual;
TO_CHAR(1086259026,'XXXXXXX
---------------------------
40BEFF52
# 由于小编码存储,52ffbe40
BBED> modify /x 52ffbe40 dba 6,1 offset 108
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Offsets: 108 to 619 Dba:0x01800001
------------------------------------------------------------------------
52ffbe40
重建控制文件
尝试打开数据库
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01122: database file 6 failed verification check
ORA-01110: data file 6: '/oradata/three/zsdba02.dbf'
ORA-01207: file is more recent than control file - old control file
备份控制文件
SQL> alter database backup controlfile to trace as '/home/oracle/a.ctl';
Database altered.
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
重建控制文件
SQL> startup nomount
ORACLE instance started.
Total System Global Area 914440192 bytes
Fixed Size 2258600 bytes
Variable Size 297797976 bytes
Database Buffers 608174080 bytes
Redo Buffers 6209536 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "THREE" NORESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 1600
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/oradata/three/redo01.log' SIZE 50M BLOCKSIZE 512,
9 GROUP 2 '/oradata/three/redo02.log' SIZE 50M BLOCKSIZE 512,
10 GROUP 3 '/oradata/three/redo03.log' SIZE 50M BLOCKSIZE 512
11 -- STANDBY LOGFILE
12 DATAFILE
13 '/oradata/three/system01.dbf',
14 '/oradata/three/sysaux01.dbf',
15 '/oradata/three/undotbs01.dbf',
16 '/oradata/three/users01.dbf',
17 '/oradata/three/zsdba01.dbf',
18 '/oradata/three/zsdba02.dbf'
19 CHARACTER SET WE8MSWIN1252
20 ;
Control file created.
SQL> recover database ;
Media recovery complete.
SQL> alter database open;
Database altered.
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/oradata/three/temp01.dbf' REUSE;
Tablespace altered.
SQL> ALTER TABLESPACE T_TEMP ADD TEMPFILE '/oradata/three/t_temp01.dbf' REUSE;
Tablespace altered.
bbed恢复--不同表空间恢复(附加)
假如损坏的数据文件头所在的表空间,只有1个数据文件,此时需要从其他表空间找一个数据文件头复制,需要改动的地方较多。
###############################修改数据文件头的注意点:
1、修改数据的DBA,rdba_kcbh
2、修改文件的大小,kccfhfsz
3、修改文件号,kccfhfno
4、修改文件创建时SCN,kcvfhcrs
5、修改文件创建时间,kcvfhcrt
6、修改表空间号,kcvfhtsn
7、修改相对文件号,kcvfhrfn
8、修改表空间的名称, kcvfhtnm
9、修改表空间的长度,kcvfhtln
10、修改检查点的SCN,kcvfhckp
11、修改检查点的时间,kcvcptim
12、修改检查点的计数器,kcvfhcpc
13、修改检查点的控制文件备份的计数器, kcvfhccc
14、如果你修改是1号文件的1号块他的root rdba的地针是指向了bootstrap$
1 ub4 rdba_kcbh @4 0x01c00001
2 ub4 kccfhfsz @44 0x00000f00
3 ub2 kccfhfno @52 0x0007
4 struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x0039a3ef
ub2 kscnwrp @104 0x0000
5 ub4 kcvfhcrt @108 0x40bf3bc8
6 sword kcvfhtsn @332 8
7 ub4 kcvfhrfn @368 0x00000007
8 text kcvfhtnm[0] @338 T
text kcvfhtnm[1] @339 E
text kcvfhtnm[2] @340 S
text kcvfhtnm[3] @341 T
text kcvfhtnm[4] @342 D
text kcvfhtnm[5] @343 D
9 ub2 kcvfhtln @336 0x0006
10 struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x0039a3f0
ub2 kscnwrp @488 0x0000
11 ub4 kcvcptim @492 0x40bf3bc8
12 ub4 kcvfhcpc @140 0x00000002
13 ub4 kcvfhccc @148 0x00000001
dd 7号数据文件
col TABLESPACE_NAME for a10
col FILE_NAME for a40
col STATUS for a10
set linesize 200
select TABLESPACE_NAME,FILE_ID,STATUS,FILE_NAME,BYTES/1024/1024 from dba_data_files;
TABLESPACE FILE_ID STATUS FILE_NAME BYTES/1024/1024
---------- ---------- ---------- ---------------------------------------- ---------------
ZSDBA 6 AVAILABLE /oradata/three/zsdba02.dbf 50
ZSDBA 5 AVAILABLE /oradata/three/zsdba01.dbf 100
USERS 4 AVAILABLE /oradata/three/users01.dbf 552.5
UNDOTBS1 3 AVAILABLE /oradata/three/undotbs01.dbf 775
SYSAUX 2 AVAILABLE /oradata/three/sysaux01.dbf 990
SYSTEM 1 AVAILABLE /oradata/three/system01.dbf 740
TESTDD 7 AVAILABLE /oradata/three/testdd01.dbf 30
7 rows selected.
[oracle@zstest tmp]$ dd if=/dev/zero of=/oradata/three/testdd01.dbf bs=8k count=1 seek=1 conv=notrunc
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 0.000172407 s, 47.5 MB/s
SQL> shutdown immediate
ORA-01122: database file 7 failed verification check
ORA-01110: data file 7: '/oradata/three/testdd01.dbf'
ORA-01210: data file header is media corrupt
bbed查看块头
BBED> set dba 7,1
DBA 0x01c00001 (29360129 7,1)
BBED> d
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 0 to 511 Dba:0x01c00001
------------------------------------------------------------------------
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> map /v
File: /oradata/three/testdd01.dbf (7)
Block: 1 Dba:0x01c00001
------------------------------------------------------------
BBED-00400: invalid blocktype (00)
复制数据块头
BBED> copy file 5 block 1 to file 7 block 1
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 0 to 511 Dba:0x01c00001
------------------------------------------------------------------------
0ba20000 01004001 00000000 00000104 a3f30000 00000000 0004200b a40d191d
54485245 45000000 11600100 00320000
<32 bytes per line>
BBED> set dba 7,1
DBA 0x01c00001 (29360129 7,1)
BBED> map
File: /oradata/three/testdd01.dbf (7)
Block: 1 Dba:0x01c00001
------------------------------------------------------------
Data File Header
struct kcvfh, 860 bytes @0
ub4 tailchk @8188
BBED> d dba 7,1 offset 0 count 16
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 0 to 15 Dba:0x01c00001
------------------------------------------------------------------------
0ba20000 01004001 00000000 00000104
<32 bytes per line>
修复数据块头
修复ub4 rdba_kcbh 4
# ub4 rdba_kcbh 存储文件rdba
# 通过set dba 6,1 得到rdba为0x01c00001,由于小编码存储,实际存储为0100c001
BBED> d dba 7,1 offset 4 count 16
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 4 to 19 Dba:0x01c00001 <======
------------------------------------------------------------------------
01004001 00000000 00000104 1a1c0000
<32 bytes per line>
BBED> modify /x 0100c001 dba 7,1 offset 4
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 4 to 19 Dba:0x01c00001
------------------------------------------------------------------------
0100c001 00000000 00000104 1a1c0000
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0x1c9a, required = 0x1c9a
修复ub4 kccfhfsz 44
# ub4 kccfhfsz 存储文件块数
[oracle@zstest tmp]$ dbfsize /oradata/three/testdd01.dbf
Database file: /oradata/three/testdd01.dbf
Database file type: file system
Database file size: 3840 8192 byte blocks
SQL> select to_char(3840,'xxxxxxxxxxx') from dual;
TO_CHAR(3840,'XXXXXXXXXXX')
------------------------------------
f00
# 计算的kccfhfsz 16进制位f00,由于小编码存储,实际存储为000f0000
BBED> d dba 6,1 offset 44
File: /oradata/three/zsdba02.dbf (6)
Block: 1 Offsets: 44 to 59 Dba:0x01800001
------------------------------------------------------------------------
00190000 00200000 06000300 00000000
<32 bytes per line>
BBED> modify /x 000f0000 dba 7,1 offset 44
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 44 to 59 Dba:0x01c00001
------------------------------------------------------------------------
000f0000 00200000 05000300 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0x219a, required = 0x219a
修复ub2 kccfhfno 52
# ub2 kccfhfno 存储文件号,可以通过v$datafile视图查看
set linesize 200
col name for a40
select FILE#,RFILE#,BYTES,BLOCKS,name from v$datafile;
FILE# RFILE# BYTES BLOCKS NAME
---------- ---------- ---------- ---------- ----------------------------------------
1 1 775946240 94720 /oradata/three/system01.dbf
2 2 1038090240 126720 /oradata/three/sysaux01.dbf
3 3 812646400 99200 /oradata/three/undotbs01.dbf
4 4 579338240 70720 /oradata/three/users01.dbf
5 5 104857600 12800 /oradata/three/zsdba01.dbf
6 6 52428800 6400 /oradata/three/zsdba02.dbf
7 7 31457280 3840 /oradata/three/testdd01.dbf
7 rows selected.
SQL> select to_char(7,'xxxxxxxxxxx') from dual;
TO_CHAR(7,'XXXXXXXXXXX')
------------------------------------
7
# 文件号为7,16进制也是7,由于小编码存储,实际存储为0700
BBED> d dba 7,1 offset 52
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 52 to 67 Dba:0x01c00001
------------------------------------------------------------------------
05000300 00000000 00000000 00000000
<32 bytes per line>
BBED> modify /x 0700 dba 7,1 offset 52
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 52 to 67 Dba:0x01c00001
------------------------------------------------------------------------
07000300 00000000 00000000 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0x2198, required = 0x2198
修复struct kcvfhcrs 100
# struct kcvfhcrs 存储文件创建时SCN
# 通过查看v$datafile的CREATION_CHANGE#字段,获取文件创建时SCN,转换为16进制
SQL> select file#,to_char(creation_time,'yyyymmdd hh24miss'),CREATION_CHANGE# from v$datafile;
FILE# TO_CHAR(CREATION_TIME,'YYYYMMDDHH24MISS') CREATION_CHANGE#
---------- --------------------------------------------- ----------------
1 20130824 113733 7
2 20130824 113737 1834
3 20130824 120719 923328
4 20130824 113749 16143
5 20210805 154242 1074381
6 20211018 103706 3710155
7 20211018 145504 3777519
7 rows selected.
SQL> select to_char(3777519,'xxxxxxxxxx') from dual;
TO_CHAR(3777519,'XXXXXXXXXX')
---------------------------------
39a3ef
# 16进制为39a3ef,由于小编码存储,实际存储为efa33900
BBED> d dba 7,1 offset 100
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 100 to 115 Dba:0x01c00001
------------------------------------------------------------------------
cd641000 00000000 72665c40 a273bb40
<32 bytes per line>
BBED> modify /x efa33900 dba 7,1 offset 100
BBED-00209: invalid number (efa33900)
BBED> modify /x efa339 dba 7,1 offset 100
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 100 to 115 Dba:0x01c00001
------------------------------------------------------------------------
efa33900 00000000 72665c40 a273bb40
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0xe693, required = 0xe693
修复ub4 kcvfhcrt 108
# ub4 kcvfhcrt 存储文件创建时间
select t.FILE#,
to_char(creation_time, 'yyyymmdd hh24miss'),
(to_char(creation_time, 'yyyy') - 1988) * 12 * 31 * 24 * 60 * 60 +
(to_char(creation_time, 'mm') - 1) * 31 * 24 * 60 * 60 +
(to_char(creation_time, 'dd') - 1) * 24 * 60 * 60 +
to_char(creation_time, 'hh24') * 60 * 60 +
to_char(creation_time, 'mi') * 60 +
to_char(creation_time, 'ss') CreateTimeSCN
from v$datafile t ;
FILE# TO_CHAR(CREATION_TIME,'YYYYMMDDHH24MISS') CREATETIMESCN
---------- --------------------------------------------- -------------
1 20130824 113733 824297853
2 20130824 113737 824297857
3 20130824 120719 824299639
4 20130824 113749 824297869
5 20210805 154242 1079797362
6 20211018 103706 1086259026
7 20211018 145504 1086274504
7 rows selected.
# 换算为16进制
select to_char(1086274504,'XXXXXXXX') from dual;
TO_CHAR(1086274504,'XXXXXXX
---------------------------
40BF3BC8
# 由于小编码存储,c83bbf40
BBED> d dba 7,1 offset 108
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 108 to 123 Dba:0x01c00001
------------------------------------------------------------------------
72665c40 a273bb40 4dad3600 00000000
<32 bytes per line>
BBED> modify /x c83bbf40 dba 7,1 offset 108
BBED-00209: invalid number (c83bbf40)
BBED> modify /x c83bbf dba 7,1 offset 108
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 108 to 123 Dba:0x01c00001
------------------------------------------------------------------------
c83bbf40 a273bb40 4dad3600 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0xbbca, required = 0xbbca
修复sword kcvfhtsn 332
# sword kcvfhtsn 存储表空间号
# 通过v$datafile视图获取TS#号
SQL> select FILE#,TS# from v$datafile;
FILE# TS#
---------- ----------
1 0
2 1
3 2
4 4
5 7
6 7
7 8
7 rows selected.
# 表空间号为8,16进制也是8,由于小编码存储,实际存储为0800
SQL> select to_char(8,'xxxxxxxxxxx') from dual;
TO_CHAR(8,'XXXXXXXXXXX')
------------------------------------
8
BBED> d dba 7,1 offset 332
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 332 to 347 Dba:0x01c00001
------------------------------------------------------------------------
07000000 05005a53 44424100 00000000
<32 bytes per line>
BBED> modify /x 0800 dba 7,1 offset 332
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 332 to 347 Dba:0x01c00001
------------------------------------------------------------------------
08000000 05005a53 44424100 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0xbbc5, required = 0xbbc5
修复ub4 kcvfhrfn 368
# ub4 kcvfhrfn存储文件相对文件号
# 通过查看v$datafile 的RFILE#字段
SQL> select FILE#,RFILE#,BYTES,BLOCKS,name from v$datafile;
FILE# RFILE# BYTES BLOCKS NAME
---------- ---------- ---------- ---------- ----------------------------------------
1 1 775946240 94720 /oradata/three/system01.dbf
2 2 1038090240 126720 /oradata/three/sysaux01.dbf
3 3 812646400 99200 /oradata/three/undotbs01.dbf
4 4 579338240 70720 /oradata/three/users01.dbf
5 5 104857600 12800 /oradata/three/zsdba01.dbf
6 6 52428800 6400 /oradata/three/zsdba02.dbf
7 7 31457280 3840 /oradata/three/testdd01.dbf
7 rows selected.
# 相对文件号为7,16进制也是7,由于小编码存储,实际存储为0700
BBED> d dba 7,1 offset 368
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 368 to 383 Dba:0x01c00001
------------------------------------------------------------------------
05000000 00000000 00000000 032ebf40
<32 bytes per line>
BBED> modify /x 0700 dba 7,1 offset 368
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 368 to 383 Dba:0x01c00001
------------------------------------------------------------------------
07000000 00000000 00000000 032ebf40
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0xbbc7, required = 0xbbc7
修复 kcvfhtnm 338
# kcvfhtnm 存储表空间名称
# 通过查看v$tablespace的NAME字段获取
SQL> select TS#,NAME FROM v$tablespace;
TS# NAME
---------- ----------------------------------------
0 SYSTEM
1 SYSAUX
2 UNDOTBS1
4 USERS
7 ZSDBA
3 TEMP
6 T_TEMP
8 TESTDD
8 rows selected.
SQL> select dump('TESTDD',16) from dual;
DUMP('TESTDD',16)
--------------------------------------------------------------------------------
Typ=96 Len=6: 54,45,53,54,44,44
# dump之后的54,45,53,54,44,44 即内部存储顺序,无需再次转换
BBED> d dba 7,1 offset 338
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 338 to 353 Dba:0x01c00001
------------------------------------------------------------------------
5a534442 41000000 00000000 00000000
<32 bytes per line>
BBED> modify /x 544553544444 dba 7,1 offset 338
BBED-00209: invalid number (544553544444)
BBED> modify /x 54455354 dba 7,1 offset 338
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 338 to 353 Dba:0x01c00001
------------------------------------------------------------------------
54455354 41000000 00000000 00000000
<32 bytes per line>
BBED> modify /x 4444 dba 7,1 offset 342
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 342 to 357 Dba:0x01c00001
-----------------------------------------------------------------------
44440000 00000000 00000000 00000000
<32 bytes per line>
BBED> d dba 7,1 offset 338
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 338 to 353 Dba:0x01c00001
------------------------------------------------------------------------
54455354 44440000 00000000 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0xffdb, required = 0xffdb
修复ub2 kcvfhtln 336
# ub2 kcvfhtln存储表空间长度
# 通过查看v$tablespace的NAME字段获取
SQL> select TS#,NAME FROM v$tablespace;
TS# NAME
---------- ----------------------------------------
0 SYSTEM
1 SYSAUX
2 UNDOTBS1
4 USERS
7 ZSDBA
3 TEMP
6 T_TEMP
8 TESTDD
8 rows selected.
SQL> select dump('TESTDD',16) from dual;
DUMP('TESTDD',16)
--------------------------------------------------------------------------------
Typ=96 Len=6: 54,45,53,54,44,44
# 表空间长度为6,16进制也是6,由于小编码存储,实际存储为0600
BBED> d dba 7,1 offset 336
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 336 to 351 Dba:0x01c00001
------------------------------------------------------------------------
05005445 53544444 00000000 00000000
<32 bytes per line>
BBED> modify /x 0600 dba 7,1 offset 336
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 336 to 351 Dba:0x01c00001
------------------------------------------------------------------------
06005445 53544444 00000000 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0xffd8, required = 0xffd8
修复struct kcvfhckp 484
# struct kcvfhckp存储检查点SCN
# 通过v$datafile的CHECKPOINT_CHANGE#字段获取
SQL> select t.FILE#,CHECKPOINT_CHANGE#, OFFLINE_CHANGE# from v$datafile t ;
FILE# CHECKPOINT_CHANGE# OFFLINE_CHANGE#
---------- ------------------ ---------------
1 3777159 0
2 3777159 0
3 3777159 0
4 3777159 0
5 3777159 0
6 3777159 0
7 3777520 0
7 rows selected.
SQL> select to_char(3777520,'xxxxxxxxxx') from dual;
TO_CHAR(3777520,'XXXXXXXXXX')
---------------------------------
39a3f0
# 16进制为39a3f0,由于小编码存储,实际存储为f0a33900
BBED> d dba 7,1 offset 484
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 484 to 499 Dba:0x01c00001
------------------------------------------------------------------------
87a23900 00000000 723bbf40 01000000
<32 bytes per line>
BBED> modify /x f0a33900 dba 7,1 offset 484
BBED-00209: invalid number (f0a33900)
BBED> modify /x f0a3 dba 7,1 offset 484
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 484 to 499 Dba:0x01c00001
------------------------------------------------------------------------
f0a33900 00000000 723bbf40 01000000
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0xfeaf, required = 0xfeaf
修复ub4 kcvcptim 492
# ub4 kcvcptim 存储检查点时间
# 通过v$datafile 的CHECKPOINT_TIME字段获取
select t.FILE#,
to_char(CHECKPOINT_TIME, 'yyyymmdd hh24miss'),
(to_char(CHECKPOINT_TIME, 'yyyy') - 1988) * 12 * 31 * 24 * 60 * 60 +
(to_char(CHECKPOINT_TIME, 'mm') - 1) * 31 * 24 * 60 * 60 +
(to_char(CHECKPOINT_TIME, 'dd') - 1) * 24 * 60 * 60 +
to_char(CHECKPOINT_TIME, 'hh24') * 60 * 60 +
to_char(CHECKPOINT_TIME, 'mi') * 60 +
to_char(CHECKPOINT_TIME, 'ss') CHECKPOINTSCN
from v$datafile t ;
FILE# TO_CHAR(CHECKPOINT_TIME,'YYYYMMDDHH24MISS') CHECKPOINTSCN
---------- --------------------------------------------- -------------
1 20211018 145338 1086274418
2 20211018 145338 1086274418
3 20211018 145338 1086274418
4 20211018 145338 1086274418
5 20211018 145338 1086274418
6 20211018 145338 1086274418
7 20211018 145504 1086274504
7 rows selected.
# 换算为16进制
select to_char(1086274504,'XXXXXXXX') from dual;
TO_CHAR(1086274504,'XXXXXXX
---------------------------
40BF3BC8
# 由于小编码存储,c83bbf40
BBED> d dba 7,1 offset 492
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 492 to 507 Dba:0x01c00001
------------------------------------------------------------------------
723bbf40 01000000 09000000 02000000
<32 bytes per line>
BBED> modify /x c83bbf40 dba 7,1 offset 492
BBED-00209: invalid number (c83bbf40)
BBED> modify /x c83b dba 7,1 offset 492
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 492 to 507 Dba:0x01c00001
------------------------------------------------------------------------
c83bbf40 01000000 09000000 02000000
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0xfe15, required = 0xfe15
修复ub4 kcvfhcpc 140
# ub4 kcvfhcpc存储数据文件发生checkpoint的次数
# 通过dump控制文件头获取 DATA FILE #7
alter session set events 'immediate trace name controlf level 8';
select value from v$diag_info where name = 'Default Trace File';
-------------------------------------------------------
/u01/app/oracle/diag/rdbms/three/three/trace/three_ora_9569.trc
vi /u01/app/oracle/diag/rdbms/three/three/trace/three_ora_9569.trc
DATA FILE #7:
name #12: /oradata/three/testdd01.dbf
creation size=3840 block size=8192 status=0xe head=12 tail=12 dup=1
tablespace 8, index=8 krfil=7 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:2 scn: 0x0000.0039a3f0 10/18/2021 14:55:04
Stop scn: 0xffff.ffffffff 10/18/2021 14:55:04
Creation Checkpointed at scn: 0x0000.0039a3ef 10/18/2021 14:55:04
thread:1 rba:(0x9.a9.10)
# 获取到Checkpoint cnt:2
# 16进制也是2,由于小编码存储,实际存储为0200
BBED> d dba 7,1 offset 140
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 140 to 155 Dba:0x01c00001
------------------------------------------------------------------------
66020000 713bbf40 65020000 00000000
<32 bytes per line>
BBED> modify /x 0200 dba 7,1 offset 140
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 140 to 155 Dba:0x01c00001
------------------------------------------------------------------------
02000000 713bbf40 65020000 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0xfc71, required = 0xfc71
修复ub4 kcvfhccc
# ub4 kcvfhccc 控制文件记录的检查点次数,值为kcvfhcpc-1
# 获取到Checkpoint cnt:2 kcvfhccc为1
# 16进制也是1,由于小编码存储,实际存储为0100
BBED> d dba 7,1 offset 148
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 148 to 163 Dba:0x01c00001
------------------------------------------------------------------------
65020000 00000000 00000000 00000000
<32 bytes per line>
BBED> modify /x 0100 dba 7,1 offset 148
File: /oradata/three/testdd01.dbf (7)
Block: 1 Offsets: 140 to 155 Dba:0x01c00001
------------------------------------------------------------------------
01000000 713bbf40 65020000 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 1:
current = 0xfc72, required = 0xfc72
开启数据库
SQL> SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01122: database file 7 failed verification check
ORA-01110: data file 7: '/oradata/three/testdd01.dbf'
ORA-01207: file is more recent than control file - old control file
# 重建控制文件
SQL> STARTUP NOMOUNT
ORACLE instance started.
Total System Global Area 914440192 bytes
Fixed Size 2258600 bytes
Variable Size 297797976 bytes
Database Buffers 608174080 bytes
Redo Buffers 6209536 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "THREE" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1600
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oradata/three/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/oradata/three/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/oradata/three/redo03.log' SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/oradata/three/system01.dbf',
'/oradata/three/sysaux01.dbf',
'/oradata/three/undotbs01.dbf',
'/oradata/three/users01.dbf',
'/oradata/three/zsdba01.dbf',
'/oradata/three/zsdba02.dbf',
'/oradata/three/testdd01.dbf'
CHARACTER SET WE8MSWIN1252
;
Control file created.
SQL> SQL> RECOVER DATABASE
Media recovery complete.
SQL> ALTER DATABASE OPEN;
Database altered.
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/oradata/three/temp01.dbf' REUSE;
Tablespace altered.
SQL> ALTER TABLESPACE T_TEMP ADD TEMPFILE '/oradata/three/t_temp01.dbf' REUSE;
Tablespace altered.
作者:bicewow —— bicewow
出处:http://www.cnblogs.com/bicewow/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。