1108File Space Bitmap Block损坏能修复吗2

[20161108]File Space Bitmap Block损坏能修复吗?

--这阵子做了数据文件的一些探究,还是回到File Space Bitmap Block损坏修复的问题。
--链接http://www.itpub.net/thread-2071023-1-1.html提到File Space Bitmap Block损坏,问能修复吗?

--通过我前面的测试,可以把空间设置为1.这样就可以解决这个问题,问题在在于相应的数据块如何构造。
--实际上很简单我仅仅建立1个相同大小的数据文件,在copy回去,再修改一些基本信息就ok了。

--我上次做的测试链接如下:http://blog.itpub.net/267265/viewspace-2127826/

--通过例子来说明:

1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

CREATE TABLESPACE SUGAR DATAFILE
  '/mnt/ramdisk/book/sugar01.dbf' SIZE 40M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

create table t1 tablespace sugar as select rownum id ,lpad('A',32,'A') name from dual connect by level<=1e5;
--建立大小5M的表。

create table t2 tablespace sugar as select rownum id ,lpad('B',32,'B') name from dual connect by level<=2e5;
create table t3 tablespace sugar as select rownum id ,lpad('C',32,'C') name from dual connect by level<=2e5;
alter system checkpoint;

2.破坏位图区。

SYS@book> alter tablespace sugar offline ;
Tablespace altered.

--安全期间,做一个备份:
$ cp /mnt/ramdisk/book/sugar01.dbf /u01/backup/sugar01.dbf_20161104
--正常数据文件第0块OS。第1块是文件头,第2块是位图头块,第3-127块是位图区。
--我文件很小,估计在3块里面:8192*3=24576

$ bvi -b 24576 -s 8192 /mnt/ramdisk/book/sugar01.dbf
--应该能看到许多F,表示已经使用,随便输入一些垃圾数据。我的测试全部设置为0。

RMAN> validate datafile 6;
Starting validate at 2016-11-08 16:25:19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=90 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00006 name=/mnt/ramdisk/book/sugar01.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
6    FAILED 0              1945         5120            6167853
  File Name: /mnt/ramdisk/book/sugar01.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              2974
  Index      0              0
  Other      1              201

validate found one or more corrupt blocks
See trace file /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_56225.trc for details
Finished validate at 2016-11-08 16:25:21

3.继续测试:
SYS@book> alter tablespace sugar online ;
Tablespace altered.

SYS@book> select * from t1 where rownum=1;
ID NAME
--- --------------------------------
  1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

SYS@book> select * from t2 where rownum=1;
ID NAME
--- --------------------------------
  1 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

SYS@book> select * from t3 where rownum=1;
ID NAME
--- --------------------------------
  1 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

--访问存在的对象没有问题。

SYS@book> update t1 set name=lpad('B',32,'B') where rownum=1;
1 row updated.

SYS@book> commit ;
Commit complete.

SYS@book> create table t4 tablespace sugar as select rownum id ,lpad('D',32,'D') name from dual connect by level<=10;
create table t4 tablespace sugar as select rownum id ,lpad('D',32,'D') name from dual connect by level<=10
                                                                                 *
ERROR at line 1:
ORA-00600: internal error code, arguments: [KSLFDNG2], [0x08591B490], [0], [0x084B84748], [0x000000000], [], [], [], [], [], [], []

--建立新表插入数据失败,既然能online,测试execute dbms_space_admin.tablespace_dump_bitmaps('SUGAR');。

SYS@book> select * from V$DATABASE_BLOCK_CORRUPTION;
     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
         1       3345          1                  0 CORRUPT
         1      91041          1                  0 CORRUPT
         6          3          1                  0 ALL ZERO

SYS@book> execute dbms_space_admin.tablespace_dump_bitmaps('SUGAR');
BEGIN dbms_space_admin.tablespace_dump_bitmaps('SUGAR'); END;

*
ERROR at line 1:
ORA-00600: internal error code, arguments: [KSLFDNG2], [0x08591B490], [32767], [0x084B84748], [0x000000000], [], [], [], [], [], [], []
ORA-06512: at "SYS.DBMS_SPACE_ADMIN", line 322
ORA-06512: at line 1

