> testing corruption
> EOF
0+1 records in
0+1 records out
19 bytes (19 B) copied, 0.000231208 s, 82.2 kB/s
ทำการ Flush Buffer Cache
SQL>
alter system flush buffer_cache ;
ทำการ Connect Database ด้วย User Corrupt
SQL>
connect corrupt/corrupt ;
ทำการ Query Data ใน Table Employee จะเห็นว่า Oracle Error
SQL>
select count(*) from emp ;
select count(*) from emp
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 131)
ORA-01110: data file 6: '/u01/app/oracle/oradata/ORCL/corrupt.dbfcode
Solution 1
ทำการตรวจสอบด้วย Data Recovery Advisor
RMAN>
list failure ;
RMAN>
advise failure ;
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
182 HIGH OPEN 27-NOV-20 Datafile 6: '/u01/app/oracle/oradata/ORCL/corrupt.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=133 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 131 in file 6
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/orcl/ORCL/hm/reco_4277806215.hm
ทำการ Recovery Data Block
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_4277806215.hm
contents of repair script:
# block media recovery
recover datafile 6 block 131;
Do you really want to execute the above repair (enter YES or NO)? YES
executing repair script
Starting recover at 27-NOV-20
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 /u01/app/oracle/fast_recovery_area/ORCL/backupset/2020_11_27/o1_mf_nnndf_TAG20201127T154218_hw1gzc5z_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2020_11_27/o1_mf_nnndf_TAG20201127T154218_hw1gzc5z_.bkp tag=TAG20201127T154218
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