重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2229|回复: 0

[转帖] bbed修改数据文件头推进scn与其他数据文件相同

[复制链接]
发表于 2015-6-29 14:56:15 | 显示全部楼层 |阅读模式
[oracle@lxy001 center]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Dec 31 14:39:54 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 314572800 bytes
Fixed Size 2020416 bytes
Variable Size 176163776 bytes
Database Buffers 130023424 bytes
Redo Buffers 6365184 bytes
Database mounted.
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '/u02/oradata/center/myth.dbf'

数据库启动时报数据文件5需要介质恢复,但是归档日志被删除了,只能通过修改这个数据文件头的scn号与其他数据文件相同启动数据库。当然这个数据文件里数据不要了的话直接把这个数据文件offline启动数据库就可以了。

SQL> select file#,checkpoint_change#,name from v$datafile_header;


FILE# CHECKPOINT_CHANGE# NAME
---------- --------------------------------------------------------
1 187511 /u02/oradata/center/system01.dbf
2 187511 /u02/oradata/center/undo.dbf
3 187511 /u02/oradata/center/sysaux01.dbf
4 187511 /u02/oradata/center/test.dbf
5 179775 /u02/oradata/center/myth.dbf

查看数据文件头的scn号可以看出5号数据文件scn号落后于其他数据文件。

下面是使用bbed修改数据文件头进行恢复的步骤。
1、bbed安装配置。
9i、10g下可以直接编译
方法相同,如下:
[oracle]$cd $ORACLE_HOME/rdbms/lib
[oracle]$ make -f ins_rdbms.mk $ORACLE_HOME/rdbms/lib/bbed
11g中默认是不带bbed的,如果确实需要使用可以将10g中文件复制过来再编译
编译的方式相同。
需要复制的文件如下:
$ORA10g_HOME/rdbms/lib/ssbbded.o
$ORA10g_HOME/rdbms/lib/sbbdpt.o
$ORA10g_HOME/rdbms/mesg/bbedus.msb
$ORA10g_HOME/rdbms/mesg/bbedus.msg
$ORA10g_HOME/rdbms/mesg/bbedar.msb
无论什么版本,编译后将$ORACLE_HOME/rdbms/lib添加到环境变量PATH中之后再使用bbed就可以直接运行了
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
编译后bbed还需要配置两个文本文件之后才能使用
两个文件分别是参数文件和对应的数据文件列表
参数文件中需要至少给定三个参数,分别是块大小、文件列表对应文件以及运行模式
mode有两种选择,browse和edit
内容如下:
vi /home/oracle/p.par
blocksize=8192
listfile=filelist.txt
mode=edit

SQL> spool /home/oracle/filelist.txt --创建filelist 
SQL> select file_id||' '||file_name||' '||bytes from dba_data_files; --filelist格式

FILE_ID||''||FILE_NAME||''||BYTES
--------------------------------------------------------------------------------
1 /u02/oradata/center/system01.dbf 1048576000
2 /u02/oradata/center/undo.dbf 1048576000
3 /u02/oradata/center/sysaux01.dbf 1048576000
4 /u02/oradata/center/test.dbf 104857600
5 /u02/oradata/center/myth.dbf

配置完后就可以进去bbed了
[oracle@lxy001 archive]$ bbed parfile=/home/oracle/p.par
Password: ------------默认密码是blockedit

BBED> show all
FILE# 1
BLOCK# 1
OFFSET 0
DBA 0x00400001 (4194305 1,1)
FILENAME /u02/oradata/center/system01.dbf
BIFILE bifile.bbd
LISTFILE /home/oracle/filelist.txt
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No



2、用bbed查询myth数据文件结构信息

BBED> set dba 5,1 -------5号数据文件第一个块
DBA 0x01400001 (20971521 5,1)
BBED> map
File: /u02/oradata/center/myth.dbf (5)
Block: 1 Dba:0x01400001
------------------------------------------------------------
Data File Header
struct kcvfh, 676 bytes @0
ub4 tailchk @8188 

