dd of=/oradata/orcl/users01.dbf bs=8192 conv=notrunc seek=157 <<EOF Corrupt me! 0+1 records in 0+1 records out 12 bytes (12 B) copied, 0.0145481 s, 0.8 kB/s [oracle@prim scripts]$ [oracle@prim scripts]$ dd of=/oradata/orcl/users01.dbf bs=8192 conv=notrunc seek=157 <<EOF > Corrupt me! > EOF 0+1 records in 0+1 records out 12 bytes (12 B) copied, 0.00138089 s, 8.7 kB/s [oracle@prim scripts]$ [oracle@prim scripts]$ [oracle@prim scripts]$ dd of=/oradata/orcl/users01.dbf bs=8192 conv=notrunc seek=159 <<EOF > Corrupt me! > EOF 0+1 records in 0+1 records out 12 bytes (12 B) copied, 0.00227023 s, 5.3 kB/s
2.查询有坏块的表 SQL> select * from scott.TESTC; select * from scott.TESTC * ERROR at line 1: ORA-01578: ORACLE data block corrupted (file # 4, block # 155) ORA-01110: data file 4: ‘/oradata/orcl/users01.dbf‘
3.RMAN 利用 DRA 修复坏块
[oracle@prim scripts]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jul 2 11:21:04 2020
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1570665551)
RMAN> validate datafile 4;
Starting validate at 02-JUL-20 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=24 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=400 device type=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: SID=25 device type=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: SID=405 device type=DISK channel ORA_DISK_1: starting validation of datafile channel ORA_DISK_1: specifying datafile(s) for validation input datafile file number=00004 name=/oradata/orcl/users01.dbf channel ORA_DISK_1: validation complete, elapsed time: 00:00:07 List of Datafiles ================= File Status Marked Corrupt Empty Blocks Blocks Examined High SCN ---- ------ -------------- ------------ --------------- ---------- 4 FAILED 0 37031 46597 2127979 File Name: /oradata/orcl/users01.dbf Block Type Blocks Failing Blocks Processed ---------- -------------- ---------------- Data 0 5819 Index 0 912 Other 3 2798
validate found one or more corrupt blocks See trace file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_27968.trc for details Finished validate at 02-JUL-20
RMAN> list failure;
List of Database Failures =========================
Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 622 HIGH OPEN 02-JUL-20 Datafile 4: ‘/oradata/orcl/users01.dbf‘ contains one or more corrupt blocks
RMAN> advise failure;
List of Database Failures =========================
Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 622 HIGH OPEN 02-JUL-20 Datafile 4: ‘/oradata/orcl/users01.dbf‘ contains one or more corrupt blocks
analyzing automatic repair options; this may take some time using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 analyzing automatic repair options complete
Mandatory Manual Actions ======================== no manual actions available
Optional Manual Actions ======================= 1. Shut down, mount the database and try flush redo using ALTER SYSTEM FLUSH REDO TO ‘standby name‘ command. Then perform a Data Guard role change (failover). Available standbys: orcl_std.
Automated Repair Options ======================== Option Repair Description ------ ------------------ 1 Recover multiple corrupt blocks in datafile 4 Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2285196485.hm
RMAN> repair failure;
Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2285196485.hm
contents of repair script: # block media recovery for multiple blocks recover datafile 4 block 155, 157, 159;
Do you really want to execute the above repair (enter YES or NO)? yes executing repair script
Starting recover at 02-JUL-20 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 searching flashback logs for block images until SCN 2123598 finished flashback log search, restored 3 blocks
starting media recovery media recovery complete, elapsed time: 00:00:01
Finished recover at 02-JUL-20 repair failure complete
4.验证坏块修复后的结果:
RMAN> validate datafile 4;
Starting validate at 02-JUL-20 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 channel ORA_DISK_1: starting validation of datafile channel ORA_DISK_1: specifying datafile(s) for validation input datafile file number=00004 name=/oradata/orcl/users01.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 ---- ------ -------------- ------------ --------------- ---------- 4 OK 0 37031 46597 2128902 File Name: /oradata/orcl/users01.dbf Block Type Blocks Failing Blocks Processed ---------- -------------- ---------------- Data 0 5822 Index 0 912 Other 0 2795