概述
数据块的故障很少见,一般是因为磁盘IO引起的,如果数量块坏块少可以执行恢复数据块的恢复,如果量大则就用数据文件或者表空间的恢复。在运行backup validate、或者backup validate命令时会进行坏块的检查。
检查数据文件和备份文件坏块的命令
validate (仅仅支持11G和更高版本,低版本用下面两个)
backup …validate
restore …validate
validate
摘录一段《深入理解ORACLE 12C 数据库管理》中的一段原文:
Using VALIDATE
The VALIDATE command can be used stand-alone to check for missing files or physical corruption in database data files, archive redo log files, control files, spfiles, and backup set pieces.
#validate all data files and the control files:
RMAN> validate database;
#You can also validate just the control file, as follows:
RMAN> validate current controlfile;
#You can validate the archive redo log files, like so:
RMAN> validate archivelog all;
#You may want to combine all the prior integrity checks into one command, as shown:
RMAN> validate database include current controlfile plus archivelog;
#Under normal conditions the VALIDATE command only checks for physical corruption. You can specify that you also want to check for logical corruption by using the CHECK LOGICAL clause:
RMAN> validate check logical database include current controlfile plus archivelog;
#VALIDATE has a variety of uses. Here are a few more examples:
RMAN> validate database skip offline;
RMAN> validate copy of database;
RMAN> validate tablespace system;
RMAN> validate datafile 3 block 20 to 30;
RMAN> validate spfile;
RMAN> validate backupset ;
RMAN> validate recovery area;
#If you’re using the Oracle Database 12c pluggable database feature, you can validate specific databases within the container. While connected as SYS to the root container, validate any associated pluggable databases:
RMAN> validate pluggable database salespdb;
#If RMAN detects any corrupt blocks, the V$DATABASE_BLOCK_CORRUPTION is populated. This view contains information on the file number, block number, and number of blocks affected. You can use this information to perform a block-level recovery .1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
关于物理坏块和逻辑坏块的解释:
physical corruption is a change to a block, such that its contents don’t match the physical format that Oracle expects. By default, rMaN checks for physical corruption when backing up, restoring, and validating data files. With logical corruption, a block is in the correct format, but the contents aren’t consistent with what Oracle expects, such as in a row piece or an index entry.1
backup …validate
这个命令和validate 命令类似,就是多个backup 开头,但是适合各种版本,不以backup开头的只能在11G及以后版本使用。列出几个常用命令。
RMAN> backup validate database;
RMAN> backup validate check logical database;
RMAN> backup validate database current controlfile;
RMAN> backup validate check logical database current controlfile plus archivelog;1
2
3
4
5
6
7
restore …validate
一般这个命令用来模拟数据库的restore,一般用来检查备份是否可以用来恢复。
RMAN> restore validate database;1
坏块的恢复
用下面的这sql来查坏块:
SQL> select * from v$database_block_corruption;
FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO CON_ID
---------- ---------- ---------- ------------------ --------- ----------
4 20 1 0 ALL ZERO 01
2
3
4
找到后用这个命令进行恢复,数据库可以在mount或者open状态下都可以:
RMAN> recover corruption list;1
2
也可指定恢复,一般推荐前者,可以自动清理v$database_block_corruption视图:
RMAN> recover datafile 4 block 20;1
2
最后
以上就是优秀手链为你收集整理的oracle rman 检查坏块,RMAN实战12:ORACLE数据块坏块的检查和恢复的全部内容,希望文章能够帮你解决oracle rman 检查坏块,RMAN实战12:ORACLE数据块坏块的检查和恢复所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复