使用BBED修复损坏的SYSTEM文件头
1.环境说明
OS:Centos7.9
DB:Oracle Database 12c Enterprise Edition Release 12.2.0.1.0
2.模拟数据库SYSTEM文件头损坏
[oracle@oracledb bbed]$ bbed password=blockedit listfile=/home/oracle/bbed/filelist.txt blocksize=8192 mode=edit
BBED> info
File# Name Size(blks)
----- ---- ----------
1 /u01/app/oracle/oradata/EVA/system01.dbf 112640
2 /u01/app/oracle/oradata/EVA/sysaux01.dbf 87040
3 /u01/app/oracle/oradata/EVA/undotbs01.dbf 131200
4 /u01/app/oracle/oradata/EVA/users01.dbf 640
5 /u01/app/oracle/oradata/EVA/tbs1.dbf 1280
--用5号文件10号块覆盖1号文件1号块
BBED> copy file 5 block 10 to file 1 block 1
File: /u01/app/oracle/oradata/EVA/system01.dbf (1)
Block: 1 Offsets: 0 to 511 Dba:0x00400001
------------------------------------------------------------------------
1ea20000 0a004001 683f0b00 00000104 ec010000 05000000 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
--模拟业务数据
SYS@EVA>conn scott/tiger
Connected.
SCOTT@EVA>create table t01(id number,name varchar2(10));
Table created.
SCOTT@EVA>insert into t01 values(1,'AAAAA');
1 row created.
SCOTT@EVA>insert into t01 values(2,'BBBBB');
1 row created.
SCOTT@EVA>insert into t01 values(3,'CCCCC');
1 row created.
SCOTT@EVA>COMMIT;
Commit complete.
SCOTT@EVA>alter system switch logfile;
System altered.
SCOTT@EVA>alter system switch logfile;
System altered.
--日志第三次切换时直接报错,数据库crash
SCOTT@EVA>alter system switch logfile;
ERROR:
ORA-03114: not connected to ORACLE
alter system switch logfile
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 28295
Session ID: 5 Serial number: 59586
--重新启动数据库,提示system01.dbf损坏
idle>startup
ORACLE instance started.
Total System Global Area 2516582400 bytes
Fixed Size 8623832 bytes
Variable Size 822085928 bytes
Database Buffers 1677721600 bytes
Redo Buffers 8151040 bytes
Database mounted.
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/u01/app/oracle/oradata/EVA/system01.dbf'
ORA-01210: data file header is media corrupt