--这样直接操作不行。

SYS@book> alter database datafile 6 offline ;
Database altered.

SYS@book> recover datafile 6;
Media recovery complete.

4.修复看看:
--建立一个相同大小的数据文件对应的表空间:

CREATE TABLESPACE TEA DATAFILE
  '/mnt/ramdisk/book/tea01.dbf' SIZE 40M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

SYS@book> execute dbms_space_admin.tablespace_dump_bitmaps('TEA');
PL/SQL procedure successfully completed.

SYS@book> alter system checkpoint;
System altered.

SYS@book> alter system dump datafile 7 block 3;
System altered.

Block dump from disk:
buffer tsn: 8 rdba: 0x01c00003 (7/3)
scn: 0x0000.005e2005 seq: 0x01 flg: 0x04 tail: 0x20051e01
frmt: 0x02 chkval: 0x4104 type: 0x1e=KTFB Bitmapped File Space Bitmap
Hex dump of block: st=0, typ_found=1
Dump of memory from 0x00007F1BB5E4D200 to 0x00007F1BB5E4F200
7F1BB5E4D200 0000A21E 01C00003 005E2005 04010000  [......... ^.....]
7F1BB5E4D210 00004104 00000007 00000080 00000000  [.A..............]
7F1BB5E4D220 00000000 0000F800 00000000 00000000  [................]
7F1BB5E4D230 00000000 00000000 00000000 00000000  [................]
        Repeat 507 times
7F1BB5E4F1F0 00000000 00000000 00000000 20051E01  [............... ]
File Space Bitmap Block:
BitMap Control:
RelFno: 7, BeginBlock: 128, Flag: 0, First: 0, Free: 63488
0000000000000000 0000000000000000 0000000000000000 0000000000000000
0000000000000000 0000000000000000 0000000000000000 0000000000000000
0000000000000000 0000000000000000 0000000000000000 0000000000000000

--嗯! 都是0,不行要都是F才行。

SCOTT@book> create table t4  tablespace tea as select rownum id from dual connect by level<=2;
Table created.

SYS@book> execute dbms_space_admin.tablespace_dump_bitmaps('TEA');
PL/SQL procedure successfully completed.

--检查发现还是0.不知道为什么,难道要写满在执行才可那个出现这个情况吗?

SYS@book> ALTER DATABASE DATAFILE '/mnt/ramdisk/book/tea01.dbf' AUTOEXTEND OFF;
Database altered.

SCOTT@book> ALTER TABLE t4 MINIMIZE RECORDS_PER_BLOCK ;
Table altered.

SCOTT@book> insert into t4 select rownum id from dual connect by level<=2e5;
insert into t4 select rownum id from dual connect by level<=2e5
            *
ERROR at line 1:
ORA-01653: unable to extend table SCOTT.T4 by 128 in tablespace TEA

SCOTT@book> rollback;
Rollback complete.

SYS@book> ALTER DATABASE DATAFILE '/mnt/ramdisk/book/tea01.dbf' AUTOEXTEND ON;
Database altered.

SYS@book> alter system checkpoint ;
System altered.

SYS@book> alter system dump datafile 7 block 3;
System altered.

--检查转储:
File Space Bitmap Block:
BitMap Control:
RelFno: 7, BeginBlock: 128, Flag: 0, First: 624, Free: 62864
FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF FFFFFFFFFFFF0000 0000000000000000 0000000000000000
0000000000000000 0000000000000000 0000000000000000 0000000000000000
0000000000000000 0000000000000000 0000000000000000 0000000000000000

--现在玩一把偷梁换柱的把戏,利用bbed。

BBED> info
File#  Name                             Size(blks)
-----  ----                             ----------
     1  /mnt/ramdisk/book/system01.dbf            0
     2  /mnt/ramdisk/book/sysaux01.dbf            0
     3  /mnt/ramdisk/book/undotbs01.dbf           0
     4  /mnt/ramdisk/book/users01.dbf             0
     5  /mnt/ramdisk/book/example01.dbf           0
     6  /mnt/ramdisk/book/sugar01.dbf             0
     7  /mnt/ramdisk/book/tea01.dbf               0