3、 Bbed查看kcvfh信息 主要看红色部分
BBED> p kcvfh
struct kcvfh, 676 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 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 0xee43
ub2 spare3_kcbh @18 0x0000
struct kcvfhhdr, 76 bytes @20
ub4 kccfhswv @20 0x00000000
ub4 kccfhcvn @24 0x0a200100
ub4 kccfhdbi @28 0x0016a916
text kccfhdbn[0] @32 C
text kccfhdbn[1] @33 E
text kccfhdbn[2] @34 N
text kccfhdbn[3] @35 T
text kccfhdbn[4] @36 E
text kccfhdbn[5] @37 R
text kccfhdbn[6] @38
text kccfhdbn[7] @39
ub4 kccfhcsq @40 0x000000a4
ub4 kccfhfsz @44 0x00003200
s_blkz kccfhbsz @48 0x00
ub2 kccfhfno @52 0x0005
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 0x00026e32
ub2 kscnwrp @104 0x0000
ub4 kcvfhcrt @108 0x33b6961f
ub4 kcvfhrlc @112 0x33b69316
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0x00000001
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, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x0002be3f --------数据文件头scn
ub2 kscnwrp @488 0x0000
ub4 kcvcptim @492 0x33b69ab8 --------数据文件头checkpoint_time的值
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x0000000a
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
ub4 kcvfhcpc @140 0x0000000b ----------文件头中检查点计数器(kcvfhcpc)的值
ub4 kcvfhrts @144 0x33b6a261
ub4 kcvfhccc @148 0x0000000a -----------数据文件头中控制文件备份的计数器(kcvfhccc)的值 比检查点计数器小1
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
word kcvfhtsn @332 5
ub2 kcvfhtln @336 0x0004
text kcvfhtnm[0] @338 M
text kcvfhtnm[1] @339 Y
text kcvfhtnm[2] @340 T
text kcvfhtnm[3] @341 H
text kcvfhtnm[4] @342
text kcvfhtnm[5] @343
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 0x00000005
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 0x00000000
struct kcvfhprs, 8 bytes @420
ub4 kscnbas @420 0x00000000
ub2 kscnwrp @424 0x0000
struct kcvfhprfs, 8 bytes @428
ub4 kscnbas @428 0x00000000
ub2 kscnwrp @432 0x0000
ub4 kcvfhtrt @444 0x00000000





3、用bbed查看其他正常数据文件头kcvfh信息



BBED> set dba 1,1
DBA 0x00400001 (4194305 1,1)


BBED> map
File: /u02/oradata/center/system01.dbf (1)
Block: 1 Dba:0x00400001
------------------------------------------------------------
Data File Header
struct kcvfh, 676 bytes @0
ub4 tailchk @8188

BBED> p kcvfh
struct kcvfh, 676 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 0x0446
ub2 spare3_kcbh @18 0x0000
struct kcvfhhdr, 76 bytes @20
ub4 kccfhswv @20 0x00000000
ub4 kccfhcvn @24 0x0a200100
ub4 kccfhdbi @28 0x0016a916
text kccfhdbn[0] @32 C
text kccfhdbn[1] @33 E
text kccfhdbn[2] @34 N
text kccfhdbn[3] @35 T
text kccfhdbn[4] @36 E
text kccfhdbn[5] @37 R
text kccfhdbn[6] @38
text kccfhdbn[7] @39
ub4 kccfhcsq @40 0x000000c9
ub4 kccfhfsz @44 0x0001f400
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 0x00400179
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x0000000a
ub2 kscnwrp @104 0x0000
ub4 kcvfhcrt @108 0x33b6936d
ub4 kcvfhrlc @112 0x33b69316
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0x00000001
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 0x2000 (NONE)
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x0002dc77
ub2 kscnwrp @488 0x0000
ub4 kcvcptim @492 0x33b9168b
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x00000014
ub4 kcrbabno @504 0x000029d1
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 0x0000001d
ub4 kcvfhrts @144 0x33b69ab7
ub4 kcvfhccc @148 0x0000001c
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
word 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 0x00000000
struct kcvfhprs, 8 bytes @420
ub4 kscnbas @420 0x00000000
ub2 kscnwrp @424 0x0000
struct kcvfhprfs, 8 bytes @428
ub4 kscnbas @428 0x00000000
ub2 kscnwrp @432 0x0000
ub4 kcvfhtrt @444 0x00000000


4、查看正常数据文件头(1号system01数据文件头)scn转码前的值
BBED> dump offset 484 count 4
File: /u02/oradata/center/system01.dbf (1)
Block: 1 Offsets: 484 to 487 Dba:0x00400001
------------------------------------------------------------------------
77dc0200 
< 32 bytes per line>

5、修改旧数据文件头(5号myth数据文件头)scn的值
BBED> m /x 77dc0200 offset 484
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u02/oradata/center/myth.dbf (5)
Block: 1 Offsets: 484 to 995 Dba:0x01400001
------------------------------------------------------------------------
77dc0200 00000000 b89ab633 01000000 0a000000 02000000 1000524c 02000000 
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 
0d000d00 0d000100 00000000 00000000 00000000 02004001 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>

6、查看正常数据文件头(1号system01数据文件头)chckpoint_time的值
BBED> dump offset 492 count 4
File: /u02/oradata/center/system01.dbf (1)
Block: 1 Offsets: 492 to 495 Dba:0x00400001
------------------------------------------------------------------------
8b16b933 
<32 bytes per line>

