ORA-01578: ORACLE 数据块损坏

 

time: 2008-6-12 18:35
author : skate
 
os: winxp
db: 10g r2
 
错误提示:
 
ORA-01578: ORACLE 数据块损坏 (文件号 6, 块号 20)
ORA-01110: 数据文件 6: 'F:/ORACLE/PRODUCT/10.2.0/ORADATA/MOVO/BLOCK.DBF'
 
 
数据块的损坏与恢复
数据库的恢复有时是件很复杂的事情,轻率的操作和尝试可能导致数据库的永久损坏
 
所以在操作前 一定要做好备份,对于重要的数据,如果自己不能确定恢复步骤
 
和后果的话,可以先向专业人士咨询,以免造成损失
 
 
这里是做模拟数据块的损坏和恢复
 
 
 
1.插入数据
 
C:/Documents and Settings/Administrator>sqlplus / as sysdba
 
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 6月 12 17:38:46 2008
 
Copyright (c) 1982, 2005, Oracle. All rights reserved.
 
 
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
 
SQL> select name from v$datafile;
 
NAME
------------------------------------------------------------------------------
 
F:/ORACLE/PRODUCT/10.2.0/ORADATA/MOVO/SYSTEM01.DBF
F:/ORACLE/PRODUCT/10.2.0/ORADATA/MOVO/UNDOTBS04.DBF
F:/ORACLE/PRODUCT/10.2.0/ORADATA/MOVO/SYSAUX01.DBF
F:/ORACLE/PRODUCT/10.2.0/ORADATA/MOVO/USERS01.DBF
F:/ORACLE/PRODUCT/10.2.0/ORADATA/MOVO/EXAMPLE01.DBF
F:/ORACLE/PRODUCT/10.2.0/ORADATA/MOVO/BLOCK.DBF
 
已选择6行。
 
SQL> drop tablespace block including contents and datafiles;
 
表空间已删除。
 
SQL> create tablespace block
 2 datafile 'F:/ORACLE/PRODUCT/10.2.0/ORADATA/MOVO/block.dbf' size 1m
 3 extent management local;
 
表空间已创建。
 
 
 
SQL> alter user skate default tablespace block;
 
用户已更改。
 
SQL> alter user skate quota unlimited on block;
 
用户已更改。
 
SQL> conn skate/skate
已连接。
SQL> create table t as select * from dba_users;
 
表已创建。
 
SQL> insert into t select * from t;
 
已创建28行。
 
SQL> insert into t select * from t;
 
已创建56行。
 
SQL> insert into t select * from t;
 
已创建112行。
 
SQL> insert into t select * from t;
 
已创建224行。
 
SQL> insert into t select * from t;
 
已创建448行。
 
SQL> insert into t select * from t;
 
已创建896行。
 
SQL> insert into t select * from t;
 
已创建1792行。
 
SQL> insert into t select * from t;
 
已创建3584行。
 
SQL> insert into t select * from t;
insert into t select * from t
*
第 1 行出现错误:
ORA-01653: 表 SKATE.T 无法通过 8 (在表空间 BLOCK 中) 扩展
 
SQL> commit;
 
提交完成。
 
SQL> alter system checkpoint;
 
系统已更改。
 
SQL> select count(*) from t;
 
 COUNT(*)
----------
      7168
 
SQL>
 
SQL> conn /as sysdba
已连接。
SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL>
 
 
2.模拟损坏数据文件
 
关闭数据库后用Ultredit编辑数据文件,随便更改几个字符.然后启动数据库
 
 
SQL> startup
ORACLE 例程已经启动。
 
Total System Global Area 574619648 bytes
Fixed Size                   1250212 bytes
Variable Size              180358236 bytes
Database Buffers           385875968 bytes
Redo Buffers                 7135232 bytes
数据库装载完毕。
数据库已经打开。
SQL> select count(*) from t;
select count(*) from t
                     *
第 1 行出现错误:
ORA-00942: 表或视图不存在
 
 
SQL> select count(*) from skate.t;
select count(*) from skate.t
                           *
第 1 行出现错误:
ORA-01578: ORACLE 数据块损坏 (文件号 6, 块号 20)
ORA-01110: 数据文件 6: 'F:/ORACLE/PRODUCT/10.2.0/ORADATA/MOVO/BLOCK.DBF'
 
 
SQL>
 
 
注意:因为数据块损坏,所以查询该表,将会提示错误
 
 
3. 使用DBV检查数据文件
 
 
 
C:/Documents and Settings/Administrator>dbv file=F:/oracle/product/10.2.0/oradat
a/movo/BLOCK.DBF blocksize=8192
 
DBVERIFY: Release 10.2.0.1.0 - Production on 星期四 6月 12 18:12:35 2008
 
Copyright (c) 1982, 2005, Oracle. All rights reserved.
 