BBED> copy dba 7,3 to dba 6,3
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /mnt/ramdisk/book/sugar01.dbf (6)
Block: 3                                                    Offsets:    0 to   63                                               Dba:0x01800003
------------------------------------------------------------------------------------------------------------------------------------------------
1ea20000 0300c001 97235e00 00000104 1bb10000 07000000 80000000 00000000 70020000 90f50000 00000000 00000000 00000000 00000000 ffffffff ffffffff
<64 bytes per line>

--千万注意方向不要错!!

BBED> set dba 6,3
        DBA             0x01800003 (25165827 6,3)

BBED> dump /v count 128
File: /mnt/ramdisk/book/sugar01.dbf (6)
Block: 3                                 Offsets:    0 to  127                            Dba:0x01800003
-----------------------------------------------------------------------------------------------------------
1ea20000 0300c001 97235e00 00000104 1bb10000 07000000 80000000 00000000 l .........#^.....................
          ~~~~~~~~                            ~~~~~~~~
70020000 90f50000 00000000 00000000 00000000 00000000 ffffffff ffffffff l p...............................
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff l ................................
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff l ................................
<32 bytes per line>

--修改~ 的两处应该ok。 第1处是dba地址,大小头对调就是 03008010, 第2处我推测是文件号对应的就是06000000
--我个人喜欢bvi修改,修改后如下:

BBED> dump /v dba 6,3  count 128
File: /mnt/ramdisk/book/sugar01.dbf (6)
Block: 3                                 Offsets:    0 to  127                            Dba:0x01800003
-----------------------------------------------------------------------------------------------------------
1ea20000 03008001 97235e00 00000104 1bb10000 06000000 80000000 00000000 l .........#^.....................
          ~~~~~~~~                            ~~~~~~~~
70020000 90f50000 00000000 00000000 00000000 00000000 ffffffff ffffffff l p...............................
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff l ................................
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff l ................................
<32 bytes per line>

BBED> sum apply dba 6,3
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
Check value for File 6, Block 3:
current = 0xb15a, required = 0xb15a

SYS@book> create table t5 tablespace sugar as select rownum id ,lpad('D',32,'D') name from dual connect by level<=10;
Table created.

--OK现在没有问题了。

5.再来执行如下命令看看:

SYS@book> execute dbms_space_admin.tablespace_dump_bitmaps('TEA');
PL/SQL procedure successfully completed.

--奇怪无法再现前面的测试。

RMAN> validate datafile 1;

Starting validate at 2016-11-08 17:19:58
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=80 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
1    OK     0              15314        96071           6170653
  File Name: /mnt/ramdisk/book/system01.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              63529
  Index      0              13184
  Other      0              3973

channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
including current control file for validation
including current SPFILE in backup set
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
List of Control File and SPFILE
===============================
File Type    Status Blocks Failing Blocks Examined
------------ ------ -------------- ---------------
SPFILE       OK     0              2
Control File OK     0              618
Finished validate at 2016-11-08 17:20:00

RMAN> validate datafile 6;

Starting validate at 2016-11-08 17:20:06
using channel ORA_DISK_1
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00006 name=/mnt/ramdisk/book/sugar01.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
6    OK     0              3989         7168            6170478
  File Name: /mnt/ramdisk/book/sugar01.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              2975
  Index      0              0
  Other      0              204

Finished validate at 2016-11-08 17:20:07

SYS@book> select * from V$DATABASE_BLOCK_CORRUPTION;
no rows selected

--OK,现在问题已经解决。
--我觉得奇怪的是全是0,并不影响存在数据的读取。理论讲想办法备份出来应该也可以解决问题。

时间: 2024-10-01 01:15:49

1108File Space Bitmap Block损坏能修复吗2的相关文章

1104File Space Bitmap Block损坏能修复吗

[20161104]File Space Bitmap Block损坏能修复吗?.txt -- 链接http://www.itpub.net/thread-2071023-1-1.html提到File Space Bitmap Block损坏,问能修复吗? 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------

