环境
-
SQL> select * from v$version;
-
-
BANNER
-
-------------------------------------------------------------------------
-
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
-
PL/SQL Release 11.2.0.1.0 - Production
-
CORE 11.2.0.1.0 Production
-
TNS for Linux: Version 11.2.0.1.0 - Production
-
NLSRTL Version 11.2.0.1.0 - Production
当前bbed配置
-
[oracle@kvm61 ~]$ cat /home/oracle/bbed.conf
-
1 /oracle/oradata/sdk/system01.dbf 723517440
-
2 /oracle/oradata/sdk/sysaux01.dbf 639631360
-
3 /oracle/oradata/sdk/undotbs01.dbf 204472320
-
4 /oracle/oradata/sdk/users01.dbf 595066880
-
5 /oracle/oradata/sdk/example01.dbf 108134400
-
6 /oracle/scripts/sql/TBS_A.DBF 25165824
下面破坏一个数据块,找一个表,找到这边表对应的数据块位置:
例如scott.dept表
-
SQL> set linesize 150
-
SQL> set pagesize 100
-
SQL> select rowid,
-
2 dbms_rowid.rowid_type(rowid) rowid_type,
-
3 dbms_rowid.rowid_object(rowid) data_object_id,
-
4 dbms_rowid.rowid_relative_fno(rowid) relative_file_number,
-
5 dbms_rowid.rowid_block_number(rowid) block_number,
-
6 dbms_rowid.rowid_row_number(rowid) row_number
-
7 from scott.dept;
-
-
ROWID ROWID_TYPE DATA_OBJECT_ID RELATIVE_FILE_NUMBER BLOCK_NUMBER ROW_NUMBER
-
------------------ ---------- -------------- -------------------- ----------------
-
AAAR3vAAEAAAACHAAA 1 73199 4 135 0
-
AAAR3vAAEAAAACHAAB 1 73199 4 135 1
-
AAAR3vAAEAAAACHAAC 1 73199 4 135 2
-
AAAR3vAAEAAAACHAAD 1 73199 4 135 3
dept表一共4行,位于第4号文件第135个数据块
-
SQL> select * from scott.dept;
-
-
DEPTNO DNAME LOC
-
---------- ---------------------------- --------------------------
-
10 ACCOUNTING NEW YORK
-
20 RESEARCH DALLAS
-
30 SALES CHICAGO
-
40 OPERATIONS BOSTON
-
-
-
SQL> shutdown immediate
-
数据库已经关闭。
-
已经卸载数据库。
-
ORACLE 例程已经关闭
对4号文件user表空间做离线备份
[oracle@kvm61 sdk]$ cp users01.dbf users01.dbf.2
[oracle@kvm61 sdk]$ pwd
/oracle/oradata/sdk
启动数据库
-
SQL> startup
-
ORACLE 例程已经启动。
-
-
Total System Global Area 513585152 bytes
-
Fixed Size 2214856 bytes
-
Variable Size 276825144 bytes
-
Database Buffers 226492416 bytes
-
Redo Buffers 8052736 bytes
-
数据库装载完毕。
-
数据库已经打开。
破坏数据块
-
[oracle@kvm61 sdk]$ bbed
-
Password:
-
-
BBED: Release 2.0.0.0.0 - Limited Production on 星期日 6月 12 22:53:04 2016
-
-
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
-
-
************* !!! For Oracle Internal Use only !!! ***************
-
-
BBED> show
-
FILE# 1
-
BLOCK# 1
-
OFFSET 0
-
DBA 0x00400001 (4194305 1,1)
-
FILENAME /oracle/oradata/sdk/system01.dbf
-
BIFILE bifile.bbd
-
LISTFILE /home/oracle/bbed.conf
-
BLOCKSIZE 8192
-
MODE Edit
-
EDIT Unrecoverable
-
IBASE Dec
-
OBASE Dec
-
WIDTH 80
-
COUNT 512
-
LOGFILE log.bbd
-
SPOOL No
-
-
BBED> set file 4
-
FILE# 4
-
-
BBED> show
-
FILE# 4
-
BLOCK# 1
-
OFFSET 0
-
DBA 0x01000001 (16777217 4,1)
-
FILENAME /oracle/oradata/sdk/users01.dbf
-
BIFILE bifile.bbd
-
LISTFILE /home/oracle/bbed.conf
-
BLOCKSIZE 8192
-
MODE Edit
-
EDIT Unrecoverable
-
IBASE Dec
-
OBASE Dec
-
WIDTH 80
-
COUNT 512
-
LOGFILE log.bbd
-
SPOOL No
下面对指定的数据块进行修改
-
BBED> modify 1000 file 4 block 135
-
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) Y
-
File: /oracle/oradata/sdk/users01.dbf (4)
-
Block: 135 Offsets: 0 to 511 Dba:0x01000087
-
------------------------------------------------------------------------
-
03e80000 87000001 3b590e00 00000106 6c240000 01000000 ef1d0100 24590e00
-
00000000 02003200 80000001 0a001b00 32020000 cc58c100 5c002900 04200000
-
3b590e00 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00010400 ffff1a00 3c1f221f 221f0000 04007e1f 681f541f 3c1f0000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
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> verify
-
DBVERIFY - Verification starting
-
FILE = /oracle/oradata/sdk/users01.dbf
-
BLOCK = 135
-
-
Block 135 is corrupt
-
Corrupt block relative dba: 0x01000087 (file 0, block 135)
-
Bad header found during verification
-
Data in bad block:
-
type: 3 format: 0 rdba: 0x01000087
-
last change scn: 0x0000.000e593b seq: 0x1 flg: 0x06
-
spare1: 0x0 spare2: 0x0 spare3: 0x0
-
consistency value in tail: 0x593b0601
-
check value in block header: 0x246c
-
computed block checksum: 0x4a05
-
-
-
DBVERIFY - Verification complete
-
-
Total Blocks Examined : 1
-
Total Blocks Processed (Data) : 0
-
Total Blocks Failing (Data) : 0
-
Total Blocks Processed (Index): 0
-
Total Blocks Failing (Index): 0
-
Total Blocks Empty : 0
-
Total Blocks Marked Corrupt : 1
-
Total Blocks Influx : 0
-
Message 531 not found; product=RDBMS; facility=BBED
-
SQL> select * from scott.dept;
-
select * from scott.dept
-
*
-
第 1 行出现错误:
-
ORA-01578: ORACLE 数据块损坏 (文件号 4, 块号 135)
-
ORA-01110: 数据文件 4: '/oracle/oradata/sdk/users01.dbf'
从备份文件恢复数据块
bbed文件列表加入离线备份文件,编号7
切换到7号文件,讲对应的block复制到4号文件:
-
[oracle@kvm61 ~]$ cat /home/oracle/bbed.conf
-
1 /oracle/oradata/sdk/system01.dbf 723517440
-
2 /oracle/oradata/sdk/sysaux01.dbf 639631360
-
3 /oracle/oradata/sdk/undotbs01.dbf 204472320
-
4 /oracle/oradata/sdk/users01.dbf 595066880
-
5 /oracle/oradata/sdk/example01.dbf 108134400
-
6 /oracle/scripts/sql/TBS_A.DBF 25165824
-
7 /oracle/oradata/sdk/users01.dbf.2 595066880
-
BBED> set file 7
-
FILE# 7
-
-
BBED> show
-
FILE# 7
-
BLOCK# 135
-
OFFSET 0
-
DBA 0x01c00087 (29360263 7,135)
-
FILENAME /oracle/oradata/sdk/users01.dbf.2
-
BIFILE bifile.bbd
-
LISTFILE /home/oracle/bbed.conf
-
BLOCKSIZE 8192
-
MODE Edit
-
EDIT Unrecoverable
-
IBASE Dec
-
OBASE Dec
-
WIDTH 80
-
COUNT 512
-
LOGFILE log.bbd
-
SPOOL No
-
-
BBED> copy file 7 block 135 to file 4 block 135
-
File: /oracle/oradata/sdk/users01.dbf (4)
-
Block: 135 Offsets: 0 to 511 Dba:0x01000087
-
------------------------------------------------------------------------
-
06a20000 87000001 3b590e00 00000106 6c240000 01000000 ef1d0100 24590e00
-
00000000 02003200 80000001 0a001b00 32020000 cc58c100 5c002900 04200000
-
3b590e00 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00010400 ffff1a00 3c1f221f 221f0000 04007e1f 681f541f 3c1f0000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-
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> verify file 4
-
DBVERIFY - Verification starting
-
FILE = /oracle/oradata/sdk/users01.dbf
-
-
-
DBVERIFY - Verification complete
-
-
Total Blocks Examined : 72640
-
Total Blocks Processed (Data) : 58074
-
Total Blocks Failing (Data) : 0
-
Total Blocks Processed (Index): 7430
-
Total Blocks Failing (Index): 0
-
Total Blocks Empty : 4973
-
Total Blocks Marked Corrupt : 0
-
Total Blocks Influx : 0
-
Message 531 not found; product=RDBMS; facility=BBED
表空间离线一下
-
SQL> select * from scott.dept;
-
select * from scott.dept
-
*
-
第 1 行出现错误:
-
ORA-01578: ORACLE 数据块损坏 (文件号 4, 块号 135)
-
ORA-01110: 数据文件 4: '/oracle/oradata/sdk/users01.dbf'
-
-
-
SQL> alter tablespace users offline;
-
-
表空间已更改。
-
-
SQL> alter tablespace users online;
-
-
表空间已更改。
-
-
SQL> select * from scott.dept;
-
-
DEPTNO DNAME LOC
-
---------- ---------------------------- --------------------------
-
10 ACCOUNTING NEW YORK
-
20 RESEARCH DALLAS
-
30 SALES CHICAGO
-
40 OPERATIONS BOSTON
数据块恢复
一个简单的例子,理解bbed的基本使用。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29023300/viewspace-2119273/
,如需转载,请注明出处,否则将追究法律责任。