7、修改旧数据文件头(5号myth数据文件头)checkpoint_time的值
BBED> m /x 8b16b933 offset 492
BBED-00209: invalid number (8b16b933) ---------有时修改的时候会报错,分成两部分执行就可以了
BBED> dump offset 492 count 4
File: /u02/oradata/center/myth.dbf (5)
Block: 1 Offsets: 492 to 495 Dba:0x01400001
------------------------------------------------------------------------
b89ab633 
<32 bytes per line>
BBED> m /x 8b16 offset 492
File: /u02/oradata/center/myth.dbf (5)
Block: 1 Offsets: 492 to 495 Dba:0x01400001
------------------------------------------------------------------------
8b16b633 
< 32 bytes per line>
BBED> m /x b933 offset 494
File: /u02/oradata/center/myth.dbf (5)
Block: 1 Offsets: 494 to 497 Dba:0x01400001
------------------------------------------------------------------------
b9330100 
<32 bytes per line>
BBED> dump offset 492 count 4
File: /u02/oradata/center/myth.dbf (5)
Block: 1 Offsets: 492 to 495 Dba:0x01400001
------------------------------------------------------------------------
8b16b933 
<32 bytes per line>

8、查看正常数据文件头中检查点计数器(kcvfhcpc)的值
BBED> dump offset 140 count 4
File: /u02/oradata/center/system01.dbf (1)
Block: 1 Offsets: 140 to 143 Dba:0x00400001
------------------------------------------------------------------------
1d000000 
<32 bytes per line>



9、修改旧数据文件头中检查点计数器(kcvfhcpc)
BBED> m /x 1d000000 offset 140
File: /u02/oradata/center/myth.dbf (5)
Block: 1 Offsets: 140 to 143 Dba:0x01400001
------------------------------------------------------------------------
1d000000 
<32 bytes per line>

10、查看正常数据文件头中控制文件备份的计数器(kcvfhccc)的值
BBED> dump offset 148 count 4
File: /u02/oradata/center/system01.dbf (1)
Block: 1 Offsets: 148 to 151 Dba:0x00400001
------------------------------------------------------------------------
1c000000 
<32 bytes per line>

11、修改旧数据文件头中控制文件备份的计数器(kcvfhccc)的值


BBED> m /x 1c000000 offset 148
File: /u02/oradata/center/myth.dbf (5)
Block: 1 Offsets: 148 to 151 Dba:0x01400001
------------------------------------------------------------------------
1c000000 
<32 bytes per line>

12、重新生成sum
BBED> sum apply
Check value for File 5, Block 1:
current = 0x0037, required = 0x0037

13、查询各个数据文件头scn
SQL> select file#,checkpoint_change#,name from v$datafile_header;
FILE# CHECKPOINT_CHANGE# NAME
---------- --------------------------------------------------------
1 187511 /u02/oradata/center/system01.dbf
2 187511 /u02/oradata/center/undo.dbf
3 187511 /u02/oradata/center/sysaux01.dbf
4 187511 /u02/oradata/center/test.dbf
5 187511 /u02/oradata/center/myth.dbf
可以看到与其他数据文件scn已经相同

14、尝试启动数据库
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01122: database file 5 failed verification check
ORA-01110: data file 5: '/u02/oradata/center/myth.dbf'
ORA-01207: file is more recent than control file - old control file

15、查看控制文件中关于bbed数据文件的信息
SQL> alter session set events 'immediate trace name controlf level 8'; 
Session altered.

查看生成的日志文件中data file #5的信息
DATA FILE #5:
(name #12) /u02/oradata/center/myth.dbf
creation size=12800 block size=8192 status=0xe head=12 tail=12 dup=1
tablespace 5, index=6 krfil=5 prev_file=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:14 scn: 0x0000.0002dc77 12/31/2014 14:39:07
Stop scn: 0x0000.0002dc77 12/31/2014 14:39:07
Creation Checkpointed at scn: 0x0000.00026e32 12/29/2014 17:06:39
thread:1 rba:(0x1.bde3f.10)
enabled threads: 01000000 00000000 00000000 00000000 00000000 00000000

可以看出控制文件中记录的检查点计数器的值为14转换成16进制为0e,数据文件头中控制文件备份的计数器等于14-1=13换成16进制为0d。

16、修改旧数据文件头中检查点计数器(kcvfhcpc)为控制文件记录的值
BBED> m /x 0e000000 offset 140
File: /u02/oradata/center/myth.dbf (5)
Block: 1 Offsets: 140 to 143 Dba:0x01400001
------------------------------------------------------------------------
0e000000 
<32 bytes per line>

17、修改旧数据文件头中控制文件备份的计数器(kcvfhccc)的值
BBED> m /x 0d000000 offset 148
File: /u02/oradata/center/myth.dbf (5)
Block: 1 Offsets: 148 to 151 Dba:0x01400001
------------------------------------------------------------------------
0d000000 
<32 bytes per line>

18、重新生成sum
BBED> sum apply
Check value for File 5, Block 1:
current = 0x0035, required = 0x0035

19、尝试启动数据库
SQL> alter database open;
Database altered.
启动成功
20、查询5号数据文件中的数据
SQL> select count(*) from myth;
COUNT(*)
----------
9405

可以正常访问5号数据文件。

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2020-9-20 03:31 , Processed in 0.114424 second(s), 21 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表