04 bbed修复system文件头损坏
04 bbed修复system文件头损坏
1 启动数据库,查看trace,在mount到open,
SQL> startup mount; ORACLE instance started.Total System Global Area 784998400 bytes Fixed Size 2257352 bytes Variable Size 511708728 bytes Database Buffers 264241152 bytes Redo Buffers 6791168 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_11247.trc
查看文件,在启动的是,先检查各个数据文件的1号块
[oracle@DSI ~]$ more /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_11247.trc WAIT #139760412634104: nam='control file sequential read' ela= 2 file#=0 block#=23 blocks=1 obj#=-1 tim=1557884751568850 WAIT #139760412634104: nam='db file sequential read' ela= 3 file#=1 block#=1 blocks=1 obj#=-1 tim=1557884751568874 ##数据文件1的1号块 WAIT #139760412634104: nam='db file sequential read' ela= 1 file#=2 block#=1 blocks=1 obj#=-1 tim=1557884751568894 WAIT #139760412634104: nam='db file sequential read' ela= 2 file#=3 block#=1 blocks=1 obj#=-1 tim=1557884751568911 WAIT #139760412634104: nam='db file sequential read' ela= 1 file#=4 block#=1 blocks=1 obj#=-1 tim=1557884751568922 WAIT #139760412634104: nam='db file sequential read' ela= 1 file#=5 block#=1 blocks=1 obj#=-1 tim=1557884751568929
2 system数据文件1号块损坏修复
测试之前先做冷备,防止修复不成功
[oracle@DSI oradata]$ cp -rf orcl/ /home/oracle/. BBED> infoFile# Name Size(blks)----- ---- ----------1 /u01/app/oracle/oradata/orcl/system01.dbf 947202 /u01/app/oracle/oradata/orcl/sysaux01.dbf 768003 /u01/app/oracle/oradata/orcl/undotbs01.dbf 1446404 /u01/app/oracle/oradata/orcl/users01.dbf 6405 /u01/app/oracle/oradata/orcl/test01.dbf 6400 BBED> set file 1 block 1FILE# 1BLOCK# 1 BBED> map /vFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Dba:0x00400001 ------------------------------------------------------------Data File Headerstruct 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> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 0 to 511 Dba:0x00400001 ------------------------------------------------------------------------0ba20000 01004000 00000000 00000104 9bec0000 00000000 0004200b cf766f5b 4f52434c 00000000 c0170000 00770100 00200000 01000300 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 08024000 07000000 00000000 512bfa3b 4f2bfa3b 01000000 00000000 00000000 00000000 00000000 00000420 8c000000 b993173c 8b000000 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 06005359 5354454d 00000000 00000000 00000000 00000000 00000000 00000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0a000a00 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 21fd1700 00000000 3e171a3c 01000000 75000000 1e7b0000 10000000 <32 bytes per line>
View Code
模拟损坏,用4号文件的10号块覆盖1号文件1号块
BBED> copy file 4 block 10 to file 1 block 1 Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) yFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 0 to 511 Dba:0x00400001 ------------------------------------------------------------------------1ea20000 0a000001 553e0000 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
#正常关闭不了数据库,直接abort
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> shutdown abort ORACLE instance shut down. SQL> startup ORACLE instance started. Total System Global Area 784998400 bytes Fixed Size 2257352 bytes Variable Size 511708728 bytes Database Buffers 264241152 bytes Redo Buffers 6791168 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
#只能启动到mount阶段,提示需要介质恢复
BBED> set file 1 block 1FILE# 1BLOCK# 1 BBED> map /vFile: /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 1FILE# 2BLOCK# 1 BBED> map /vFile: /u01/app/oracle/oradata/orcl/sysaux01.dbf (2)Block: 1 Dba:0x00800001 ------------------------------------------------------------Data File Header BBED> copy file 2 block 1 to file 1 block 1File: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 0 to 511 Dba:0x00400001 ------------------------------------------------------------------------0ba20000 01008000 00000000 00000104 c4d80000 00000000 0004200b cf766f5b 4f52434c 00000000 c0170000 003b0100 00200000 02000300 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 07070000 00000000 522bfa3b 4f2bfa3b 01000000 00000000 00000000 00000000 00000000 00000400 8c000000 b993173c 8b000000 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 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 21fd1700 00000000 3e171a3c 01000000 75000000 1e7b0000 10000000 <32 bytes per line>BBED> sum apply Check value for File 1, Block 1: current = 0xd8c4, required = 0xd8c4 查看文件头的结构 BBED> set file 1 block 1FILE# 1BLOCK# 1 BBED> map /vFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Dba:0x00400001 ------------------------------------------------------------Data File Header
BBED修复文件头
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
1 BBED修复文件头block的rdba地址
BBED> p kcvfhbfh struct kcvfhbfh, 20 bytes @0 ub4 rdba_kcbh @4 0x00800001 rdba地址转换 SQL> select dbms_utility.data_block_address_file(TO_NUMBER('800001','XXXXXXXX')) file_id,dbms_utility.data_block_address_block(TO_NUMBER('800001','XXXXXXXX')) block_id from dual; 32个字节,前10个bit文件号,后22个bit块号 0000 0000 1000 >>0000 0000 10 得出是2号文件,现在要修改为1号文件0000 0000 0100>>0x00400001 转换成十六进制 BBED修复文件头block的rdba地址 ( Cont … ) BBED> set file 1 block 1 offset 4 count 32FILE# 1BLOCK# 1OFFSET 4COUNT 32 BBED> dump ##查看值File: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 4 to 35 Dba:0x00400001 ------------------------------------------------------------------------01008000 00000000 00000104 c4d80000 00000000 0004200b cf766f5b 4f52434c <32 bytes per line> BBED> modify /x 01004000 offset 4 ##修改File: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 4 to 35 Dba:0x00400001 ------------------------------------------------------------------------01004000 00000000 00000104 c4d80000 00000000 0004200b cf766f5b 4f52434c <32 bytes per line> BBED> sum apply ##提交 Check value for File 1, Block 1: current = 0xd804, required = 0xd804 BBED> dump ##再次查看,已经修改为01004000File: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 4 to 35 Dba:0x00400001 ------------------------------------------------------------------------01004000 00000000 00000104 04d80000 00000000 0004200b cf766f5b 4f52434c <32 bytes per line>
2 BBED修复文件头的文件大小
BBED> p kcvfhhdrub4 kccfhfsz @44 0x00013b00 从系统层面查看system数据文件的大小 [oracle@DSI orcl]$ ll -l |grep system* -rw-r----- 1 oracle oinstall 786440192 May 15 15:32 system01.dbf 计算大小 SQL> select (786440192-8192)/8192 from dual; ##-8192是减去os层面的0号块 (786440192-8192)/8192 ---------------------96000 SQL> select to_char(96000,'xxxxxxxxxxxxxxx') from dual;TO_CHAR(96000,'X ----------------17700 BBED> set file 1 block 1 offset 44 count 32FILE# 1BLOCK# 1OFFSET 44COUNT 32 BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 44 to 75 Dba:0x00400001 ------------------------------------------------------------------------003b0100 00200000 02000300 00000000 00000000 00000000 00000000 00000000 <32 bytes per line> BBED> modify /x 00770100 ##需要把17700反一下,先补全00017700,然后在反File: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 44 to 75 Dba:0x00400001 ------------------------------------------------------------------------00770100 00200000 02000300 00000000 00000000 00000000 00000000 00000000 <32 bytes per line> BBED> sum apply Check value for File 1, Block 1: current = 0x9404, required = 0x9404 BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 44 to 75 Dba:0x00400001 ------------------------------------------------------------------------00770100 00200000 02000300 00000000 00000000 00000000 00000000 00000000 <32 bytes per line>
3 BBED修复文件头的文件号
BBED> p kcvfhhdrub2 kccfhfno @52 0x0002 BBED> set file 1 block 1 offset 52 count 32FILE# 1BLOCK# 1OFFSET 52COUNT 32 BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 52 to 83 Dba:0x00400001 ------------------------------------------------------------------------02000300 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <32 bytes per line> BBED> modify /x 01 offset 52File: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 52 to 83 Dba:0x00400001 ------------------------------------------------------------------------01000300 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <32 bytes per line> BBED> sum apply Check value for File 1, Block 1: current = 0x9407, required = 0x9407 BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 52 to 83 Dba:0x00400001 ------------------------------------------------------------------------01000300 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <32 bytes per line>
4 BBED修复文件头的root数据块号
SQL> select fhrdb,FHFNO from x$kcvfh order by 2;FHRDB FHFNO ---------- ----------4194824 1 SQL> select to_char(4194824,'xxxxxxxxxx') from dual;TO_CHAR(419 -----------400208 SQL> select dbms_utility.data_block_address_file(TO_NUMBER('400208', 'XXXXXXXX')) file_id,dbms_utility.data_block_address_block(TO_NUMBER('400208', 'XXXXXXXX')) block_id from dual; FILE_ID BLOCK_ID ---------- ---------- 1 520 =>1号文件520号块 SQL> select to_char(520,'xxxxxxxxxxxxxxxxxxx') from dual;TO_CHAR(520,'XXXXXXX --------------------208 =>00400208 BBED> p kcvfhrdb ub4 kcvfhrdb @96 0x00000000BBED> set file 1 block 1 offset 96 count 32FILE# 1BLOCK# 1OFFSET 96COUNT 32 BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 96 to 127 Dba:0x00400001 ------------------------------------------------------------------------00000000 07070000 00000000 522bfa3b 4f2bfa3b 01000000 00000000 00000000 <32 bytes per line> BBED> modify /x 08024000 ##同样这里也取反File: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 96 to 127 Dba:0x00400001 ------------------------------------------------------------------------08024000 07070000 00000000 522bfa3b 4f2bfa3b 01000000 00000000 00000000 <32 bytes per line> BBED> sum apply Check value for File 1, Block 1: current = 0x964f, required = 0x964f BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 96 to 127 Dba:0x00400001 ------------------------------------------------------------------------08024000 07070000 00000000 522bfa3b 4f2bfa3b 01000000 00000000 00000000 <32 bytes per line>
5 BBED修复文件头的文件创建SCN
BBED> p kcvfhcrs struct kcvfhcrs, 8 bytes @100 ub4 kscnbas @100 0x00000707ub2 kscnwrp @104 0x0000 SQL> select file#,creation_change# from v$datafile; 1 7 2 1799 3 2821 4 15940 5 929531 SQL> select to_char(1799,'xxxxxxxxxxxx') from dual; TO_CHAR(1799, -------------707 BBED> set file 1 block 1 offset 100 count 32FILE# 1BLOCK# 1OFFSET 100COUNT 32 BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 100 to 131 Dba:0x00400001 ------------------------------------------------------------------------07070000 00000000 522bfa3b 4f2bfa3b 01000000 00000000 00000000 00000000 <32 bytes per line> BBED> modify /x 07000000 offset 100 ###由于这里是用的2号文件的1号块覆盖的,所以这里的值是2号文件的707,要修改为7File: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 100 to 131 Dba:0x00400001 ------------------------------------------------------------------------07000000 00000000 522bfa3b 4f2bfa3b 01000000 00000000 00000000 00000000 <32 bytes per line> BBED> sum apply Check value for File 1, Block 1: current = 0x914f, required = 0x914f
6 BBED修复文件头的文件创建时间
BBED> p kcvfhcrt ub4 kcvfhcrt @108 0x3bfa2b52BBED> set file 1 block 1 offset 108 count 32FILE# 1BLOCK# 1OFFSET 108COUNT 32BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 108 to 139 Dba:0x00400001 ------------------------------------------------------------------------522bfa3b 4f2bfa3b 01000000 00000000 00000000 00000000 00000000 00000400 <32 bytes per line> SQL> select file#,to_char(creation_time,'yyyy-mm-dd hh24:mi:ss') creation_time_file, (to_char(creation_time,'yyyy')-1988)*12*31*24*3600+ (to_char(creation_time,'mm')-1)*31*24*3600 +(to_char(creation_time,'dd')-1)*24*3600 +to_char(creation_time,'hh24')*3600 +to_ 2 3 4 5 6 char(creation_time,'mi')*60 +to_char(creation_time,'ss') creation_name_scn from v$datafile order by 1; 7 8 FILE# CREATION_TIME_FILE CREATION_NAME_SCN ---------- ------------------- -----------------1 2019-04-22 10:07:13 10062508332 2019-04-22 10:07:14 10062508343 2019-04-22 10:07:15 10062508354 2019-04-22 10:07:20 10062508405 2019-04-22 17:12:12 1006276332 SQL> select to_char(1006250833,'xxxxxxxxxxxx') from dual; TO_CHAR(10062 -------------3bfa2b51 BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 108 to 139 Dba:0x00400001 ------------------------------------------------------------------------522bfa3b 4f2bfa3b 01000000 00000000 00000000 00000000 00000000 00000400 <32 bytes per line> BBED> modify /x 512bfa3b offset 108 ##取反,如果这里报错无效的number,则分开修改 108,109,110,111File: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 108 to 139 Dba:0x00400001 ------------------------------------------------------------------------512bfa3b 4f2bfa3b 01000000 00000000 00000000 00000000 00000000 00000400 <32 bytes per line>BBED> sum apply Check value for File 1, Block 1: current = 0x914c, required = 0x914c
7 BBED修复文件头的文件状态
BBED> p offset 138 kcvfh.kcvfhsta -------------- ub2 kcvfhsta @138 0x0004 (KCVFHOFZ)BBED> set file 1 block 1 offset 138 count 32FILE# 1BLOCK# 1OFFSET 138COUNT 32BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 138 to 169 Dba:0x00400001 ------------------------------------------------------------------------04008c00 0000b993 173c8b00 00000000 00000000 00000000 00000000 00000000 <32 bytes per line> #当一个datafile处于fuzzy状态的时候,其kcvfhsta为0x04,这里是abort关闭,状态时04,不修改,如果是正常关闭,则是0x2000
8 BBED修复文件头的表空间号
BBED> p kcvfhtsn sword kcvfhtsn @332 1BBED> set file 1 block 1 offset 332 count 32FILE# 1BLOCK# 1OFFSET 332COUNT 32 BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 332 to 363 Dba:0x00400001 ------------------------------------------------------------------------01000000 06005359 53415558 00000000 00000000 00000000 00000000 00000000 <32 bytes per line> SQL> select file#,ts# from v$datafile; FILE# TS# ---------- ----------1 02 13 24 45 5 BBED> modify /x 00 offset 332 ##这里是system数据文件,ts为0File: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 332 to 363 Dba:0x00400001 ------------------------------------------------------------------------00000000 06005359 53415558 00000000 00000000 00000000 00000000 00000000 <32 bytes per line>BBED> sum apply Check value for File 1, Block 1: current = 0x914d, required = 0x914d
9 BBED修复文件头的表空间长度
BBED> p kcvfhtln ub2 kcvfhtln @336 0x0006BBED> 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 SYSTEM表空间长度一致
10 BBED修复文件头的表空间名称
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 修改为SYSTEM BBED> set file 1 block 1 offset 338 count 32FILE# 1BLOCK# 1OFFSET 338COUNT 32BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 338 to 369 Dba:0x00400001 ------------------------------------------------------------------------53595341 55580000 00000000 00000000 00000000 00000000 00000000 00000200 <32 bytes per line> SQL> select dump('SYSTEM',16) from dual;DUMP('SYSTEM',16) ------------------------------- Typ=96 Len=6: 53,59,53,54,45,4d BBED> set file 1 block 1 offset 341 ##直接从341偏移量开始修改,前面SYS都一样FILE# 1BLOCK# 1OFFSET 341BBED> modify /x 54454dFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 341 to 372 Dba:0x00400001 ------------------------------------------------------------------------54454d00 00000000 00000000 00000000 00000000 00000000 00000002 00000000 <32 bytes per line>BBED> sum apply Check value for File 1, Block 1: current = 0x915d, required = 0x915d
11 BBED修复文件头的相对文件号
BBED> p kcvfhrfn ub4 kcvfhrfn @368 0x00000002BBED> set file 1 block 1 offset 368FILE# 1BLOCK# 1OFFSET 368BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 368 to 399 Dba:0x00400001 ------------------------------------------------------------------------02000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <32 bytes per line> SQL> select file#,rfile# from v$datafile; FILE# RFILE# ---------- ----------1 12 23 34 45 5 BBED> modify /x 01 offset 368 #修改为对于的 RFILEFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 368 to 399 Dba:0x00400001 ------------------------------------------------------------------------01000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <32 bytes per line>BBED> sum apply Check value for File 1, Block 1: current = 0x915e, required = 0x915e
12 BBED修复文件头的检查点SCN
BBED> p kcvfhckp struct kcvfhckp, 36 bytes @484 struct kcvcpscn, 8 bytes @484 ub4 kscnbas @484 0x0017fd21ub2 kscnwrp @488 0x0000ub4 kcvcptim @492 0x3c1a173e SQL> set pagesize 999 SQL> set linesize 999 SQL> select file#,CREATION_CHANGE#,CHECKPOINT_CHANGE# ,UNRECOVERABLE_CHANGE#,LAST_CHANGE#,OFFLINE_CHANGE# from v$datafile order by 1; FILE# CREATION_CHANGE# CHECKPOINT_CHANGE# UNRECOVERABLE_CHANGE# LAST_CHANGE# OFFLINE_CHANGE# ---------- ---------------- ------------------ --------------------- ------------ ---------------1 7 1572129 0 02 1799 1572129 0 03 2821 1572129 0 04 15940 1572129 0 05 929531 1572129 0 0 SQL> select to_char(1572129,'xxxxxxxxxxxxxxxx') from dual;TO_CHAR(1572129,' -----------------17fd21 这里的值跟 ub4 kscnbas @484 0x0017fd21是一样的,不用修改
13 BBED修复文件头的检查点时间
BBED> set file 1 block 1 offset 492FILE# 1BLOCK# 1OFFSET 492BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 1 Offsets: 492 to 523 Dba:0x00400001 ------------------------------------------------------------------------3e171a3c 01000000 75000000 1e7b0000 10000000 02000000 00000000 00000000 <32 bytes per line> select file#,to_char(CHECKPOINT_TIME,'yyyy-mm-dd hh24:mi:ss') CHECKPOINT_TIME_file, (to_char(CHECKPOINT_TIME,'yyyy')-1988)*12*31*24*3600 +(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 order by 1; SQL> select file#,to_char(CHECKPOINT_TIME,'yyyy-mm-dd hh24:mi:ss') CHECKPOINT_TIME_file, (to_char(CHECKPOINT_TIME,'yyyy')-1988)*12*31*24*3600 +(to_char(CHECKPOINT_TIME,'mm')-1)*31*24*3600 +(to_char(CHECKPOINT_TIME,'dd')-1)*24*3600 +to_char(CHECKPOINT_TIME,'hh24 2 3 4 5 6 ')*3600 +to_char(CHECKPOINT_TIME,'mi')*60 +to_char(CHECKPOINT_TIME,'ss') CHECKPOINT_TIME_scn from v$datafile order by 1; 7 8 9 FILE# CHECKPOINT_TIME_FIL CHECKPOINT_TIME_SCN ---------- ------------------- -------------------1 2019-05-15 15:14:06 10083428462 2019-05-15 15:14:06 10083428463 2019-05-15 15:14:06 10083428464 2019-05-15 15:14:06 10083428465 2019-05-15 15:14:06 1008342846 SQL> select to_char(1008342846,'xxxxxxxxxxxxxxxxxxxxxxx') from dual;TO_CHAR(1008342846,'XXXX ------------------------3c1a173e这里的值与ub4 kcvcptim @492 0x3c1a173e一样,不用修改
通过dbv检查下文件头修改是否都正确
[oracle@DSI ~]$ dbv file=/u01/app/oracle/oradata/orcl/system01.dbf start=1 end=2 DBVERIFY: Release 11.2.0.4.0 - Production on Wed May 15 16:48:53 2019 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 completeTotal 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 : 1352932 (0.1352932) SQL> alter database open; Database altered.
这里成功打开数据库
如果打开数据库报错,根据提示再检查修改相应的块内容
如果是提示控制文件太旧
方法一:修改checkpoint count
kcvfhcpc (offset 144) Datafile checkpoint count
kcvfhccc (offset 148) Controlfile Checkpoint Count
kcvfhcpc>kcvfhccc+1 一般是这样
方法二:手工创建control file
测试题目:
1.模拟2号文件头损坏恢复的实验(详细操作步骤)
--这里2号文件跟1号文件类似,不用修改4. kcvfhrdb (offset 96) root dba
2.Oracle 11g 没有备份的情况下,1号文件520号块坏了,还能恢复吗?
如果不能恢复请给出原因?如果能恢复请给出方法和思路?
不能简单的从其他块进行覆盖修改,这里没有其他的文件快可以替换,结构都不一样,不清楚这个520号块的作用,是否可以从其他实例cp这520号块
查看本地其他数据文件的520号块
BBED> set file 1 block 1FILE# 1BLOCK# 1 BBED> p offset 520 pad --- ub1 pad @520 0x00BBED> set file 1 block 520FILE# 1BLOCK# 520 BBED> map /vFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 520 Dba:0x00400208 ------------------------------------------------------------Unlimited Data Segment Headerstruct kcbh, 20 bytes @0 ub1 type_kcbh @0 ub1 frmt_kcbh @1 ub1 spare1_kcbh @2 ub1 spare2_kcbh @3 ub4 rdba_kcbh @4 ub4 bas_kcbh @8 ub2 wrp_kcbh @12 ub1 seq_kcbh @14 ub1 flg_kcbh @15 ub2 chkval_kcbh @16 ub2 spare3_kcbh @18 struct ktech, 72 bytes @20 ub4 spare1_ktech @20 sword tsn_ktech @24 ub4 lastmap_ktech @28 ub4 mapcount_ktech @32 ub4 extents_ktech @36 ub4 blocks_ktech @40 ub2 mapend_ktech @44 struct hwmark_ktech, 32 bytes @48 struct locker_ktech, 8 bytes @80 ub4 flag_ktech @88 struct ktemh, 16 bytes @92 ub4 count_ktemh @92 ub4 next_ktemh @96 ub4 obj_ktemh @100 ub4 flag_ktemh @104 struct ktetb[1], 8 bytes @108 ub4 ktetbdba @108 ub4 ktetbnbk @112 struct ktshc, 8 bytes @4148 ub2 ktshcnxf @4148 ub2 ktshcnfl @4150 ub2 ktshcnfb @4152 ub1 ktshctyp @4154 struct ktsfs_seg[1], 20 bytes @4156 ub2 ktsfsflg @4156 struct ktsfsxid, 8 bytes @4160 ub4 ktsfslhd @4168 ub4 ktsfsltl @4172 struct ktsfs_txn[16], 320 bytes @4176 ub2 ktsfsflg @4176 struct ktsfsxid, 8 bytes @4180 ub4 ktsfslhd @4188 ub4 ktsfsltl @4192 ub4 tailchk @8188 BBED> dumpFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 520 Offsets: 0 to 511 Dba:0x00400208 ------------------------------------------------------------------------10a20000 08024000 b9010000 00000204 43e40000 00000000 00000000 00000000 00000000 01000000 07000000 20100000 00000000 03000000 07000000 0c024000 00000000 00000000 01000000 03000000 00000000 00000000 00000000 01000000 00000000 3b000000 00000040 09024000 07000000 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> set file 2 block 520FILE# 2BLOCK# 520 BBED> map /vFile: /u01/app/oracle/oradata/orcl/sysaux01.dbf (2)Block: 520 Dba:0x00800208 ------------------------------------------------------------ BBED-00400: invalid blocktype (32)BBED> p offset 520 BBED-00400: invalid blocktype (32)BBED> set file 3 block 520FILE# 3BLOCK# 520 BBED> p offset 520 freespace[478] -------------- ub1 freespace[478] @520 0x00BBED> map /vFile: /u01/app/oracle/oradata/orcl/undotbs01.dbf (3)Block: 520 Dba:0x00c00208 ------------------------------------------------------------Undo Datastruct kcbh, 20 bytes @0 ub1 type_kcbh @0 ub1 frmt_kcbh @1 ub1 spare1_kcbh @2 ub1 spare2_kcbh @3 ub4 rdba_kcbh @4 ub4 bas_kcbh @8 ub2 wrp_kcbh @12 ub1 seq_kcbh @14 ub1 flg_kcbh @15 ub2 chkval_kcbh @16 ub2 spare3_kcbh @18 struct ktubh, 22 bytes @20 struct ktubhxid, 8 bytes @20 ub2 ktubhseq @28 ub1 ktubhcnt @30 ub1 ktubhirb @31 ub1 ktubhicl @32 ub1 ktubhflg @33 ub2 ktubhidx[4] @34 ub1 freespace[7806] @42 ub1 undodata[340] @7848 ub4 tailchk @8188
View Code
查看并修改1号文件520号块
SQL> select distinct dbms_rowid.rowid_relative_fno(rowid) file#, dbms_rowid.rowid_block_number(rowid) block# from bootstrap$; 2 3 FILE# BLOCK# ---------- ----------1 5211 5231 522 查看并修改1号文件520号块 BBED> infoFile# Name Size(blks)----- ---- ----------1 /u01/app/oracle/oradata/orcl/system01.dbf 947202 /u01/app/oracle/oradata/orcl/sysaux01.dbf 768003 /u01/app/oracle/oradata/orcl/undotbs01.dbf 1446404 /u01/app/oracle/oradata/orcl/users01.dbf 6405 /u01/app/oracle/oradata/orcl/test01.dbf 6400 这里从别处cp一个system01数据文件过来,由于这个是单实例,我从一个rac集群拷贝一个system过来试试 ASMCMD> cp SYSTEM.259.1001364555 /tmp/. copying +data/bol/datafile/SYSTEM.259.1001364555 -> /tmp/./SYSTEM.259.1001364555 [grid@rac03 tmp]$ scp SYSTEM.259.1001364555 oracle@10.15.7.25:/tmp/. [oracle@DSI ~]$ vim filelist.txt [oracle@DSI ~]$ bbed BBED> infoFile# Name Size(blks)----- ---- ----------1 /u01/app/oracle/oradata/orcl/system01.dbf 947202 /u01/app/oracle/oradata/orcl/sysaux01.dbf 768003 /u01/app/oracle/oradata/orcl/undotbs01.dbf 1446404 /u01/app/oracle/oradata/orcl/users01.dbf 6405 /u01/app/oracle/oradata/orcl/test01.dbf 64006 /u01/app/oracle/oradata/orcl/SYSTEM.259.1001364555 0BBED> copy file 6 block 520 to file 1 block 520 Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) yFile: /u01/app/oracle/oradata/orcl/system01.dbf (1)Block: 520 Offsets: 0 to 511 Dba:0x00400208 ------------------------------------------------------------------------10a20000 08024000 d0010000 00000204 43e40000 00000000 00000000 00000000 00000000 01000000 07000000 20100000 00000000 03000000 07000000 0c024000 00000000 00000000 01000000 03000000 00000000 00000000 00000000 01000000 00000000 3b000000 00000040 09024000 07000000 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 520: current = 0xe443, required = 0xe443 启动成功 SQL> startup ORACLE instance started.Total System Global Area 784998400 bytes Fixed Size 2257352 bytes Variable Size 511708728 bytes Database Buffers 264241152 bytes Redo Buffers 6791168 bytes Database mounted. Database opened.
View Code
3.以下SQL中的1988是怎么得来的?
select file#,to_char(creation_time,'yyyy-mm-dd hh24:mi:ss') creation_time_file,
(to_char(creation_time,'yyyy')-1988)*12*31*24*3600+
(to_char(creation_time,'mm')-1)*31*24*3600
+(to_char(creation_time,'dd')-1)*24*3600
+to_char(creation_time,'hh24')*3600
+to_ 2 3 4 5 6 char(creation_time,'mi')*60
+to_char(creation_time,'ss') creation_name_scn
from v$datafile order by 1;
--数据库记录时间起点
1988/01/01 00:00:00
转载于:https://www.cnblogs.com/yhq1314/p/10870998.html
04 bbed修复system文件头损坏相关推荐
- 分享:bbed修改数据文件头推进scn与其他数据文件相同
2019独角兽企业重金招聘Python工程师标准>>> 场景简介: 物理copy表空间数据文件,数据库发生完全检查点,删除该表空间下的数据文件,使该表空间数据文件头的scn与其他数据 ...
- 修改oracle的表空间文件scn,分享:bbed修改数据文件头推进scn与其他数据文件相同...
场景简介: 物理copy表空间数据文件,数据库发生完全检查点,删除该表空间下的数据文件,使该表空间数据文件头的scn与其他数据文件不一致. 场景构造: 1.创建测试表空间 SYS@orser> ...
- 使用BBED恢复数据文件头
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/31018075 @@@@@@@利用BBED模拟损坏5文件1号块(文件头) BBED> ...
- wav文件头损坏_Dex文件结构学习
本文为看雪论坛优秀文章看雪论坛作者ID:iio 目 录 一.DexHeader 1. 理解DexHeader 2. 解析DexHeader 二.DexStringId 1. 理解DexStringId ...
- ctf wav文件头损坏_【CTF入门第二篇】南邮CTF web题目总结
这几天写了南邮的web题目,都比较基础,但是对我这个小白来说还是收获蛮大的.可以借此总结一下web题的类型 一,信息都藏在哪 作为ctf题目,肯定是要有些提示的,这些提示有时会在题目介绍里说有时也会隐 ...
- 常见的文件头识别和修复
常见的文件头识别和修复 文件头是位于文件开头的一段承担一定任务的数据 以下是常见的文件头: 相应的还有文件结尾 zip文件的结尾以一串504B0506开始 rar文件以C43D7B00400700结尾 ...
- oracle恢复指定数据文件,Oracle特殊恢复-BBED修改某个数据文件头
Oracle数据文件头中的scn要与控制文件中的scn一致,数据库才可以open,在open过程中我们可以通过bbed来修改某个数据文件头的scn,来欺骗oracle,来open库. 1.环境如下 使 ...
- Microsoft Word文档损坏,如何快速修复?一招解决文档修复
遇见过☞文件无法打开,或☞文件打开乱码等情况的伙伴们看过来,从事数据恢复行业20余年的"技术宅"效哥,直接给大家上权威恢复方法啦~ 方法一:通过手动重建文件头,修复损坏的Micro ...
- 文件头_常见文件文件头
在日常生活中我们接触到很多软件,如QQ和微信等,这些软件都会对一些文件加密如图片加密成dat文件,这其中多数是利用文件的16进制编码进行异或运算进行加密.此处我们具体介绍一些常见的文件未进行加密前的文 ...
最新文章
- 以金山界面库(openkui)为例思考和分析界面库的设计和实现——问题
- python搭建可视化管理平台_搭建可视化数据平台 superset
- Gamma阶段测试报告
- java相同数组拼接_java遍历数组并重新拼接数组里的元素
- python的日期格式化_Python日期格式化-阿里云开发者社区
- 验证多个Filter过滤一个资源时执行顺序
- vue 刷新echarts_在vue.js中使用echarts,数据动态刷新
- mysql+安全性语言实验,实验四--数据库的安全性、完整性控制
- 使用Websocket框架之GatewayWorker开发电商平台买家与卖家实时通讯
- 为什么构造函数不能声明为虚函数?
- 大话数据结构PDF原文内容分享
- CSA发布云控制矩阵3.0版
- 胃病患者饮食结构注意事项
- ArrayList集合的使用
- 案例:自动复制黏贴bat
- vue中provide和inject 用法
- 深度学习之语义分割unet算法解读
- 5G?折叠屏?华为新款手机刷屏了!
- python遍历是什么意思_在Python中遍历列表的方法有哪些
- Unsupervised Domain Adaptation for Semantic Segmentation by Content Transfer