backup validate datafile 7 format '+DATA/ORCL/DATAFILE/users';
1.验证数据文件的有效性(查看是否有坏块):
RMAN> backup validate datafile 7 fomrat '+DATA/ORCL/DATAFILE/users';
2.查询v$database_block_corruption视图,得到“坏块”的具体信息
SQL> Select * from v$database_block_corruption;
FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
5 152 1 0 FRACTURED
3.使用RMAN命令修复损坏的数据库块
RMAN> blockrecover datafile 5 block 126,127;
或者
RMAN> blockrecover corruption list;
Starting recover at 30-OCT-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 00005
channel ORA_DISK_1: reading from backup piece /home/oracle/zhuo.bak
channel ORA_DISK_1: piece handle=/home/oracle/zhuo.bak tag=TAG20201030T171734
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:03
Finished recover at 30-OCT-20
恢复表
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 07/05/2023 03:56:27
ORA-01113: file 7 needs media recovery
ORA-01110: data file 7: '+DATA/ORCL/DATAFILE/users'
RMAN> recover datafile 7;
Starting recover at 2023-07-05 03:57:44
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 5 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_06_29/thread_1_seq_5.263.1140817057
archived log for thread 1 with sequence 6 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_06_29/thread_1_seq_6.259.1140818697
archived log for thread 1 with sequence 7 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_06_29/thread_1_seq_7.257.1140818727
archived log for thread 1 with sequence 8 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_07_01/thread_1_seq_8.258.1140998759
archived log for thread 1 with sequence 9 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_07_01/thread_1_seq_9.256.1141056047
archived log for thread 1 with sequence 10 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_07_02/thread_1_seq_10.261.1141110033
archived log for thread 1 with sequence 11 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_07_02/thread_1_seq_11.262.1141164523
archived log for thread 1 with sequence 12 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_07_03/thread_1_seq_12.260.1141250453
archived log for thread 1 with sequence 13 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_07_04/thread_1_seq_13.274.1141272307
archived log for thread 1 with sequence 14 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_07_05/thread_1_seq_14.275.1141347657
archived log for thread 1 with sequence 15 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_07_05/thread_1_seq_15.276.1141354829
archived log for thread 1 with sequence 16 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_07_05/thread_1_seq_16.277.1141354835
archived log for thread 1 with sequence 17 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_07_05/thread_1_seq_17.278.1141355901
archived log for thread 1 with sequence 18 is already on disk as file +ARCH/ORCL/ARCHIVELOG/2023_07_05/thread_1_seq_18.279.1141355905
archived log file name=+ARCH/ORCL/ARCHIVELOG/2023_06_29/thread_1_seq_5.263.1140817057 thread=1 sequence=5
media recovery complete, elapsed time: 00:00:01
Finished recover at 2023-07-05 03:57:47
RMAN> alter database datafile 7 online;
Statement processed