
在Oracle中,BBED模拟修复坏块。
1SYS@orclasm > create tablespace ts_bc_lhr datafile '/tmp/ts_bc_lhr.dbf' size 50M;
2
3Tablespace created.
4
5SYS@orclasm > create table t_bc_lhr tablespace ts_bc_lhr as select * from dba_objects;
6
7Table created.
8
9
10SELECT DBMS_ROWID.ROWID_OBJECT(ROWID) OBJECT_ID,
11 DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID) FILE_ID,
12 DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) BLOCK_ID,
13 COUNT(1) COUNTS
14 FROM LHR.T_BC_LHR D
15 GROUP BY DBMS_ROWID.ROWID_OBJECT(ROWID),
16 DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID),
17 DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
18 ORDER BY DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID);

1[oracle@rhel6lhr ~]$ echo "12 /tmp/ts_bc_lhr.dbf" > /home/oracle/file.txt
2[oracle@rhel6lhr ~]$ bbed PASSWORD=blockedit mode=edit blocksize=8192 listfile=/home/oracle/file.txt
3
4BBED: Release 2.0.0.0.0 - Limited Production on Mon May 22 16:35:14 2017
5
6Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
7
8************* !!! For Oracle Internal Use only !!! ***************
9
10BBED> show
11 FILE# 12
12 BLOCK# 1
13 OFFSET 0
14 DBA 0x03000001 (50331649 12,1)
15 FILENAME /tmp/ts_bc_lhr.dbf
16 BIFILE bifile.bbd
17 LISTFILE /home/oracle/file.txt
18 BLOCKSIZE 8192
19 MODE Edit
20 EDIT Unrecoverable
21 IBASE Dec
22 OBASE Dec
23 WIDTH 80
24 COUNT 512
25 LOGFILE ./log.bbd
26 SPOOL No
27
28
29BBED> info
30 File# Name Size(blks)
31 ----- ---- ----------
32 12 /tmp/ts_bc_lhr.dbf 0
33
34BBED> set dba 12,2443
35 DBA 0x0300098b (50334091 12,2443)
36
37BBED> modify /c HAHAH dba 12,2443 offset 0
38 File: /tmp/ts_bc_lhr.dbf (12)
39 Block: 2443 Offsets: 0 to 127 Dba:0x0300098b
40------------------------------------------------------------------------
41 48414841 48090003 c33cc703 00000204 26570000 01000000 c2760200 c13cc703
42 00000000 03003200 88090003 ffff0000 00000000 00000000 00000000 00800000
43 c13cc703 00000000 00000000 00000000 00000000 00000000 00000000 00000000
44 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00015800
45
46 <32 bytes per line>
47
48BBED> dump /v dba 12,2443 offset 0
49 File: /tmp/ts_bc_lhr.dbf (12)
50 Block: 2443 Offsets: 0 to 127 Dba:0x0300098b
51-------------------------------------------------------
52 48414841 48090003 c33cc703 00000204 l HAHAH....<......
53 26570000 01000000 c2760200 c13cc703 l &W.......v...<..
54 00000000 03003200 88090003 ffff0000 l ......2.........
55 00000000 00000000 00000000 00800000 l ................
56 c13cc703 00000000 00000000 00000000 l .<..............
57 00000000 00000000 00000000 00000000 l ................
58 00000000 00000000 00000000 00000000 l ................
59 00000000 00000000 00000000 00015800 l ..............X.
60
61 <16 bytes per line>
62
63BBED> sum apply
64Check value for File 12, Block 2443:
65current = 0xf5e3, required = 0xf5e3
66
67BBED> verify
68DBVERIFY - Verification starting
69FILE = /tmp/ts_bc_lhr.dbf
70BLOCK = 2443
71
72Block 2443 is corrupt
73Corrupt block relative dba: 0x0300098b (file 0, block 2443)
74Bad header found during verification
75Data in bad block:
76 type: 72 format: 1 rdba: 0x03000948
77 last change scn: 0x0000.03c73cc3 seq: 0x2 flg: 0x04
78 spare1: 0x48 spare2: 0x41 spare3: 0x0
79 consistency value in tail: 0x3cc30602
80 check value in block header: 0xf5e3
81 computed block checksum: 0x0
82
83
84DBVERIFY - Verification complete
85
86Total Blocks Examined : 1
87Total Blocks Processed (Data) : 0
88Total Blocks Failing (Data) : 0
89Total Blocks Processed (Index): 0
90Total Blocks Failing (Index): 0
91Total Blocks Empty : 0
92Total Blocks Marked Corrupt : 1
93Total Blocks Influx : 0
94Message 531 not found; product=RDBMS; facility=BBED
95
96
97BBED>
98[oracle@rhel6lhr ~]$ dbv file=/tmp/ts_bc_lhr.dbf blocksize=8192
99
100DBVERIFY: Release 11.2.0.3.0 - Production on Mon May 22 16:51:26 2017
101
102Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
103
104DBVERIFY - Verification starting : FILE = /tmp/ts_bc_lhr.dbf
105Page 2443 is marked corrupt
106Corrupt block relative dba: 0x0300098b (file 12, block 2443)
107Bad header found during dbv:
108Data in bad block:
109 type: 72 format: 1 rdba: 0x03000948
110 last change scn: 0x0000.03c73cc3 seq: 0x2 flg: 0x04
111 spare1: 0x48 spare2: 0x41 spare3: 0x0
112 consistency value in tail: 0x3cc30602
113 check value in block header: 0xf5e3
114 computed block checksum: 0x0
115
116
117
118DBVERIFY - Verification complete
119
120Total Pages Examined : 6400
121Total Pages Processed (Data) : 2236
122Total Pages Failing (Data) : 0
123Total Pages Processed (Index): 0
124Total Pages Failing (Index): 0
125Total Pages Processed (Other): 185
126Total Pages Processed (Seg) : 0
127Total Pages Failing (Seg) : 0
128Total Pages Empty : 3978
129Total Pages Marked Corrupt : 1
130Total Pages Influx : 0
131Total Pages Encrypted : 0
132Highest block SCN : 63388870 (0.63388870)
133[oracle@rhel6lhr ~]$
134
135
136SYS@orclasm > alter system flush BUFFER_CACHE;
137
138System altered.
139
140SYS@orclasm > select /*+FULL(T)*/ COUNT(1) FROM LHR.t_bc_lhr;
141select /*+FULL(T)*/ COUNT(1) FROM LHR.t_bc_lhr
142*
143ERROR at line 1:
144ORA-01578: ORACLE data block corrupted (file # 12, block # 2443)
145ORA-01110: data file 12: '/tmp/ts_bc_lhr.dbf'
146
147SYS@orclasm > ANALYZE TABLE LHR.t_bc_lhr VALIDATE STRUCTURE;
148ANALYZE TABLE LHR.t_bc_lhr VALIDATE STRUCTURE
149*
150ERROR at line 1:
151ORA-01578: ORACLE data block corrupted (file # 12, block # 2443)
152ORA-01110: data file 12: '/tmp/ts_bc_lhr.dbf'
153
154SYS@orclasm > SELECT * FROM V$DATABASE_BLOCK_CORRUPTION;
155
156 FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
157---------- ---------- ---------- ------------------ ---------
158 12 2443 1 0 CORRUPT
159
160
161[oracle@rhel6lhr ~]$ exp lhr/lhr tables=lhr.T_BC_LHR file=T_BC_LHR.dmp
162
163Export: Release 11.2.0.3.0 - Production on Mon May 22 17:40:52 2017
164
165Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
166
167
168Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
169With the Partitioning, Automatic Storage Management, OLAP, Data Mining
170and Real Application Testing options
171Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
172
173About to export specified tables via Conventional Path ...
174. . exporting table T_BC_LHR
175EXP-00056: ORACLE error 1578 encountered
176ORA-01578: ORACLE data block corrupted (file # 12, block # 131)
177ORA-01110: data file 12: '/tmp/ts_bc_lhr.dbf'
178Export terminated successfully with warnings.
179[oracle@rhel6lhr ~]$
180
181SYS@orclasm > select tablespace_id,header_file,header_block from sys.sys_dba_segs where owner='LHR' and segment_name='T_BC_LHR';
182
183TABLESPACE_ID HEADER_FILE HEADER_BLOCK
184------------- ----------- ------------
185 36 12 130
186
187[oracle@rhel6lhr ~]$ dbv userid=sys/lhr segment_id=36.12.130
188
189DBVERIFY: Release 11.2.0.3.0 - Production on Mon May 22 17:35:33 2017
190
191Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
192
193DBVERIFY - Verification starting : SEGMENT_ID = 36.12.130
194Page 131 is marked corrupt
195Corrupt block relative dba: 0x03000083 (file 12, block 131)
196Bad header found during dbv:
197Data in bad block:
198 type: 72 format: 1 rdba: 0x03000048
199 last change scn: 0x0000.03c748c6 seq: 0x2 flg: 0x04
200 spare1: 0x48 spare2: 0x41 spare3: 0x0
201 consistency value in tail: 0x48c60602
202 check value in block header: 0xefaf
203 computed block checksum: 0x0
204
205
206
207DBVERIFY - Verification complete
208
209Total Pages Examined : 8
210Total Pages Processed (Data) : 2
211Total Pages Failing (Data) : 0
212Total Pages Processed (Index): 0
213Total Pages Failing (Index): 0
214Total Pages Processed (Other): 2
215Total Pages Processed (Seg) : 1
216Total Pages Failing (Seg) : 0
217Total Pages Empty : 2
218Total Pages Marked Corrupt : 1
219Total Pages Influx : 0
220Total Pages Encrypted : 0
221Highest block SCN : 63391953 (0.63391953)
本文选自《Oracle程序员面试笔试宝典》,作者:小麦苗

==================================================================================================================【干货来了|小麦苗IT资料分享】★小麦苗DB职场干货:https://mp.weixin.qq.com/s/Vm5PqNcDcITkOr9cQg6T7w★小麦苗数据库健康检查:https://share.weiyun.com/5lb2U2M★小麦苗微店:https://weidian.com/?userid=793741433★各种操作系统下的数据库安装文件(Linux、Windows、AIX等):https://pan.baidu.com/s/1hqff3Evv6oj2-Tn87MpFkQ★小麦苗分享的资料:https://share.weiyun.com/57HUxNi★小麦苗课堂资料:https://share.weiyun.com/5fAdN5m★小麦苗课堂试听资料:https://share.weiyun.com/5HnQEuL★小麦苗出版的相关书籍:https://share.weiyun.com/5sQBQpY★小麦苗博客文章:https://share.weiyun.com/5ufi4Dx★数据库系列(Oracle、MySQL、NoSQL):https://share.weiyun.com/5n1u8gv★公开课录像文件:https://share.weiyun.com/5yd7ukG★其它常用软件分享:https://share.weiyun.com/53BlaHX★其它IT资料(OS、网络、存储等):https://share.weiyun.com/5Mn6ESi★Python资料:https://share.weiyun.com/5iuQ2Fn★已安装配置好的虚拟机:https://share.weiyun.com/5E8pxvT★小麦苗腾讯课堂:https://lhr.ke.qq.com/★小麦苗博客:http://blog.itpub.net/26736162/★OCP培训:https://mp.weixin.qq.com/s/2cymJ4xiBPtTaHu16HkiuA★12c的OCP培训:https://mp.weixin.qq.com/s/hMLHlyjMHhLmA0xN4hLvfw★OCM培训:https://mp.weixin.qq.com/s/7-R6Cz8RcJKduVv6YlAxJA★高可用(RAC+DG+OGG)培训:https://mp.weixin.qq.com/s/4vf042CnOdAD8zDyjUueiw★小麦苗课堂腾讯视频:http://v.qq.com/vplus/71f69a319a24c6808cd6e6189ae90664==================================================================================================================

● 本文作者:小麦苗,只专注于数据库的技术,更注重技术的运用
● 作者博客地址:http://blog.itpub.net/26736162/abstract/1/
● 本系列题目来源于作者的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解
● 版权所有,欢迎分享本文,转载请保留出处
● QQ:646634621 QQ群:230161599、618766405
● 微信:lhrbestxh
● 微信公众号:DB宝
● 提供Oracle OCP、OCM、高可用(rac+dg+ogg)和MySQL最实用的技能培训
● 题目解答若有不当之处,还望各位朋友批评指正,共同进步

长按下图识别二维码或微信扫描下图二维码来关注小麦苗的微信公众号:DB宝,学习最实用的数据库技术。



最后修改时间:2020-06-12 12:44:15
文章转载自DB宝,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