DBVERIFY - 开始验证: FILE = F:/oracle/product/10.2.0/oradata/movo/BLOCK.DBF
页 20 标记为损坏
Corrupt block relative dba: 0x01800014 (file 6, block 20)
Bad check value found during dbv:
Data in bad block:
 type: 6 format: 2 rdba: 0x01800014
 last change scn: 0x0000.0015e13c seq: 0x1 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0xe13c0601
 check value in block header: 0xf7d7
 computed block checksum: 0x7772
 
 
 
DBVERIFY - 验证完成
 
检查的页总数: 128
处理的页总数 (数据): 109
失败的页总数 (数据): 0
处理的页总数 (索引): 0
失败的页总数 (索引): 0
处理的页总数 (其它): 18
处理的总页数 (段) : 0
失败的总页数 (段) : 0
空的页总数: 0
标记为损坏的总页数: 1
流入的页总数: 0
最高块 SCN             : 1433924 (0.1433924)
 
C:/Documents and Settings/Administrator>
 
 
 
dbv检测到坏块.
 
 
4.寻求恢复
 
在这种情况下,如果有备份,需要从备份中恢复
如果没有备份,那么坏块部分的数据肯定要丢失了
 
 
在这个时候导出是不允许的:
 
 
C:/Documents and Settings/Administrator>exp skate/skate@movo file=t.dmp tables=t
 
 
Export: Release 10.2.0.1.0 - Production on 星期四 6月 12 18:14:54 2008
 
Copyright (c) 1982, 2005, Oracle. All rights reserved.
 
 
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
 
即将导出指定的表通过常规路径...
. . 正在导出表                                T
EXP-00056: 遇到 ORACLE 错误 1578
ORA-01578: ORACLE 数据块损坏 (文件号 6, 块号 20)
ORA-01110: 数据文件 6: 'F:/ORACLE/PRODUCT/10.2.0/ORADATA/MOVO/BLOCK.DBF'
导出成功终止, 但出现警告。
 
C:/Documents and Settings/Administrator>
 
 
 
5.恢复步骤
 
当然,对于不同的情况需要区别对待
 
首先你需要检查损坏的对象,使用以下SQL:
 
 
 
SQL> select tablespace_name,segment_type,owner,segment_name from dba_extents
 2 where file_id=6 and 20 between block_id and block_id+blocks-1
 3 ;
 
TABLESPACE_NAME                 SEGMENT_TYPE       OWNER
------------------------------ ------------------ ------------------------------
 
SEGMENT_NAME
--------------------------------------------------------------------------------
 
BLOCK                           TABLE              SKATE
T
 
 
SQL>
 
 
如果损失的是数据,ok
我们可以设置内部事件,使exp跳过这些损坏的block
 
 
 
SQL> alter system set events='10231 trace name context forever,level 10';   
 
系统已更改。
 
SQL>
 
注意: 10231 内部事件,设置在全表扫描时跳过损坏的数据块.
 
 
 
然后我们可以导出未损坏的数据:
 
 
C:/Documents and Settings/Administrator>exp skate/skate@movo file=t.dmp tables=t
 
 
Export: Release 10.2.0.1.0 - Production on 星期四 6月 12 18:22:49 2008
 
Copyright (c) 1982, 2005, Oracle. All rights reserved.
 
 
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
 
即将导出指定的表通过常规路径...
. . 正在导出表                                T导出了         7102 行
成功终止导出, 没有出现警告。
 
C:/Documents and Settings/Administrator>
 
 
 
 
这时候数据成功导出.这是我可以drop table,然后recreate这个表,最后在imp数据
 
删除表T:
 
SQL> drop table t;
drop table t
           *
第 1 行出现错误:
ORA-00942: 表或视图不存在
 
 
SQL> drop table skate.t;
 
表已删除。
 
SQL> commit;
 
提交完成。
 
SQL>
 
 
导入数据
 
C:/Documents and Settings/Administrator>imp skate/skate@movo file=t.dmp tables=t
 
 
Import: Release 10.2.0.1.0 - Production on 星期四 6月 12 18:29:36 2008
 
Copyright (c) 1982, 2005, Oracle. All rights reserved.
 
 
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
 
经由常规路径由 EXPORT:V10.02.01 创建的导出文件
已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入
. 正在将 SKATE 的对象导入到 SKATE
. 正在将 SKATE 的对象导入到 SKATE
. . 正在导入表                              "T"导入了         7102 行
成功终止导入, 没有出现警告。
 
C:/Documents and Settings/Administrator>
 
 
SQL> select count(*) from skate.t;
 
 COUNT(*)
----------
      7102
 
SQL>
 
现在这个表可以访问了
 
 
在这个例子中我们损失数据为:
 
 7168-7102=66
数据块损坏前:
 
SQL> select count(*) from t;
 
 COUNT(*)
----------
      7168
 
数据块损坏后:
 
SQL> select count(*) from t;
 
 COUNT(*)
----------
      7102
 
 
 
---end----
 
 
 
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值