[20161111File Space Bitmap Block修复机制

[20161111]File Space Bitmap Block修复机制.txt --前几天在测试File Space Bitmap Block时执行了,execute dbms_space_admin.TABLESPACE_REBUILD_BITMAPS('SUGAR') --这样位图区全部设置为1,显示都是F.它的修复机制不是非常清楚,今天做一些深入的探究. --继续重复昨天的测试. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING            

20161114File Space Bitmap Block修复机制2

[20161114]File Space Bitmap Block修复机制2.txt --前几天在测试File Space Bitmap Block时执行了,execute dbms_space_admin.TABLESPACE_REBUILD_BITMAPS('SUGAR') --这样位图区全部设置为1,显示都是F. --上次提到,execute dbms_space_admin.TABLESPACE_REBUILD_BITMAPS('SUGAR')会修改位图区全部设置为1,显示都是F. --

mysql数据库索引损坏及修复经验分享

  这篇文章主要介绍了mysql数据库索引损坏及修复经验分享,需要的朋友可以参考下 mysql表索引被破坏的问题及解决 下午上班,惊闻我的dedecms的网站出问题了,访问一看,果然全屏报错,检查mysql日志,错误信息为: Table '.dedecmsv4dede_archives' is marked as crashed and should be repaired 提示说cms的文章表dede_archives被标记有问题,需要修复.于是赶快恢复历史数据,上网查找原因.最终将问题解决.

电脑回收站损坏怎么修复

  电脑回收站损坏怎么修复 1.按win+r打开运行窗口,输入cmd,回车即可,如图所示: 2.然后在界面中,输入"rd/s c:\\$recylce.bin"(双引号不用),回车即可修复,如图所示:

WinRAR压缩包损坏怎么修复

对于文件比较大的文件我们常常会进行压缩或者要传输一个大一点的文件也会用到压缩,这样不仅占用空间会变小,而且传输过程中也容易保存文件的完整性,但是我们有的时候遇到这样的问题,就是压缩文件受到了损坏.那么压缩文件损坏怎么办?压缩文件损坏怎么修复?其实WinRAR压缩包中有内置的压缩文件修复功能,对于压缩包损坏的一些受损的压缩文件可以起到妙用. 对于文件比较大的文件我们经常爱做的就是进行压缩,但是我们有的时候遇到这样的问题,就是压缩文件受到了损坏.那么压缩文件损坏怎么办?压缩文件损坏怎么修复?其实Wi

主引导程序损坏的修复

  主引导程序损坏的修复方法很重要,用户可以参考以下过程. 1.检查硬件和基本配置 电脑出现硬盘无法检测的情况,首先要检查盘驱动器与硬盘控制器的连接是否正常,硬盘驱动器的电源线连接.如果有多个设备,需要检查硬盘之间或硬盘与光驱等设备之间是否有冲突. 2.主引导区检查及修复 主引导区如果被病毒.误操作等原因破坏,可能导致硬盘或数据无法访问.可以用U盘启动系统,看能否对硬盘进行访问.如果能访问,说明可能仅是操作系统受到破坏.如果不能访问,说明可能硬件故障,需要进行维修.

ps-扩容盘照片损坏能否修复

问题描述 扩容盘照片损坏能否修复 不小心买了个扩容盘,里面存了一些照片,有几张特别珍贵,但是现在打开一看全都损坏了,请问有办法能修复么-- 解决方案 看什么情况,所谓扩容sd卡或者u盘,无非就是把相同的存储单元分配给了不同的地址.造成的后果是,数据的覆盖和数据并不真实存在在这个地址上,前者没有办法恢复,后者,通过对存储单元扫描和重构,可以提取部分不完整的数据.

xls-XLS文件误删后恢复硬盘找回了,可是提示文件损坏,修复后却出现另一种问题,求大神解决QWQ

问题描述 XLS文件误删后恢复硬盘找回了,可是提示文件损坏,修复后却出现另一种问题,求大神解决QWQ 修复后,大量的lost label,请问这种情况怎么修复啊各位大神,这个表格很重要的,当时竟然忘了备份,跪求解决啊QWQ 解决方案 有两个可能,一个是存放文件的实际的簇被别的数据覆盖了,如果是这样,没辙. 还可能是你的恢复软件不行,它没有真正定位文件头,那么这个需要手工去寻找了.如果文件很重要,建议你找数据恢复的公司帮你.