袁莎精忠报国古筝曲谱:块损坏的恢复

来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 06:39:50
块损坏的恢复 一、没有备份的情况下,块损坏,并且块所存储的是数据
SQL> conn olive/olive
已连接。
SQL> create table t as select * from dba_users;表已创建。SQL> select count(*)from t;  COUNT(*)
----------
        28SQL> /  COUNT(*)
----------
        28SQL> /  COUNT(*)
----------
        28SQL> insert into t select * from t;已创建28行。SQL> /已创建56行。SQL> /已创建112行。SQL> /已创建224行。SQL> /已创建448行。SQL> /已创建896行。SQL> /已创建1792行。SQL> /已创建3584行。SQL> /
insert into t select * from t
*
第 1 行出现错误:
ORA-01653: 表 OLIVE.T 无法通过 8 (在表空间 BLOCK 中) 扩展
SQL> commit;提交完成。SQL> select count(*)from t;  COUNT(*)
----------
      7168SQL> conn olive/olive
已连接。
SQL> select count(*) from t;
select count(*) from t
                     *
第 1 行出现错误:
ORA-01578: ORACLE 数据块损坏 (文件号 6, 块号 116)
ORA-01110: 数据文件 6: 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\BLOCK.DBF'alert.log中
Hex dump of (file 6, block 116) in trace file d:\oracle\product\10.2.0\admin\orcl\udump\orcl_ora_1424.trc
Corrupt block relative dba: 0x01800074 (file 6, block 116)
Bad check value found during buffer read
Data in bad block:
 type: 6 format: 2 rdba: 0x01800074
 last change scn: 0x0000.0008e356 seq: 0x1 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0xe3560601
 check value in block header: 0x8f60
 computed block checksum: 0x281e
Reread of rdba: 0x01800074 (file 6, block 116) found same corrupted data
Fri Jan 26 13:22:59 2007
Corrupt Block Found
         TSN = 7, TSNAME = BLOCK
         RFN = 6, BLK = 116, RDBA = 25165940
         OBJN = 52546, OBJD = 52546, OBJECT = T, SUBOBJECT =
         SEGMENT OWNER = OLIVE, SEGMENT TYPE = Table Segment
使用dbv检查数据文件D:\oracle\product\10.2.0\oradata\orcl>dbv file=block.dbf blocksize=8192DBVERIFY: Release 10.2.0.1.0 - Production on 星期五 1月 26 13:27:12 2007Copyright (c) 1982, 2005, Oracle.  All rights reserved.DBVERIFY - 开始验证: FILE = block.dbf
页 116 标记为损坏
Corrupt block relative dba: 0x01800074 (file 6, block 116)
Bad check value found during dbv:
Data in bad block:
 type: 6 format: 2 rdba: 0x01800074
 last change scn: 0x0000.0008e356 seq: 0x1 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0xe3560601
 check value in block header: 0x8f60
 computed block checksum: 0x281e DBVERIFY - 验证完成检查的页总数: 128
处理的页总数 (数据): 109
失败的页总数 (数据): 0
处理的页总数 (索引): 0
失败的页总数 (索引): 0
处理的页总数 (其它): 18
处理的总页数 (段)  : 0
失败的总页数 (段)  : 0
空的页总数: 0
标记为损坏的总页数: 1
流入的页总数: 0
最高块 SCN            : 582511 (0.582511) 准备导出该表D:\oracle\product\10.2.0\oradata\orcl>exp olive/olive file=d:\t.dmp tables=(T);Export: Release 10.2.0.1.0 - Production on 星期五 1月 26 13:31:34 2007Copyright (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, 块号 116)
ORA-01110: 数据文件 6: 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\BLOCK.DBF'
EXP-00011: OLIVE.; 不存在
导出成功终止, 但出现警告。D:\oracle\product\10.2.0\oradata\orcl>
5.恢复步骤当然,对于不同的情况需要区别对待首先你需要检查损坏的对象,使用以下SQL:
SQL>  SELECT tablespace_name, segment_type, owner, segment_name,block_id,blocks
 FROM dba_extents
  2   WHERE file_id = 6
  3   and 116 between block_id AND block_id + blocks -1
  4  ;TABLESPACE_NAME     SEGMENT_TYPE       OWNER     SEGMENT_NAME   BLOCK_ID     BLOCKS
