repair failure修复坏块

刚刚逛论坛,看到一个网友说他dd破坏的块用repair failure修复不了,我这里也实验一把试试

测试之前先做一个备份
RMAN> backup database;
Starting backup at 12-MAR-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/opt/app/oracle/oradata/goolen/system01.dbf
input datafile file number=00002 name=/opt/app/oracle/oradata/goolen/sysaux01.dbf
input datafile file number=00003 name=/opt/app/oracle/oradata/goolen/undotbs01.dbf
input datafile file number=00006 name=/opt/app/oracle/oradata/goolen/goolen01.dbf
channel ORA_DISK_1: starting piece 1 at 12-MAR-14
channel ORA_DISK_1: finished piece 1 at 12-MAR-14
piece handle=/opt/app/oracle/product/11.2.0/dbs/1rp3029l_1_1 tag=TAG20140312T112124 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 12-MAR-14
channel ORA_DISK_1: finished piece 1 at 12-MAR-14
piece handle=/opt/app/oracle/product/11.2.0/dbs/1sp302ao_1_1 tag=TAG20140312T112124 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-MAR-14

创建一个测试表
SQL> create table scott.rcsy tablespace goolen as select empno,ename from scott.emp where rownum <=2;
Table created.

SQL> set lines 120
SQL> select owner,table_name,tablespace_name from dba_tables where owner='SCOTT' and table_name='RCSY';
OWNER                          TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
SCOTT                          RCSY                           GOOLEN

SQL> col file_name for a55
SQL> select file_name,file_id,TABLESPACE_NAME from dba_data_files where tablespace_name='GOOLEN';
FILE_NAME                                                  FILE_ID TABLESPACE_NAME
------------------------------------------------------- ---------- ------------------------------
/opt/app/oracle/oradata/goolen/goolen01.dbf                      6 GOOLEN

SQL> select dbms_rowid.ROWID_RELATIVE_FNO(rowid),dbms_rowid.rowid_block_number(rowid) block# from scott.rcsy;
DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID)     BLOCK#
------------------------------------ ----------
                                   6         51
                                   6         51
现在我们来破坏6号文件的51号块
[oracle@localhost xiaoming]$ dd if=/dev/zero of=/opt/app/oracle/oradata/goolen/goolen01.dbf count=1 seek=51 bs=8192 conv=notrunc    
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 3.9785e-05 s, 206 MB/s

SQL> select * from scott.rcsy;
     EMPNO ENAME
---------- ----------
      7369 SMITH
      7499 ALLEN

SQL> alter system flush buffer_cache;
System altered.

再次查询报错,有坏块
SQL> select * from scott.rcsy;
select * from scott.rcsy
                    *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 51)
ORA-01110: data file 6: '/opt/app/oracle/oradata/goolen/goolen01.dbf'

使用rman来恢复这个坏块
RMAN>  list failure;
using target database control file instead of recovery catalog
List of Database Failures
=========================
Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
8102       HIGH     OPEN      12-MAR-14     Datafile 6: '/opt/app/oracle/oradata/goolen/goolen01.dbf' contains one or more corrupt blocks

RMAN> advise failure;
List of Database Failures
=========================
Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
8102       HIGH     OPEN      12-MAR-14     Datafile 6: '/opt/app/oracle/oradata/goolen/goolen01.dbf' contains one or more corrupt blocks

analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK
analyzing automatic repair options complete
Mandatory Manual Actions
========================
no manual actions available
Optional Manual Actions
=======================
no manual actions available
Automated Repair Options
========================
Option Repair Description
------ ------------------
1      Perform block media recovery of block 51 in file 6  
  Strategy: The repair includes complete media recovery with no data loss
  Repair script: /opt/app/oracle/diag/rdbms/goolen/goolen/hm/reco_697173025.hm

RMAN> repair failure;
Strategy: The repair includes complete media recovery with no data loss
Repair script: /opt/app/oracle/diag/rdbms/goolen/goolen/hm/reco_697173025.hm
contents of repair script:
   # block media recovery
   recover datafile 6 block 51;
Do you really want to execute the above repair (enter YES or NO)? yes
executing repair script
Starting recover at 12-MAR-14
using channel ORA_DISK_1
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00006
channel ORA_DISK_1: reading from backup piece /opt/app/oracle/product/11.2.0/dbs/1rp3029l_1_1
channel ORA_DISK_1: piece handle=/opt/app/oracle/product/11.2.0/dbs/1rp3029l_1_1 tag=TAG20140312T112124
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 12-MAR-14
repair failure complete

RMAN> exit

Recovery Manager complete.

SQL> alter system flush buffer_cache;
System altered.

SQL> select * from scott.rcsy;
     EMPNO ENAME
---------- ----------
      7369 SMITH
      7499 ALLEN
 

可以看到我们这里的测试是可以恢复的,我估计是他之前的备份集有问题,或者恢复完后没有flush buffercache,查询还是有可能报错的



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个 Oracle 数据损坏恢复的案例,包括具体解决过程: 1. 案例背景 某企业的 Oracle 数据库出现了数据损坏的情况,导致数据库无法正常启动和运行。经过初步排查,发现是数据库的 redo log 文件损坏导致的。该企业非常重视数据的安全性和完整性,因此需要尽快恢复数据库服务,以确保业务的正常运转。 2. 解决过程 步骤一:备份数据 在进行任何操作之前,首先需要备份数据库中的数据,以便在操作失误或出现意外情况时进行恢复。同时可以将备份数据恢复到测试环境中,以便进行后续的测试和验证。 步骤二:关闭数据库 关闭数据库,以便进行后续的修复工作。同时需要备份数据库的控制文件和数据文件,以便在需要时进行恢复。 步骤三:修复 redo log 文件 采用 Oracle 提供的工具进行 redo log 文件的修复。具体操作如下: 1)使用 RMAN 命令查询损坏的 redo log 文件: RMAN> list failure; 2)标记损坏的 redo log 文件为已修复状态: RMAN> repair failure; 3)重新启动数据库并进行测试验证。 步骤四:检查数据库完整性 重新启动数据库后,需要检查数据库的完整性和一致性。可以使用 Oracle 提供的工具进行检查,例如使用 DBVERIFY 工具检查数据文件是否损坏,使用 ANALYZE 命令检查数据库的逻辑一致性等。 步骤五:恢复数据库服务 在确认数据库的完整性和一致性后,可以重新启动数据库服务,进行正常的业务操作。 3. 结论 通过以上的步骤,成功恢复了该企业的 Oracle 数据库服务。该案例也提醒用户需要采取备份和恢复措施,加强对于数据库的监控和维护,提高数据库的可用性和安全性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值