在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)