------------------ -------------- ------------- -------------  --------- ----------
BLOCK              TABLE              OLIVE   T       113          8
发现是表中数据损坏我们可以设置内部事件,使exp跳过这些损坏的blockSQL> ALTER SYSTEM SET EVENTS='10231 trace name context forever,level 10';系统已更改。SQL>ALTER SYSTEM SET EVENTS='10231 trace name context forever,level 10' ;
内部事件,设置在全表扫描时跳过损坏的数据块. D:\oracle\product\10.2.0\oradata\orcl>exp olive/olive file=d:\t.dmp tables=(T);Export: Release 10.2.0.1.0 - Production on 星期五 1月 26 13:49:20 2007Copyright (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 行
EXP-00011: OLIVE.; 不存在
导出成功终止, 但出现警告。D:\oracle\product\10.2.0\oradata\orcl>
损失数据 7168-7102=66条
删除表并从备份中导入SQL> conn olive/olive
已连接。
SQL> drop table t;表已删除。SQL> host
Microsoft Windows 2000 [Version 5.00.2195]
(C) 版权所有 1985-2000 Microsoft Corp.C:\Documents and Settings\Administrator.XY>imp olive/olive file=d:\t.dmp tables=
(t);Import: Release 10.2.0.1.0 - Production on 星期五 1月 26 13:53:31 2007Copyright (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 字符集中的导入
. 正在将 OLIVE 的对象导入到 OLIVE
. 正在将 OLIVE 的对象导入到 OLIVE
. . 正在导入表                             "T"导入了        7102 行
IMP-00033: 警告: 在导出文件中未找到表 ";"
成功终止导入, 但出现警告。C:\Documents and Settings\Administrator.XY>sqlplus olive/oliveSQL*Plus: Release 10.2.0.1.0 - Production on 星期五 1月 26 13:53:58 2007Copyright (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 optionsSQL> select count(*) from t;  COUNT(*)
----------
      7102SQL>二、通过备份进行修复被损坏的块,blockrecover1、数据总计7102条
C:\Documents and Settings\Administrator.XY>sqlplus olive/oliveSQL*Plus: Release 10.2.0.1.0 - Production on 星期五 1月 26 13:53:58 2007Copyright (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 optionsSQL> select count(*) from t;  COUNT(*)
----------
      7102SQL>
人为损坏数据块
alert.logHex dump of (file 6, block 71) in trace file d:\oracle\product\10.2.0\admin\orcl\udump\orcl_ora_8336.trc
Corrupt block relative dba: 0x01800047 (file 6, block 71)
Bad check value found during buffer read
Data in bad block:
 type: 6 format: 2 rdba: 0x01800047
 last change scn: 0x0000.0009e8ba seq: 0x1 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0xe8ba0601
 check value in block header: 0x725b
 computed block checksum: 0xab79SQL> select count(*) from t;
select count(*) from t
                     *
第 1 行出现错误:
ORA-01578: ORACLE 数据块损坏 (文件号 6, 块号 71)
ORA-01110: 数据文件 6: 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\BLOCK.DBF'
SQL>使用rman检验数据文件
RMAN> backup validate datafile 6;启动 backup 于 26-1月 -07
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=142 devtype=DISK
通道 ORA_DISK_1: 启动全部数据文件备份集
通道 ORA_DISK_1: 正在指定备份集中的数据文件
输入数据文件 fno=00006 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\BLOCK.DBF
通道 ORA_DISK_1: 备份集已完成, 经过时间:00:00:03
完成 backup 于 26-1月 -07发现坏块
Hex dump of (file 6, block 71) in trace file d:\oracle\product\10.2.0\admin\orcl\udump\orcl_ora_8484.trc
Corrupt block relative dba: 0x01800047 (file 6, block 71)
Bad check value found during backing up datafile
Data in bad block:
 type: 6 format: 2 rdba: 0x01800047
 last change scn: 0x0000.0009e8ba seq: 0x1 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0xe8ba0601
 check value in block header: 0x725b
 computed block checksum: 0xab79
Reread of blocknum=71, file=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\BLOCK.DBF. found same corrupt data
Reread of blocknum=71, file=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\BLOCK.DBF. found same corrupt data
Reread of blocknum=71, file=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\BLOCK.DBF. found same corrupt data
Reread of blocknum=71, file=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\BLOCK.DBF. found same corrupt data
Reread of blocknum=71, file=D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\BLOCK.DBF. found same corrupt dataReread of rdba: 0x01800047 (file 6, block 71) found same corrupted data
只有使用rman检验数据文件发现坏块v$database_block_corruption才有数据。
SQL> select * from v$database_block_corruption where file#=6;     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
         6         71          1                  0 CHECKSUMSQL>  RMAN> blockrecover datafile 6 block 71 from backupset;启动 blockrecover 于 26-1月 -07
使用通道 ORA_DISK_1通道 ORA_DISK_1: 正在恢复块
通道 ORA_DISK_1: 正在指定要从备份集恢复的块
正在恢复数据文件 00006 的块
通道 ORA_DISK_1: 正在读取备份段 D:\FULL.BAK
通道 ORA_DISK_1: 已从备份段 1 恢复块
段句柄 = D:\FULL.BAK 标记 = 20070126
通道 ORA_DISK_1: 块恢复完成, 用时: 00:00:01正在开始介质的恢复
介质恢复完成, 用时: 00:00:08完成 blockrecover 于 26-1月 -07RMAN>
SQL> select count(*) from olive.t;  COUNT(*)
----------
      7102
SQL> select * from v$database_block_corruption where file#=6;     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
         6         71          1                  0 CHECKSUM
v$database_block_corruption中的信息只有下次执行检验数据文件后才清除呵呵,DBA 的基本知识,制造坏块的方法很多的
可以用ultraedit,也可以用dd命令
同时也呆以用orapatch工具
$orapatch open tools001.dbf write
patch>set hex --要用十六进制
patch>display 177 --orapatch以512字节为工作模式,假定想破坏第11个block即为:8k/512*11+1(file header)
patch>find 00400003 --选一个要编辑的点
patch>modify 00400002 --破坏
patch>exit