如何使用 rman 识别数据库中损坏的段。 解决方法: 步骤1:识别坏块 执行下面的 rman 命令,使所有的坏块信息被记录在 v$databas
如何使用 rman 识别数据库中损坏的段。
解决方法:
步骤1:识别坏块
执行下面的 rman 命令,使所有的坏块信息被记录在 v$database_block_corruption 视图中:
rman> backup validate check logical database;
注意:
这个命令只是检查数据库的坏块,而不会真正进行备份。从 11g 开始可以省略 backup 子句,而直接使用命令validate check logical database。
如果由于缺失文件导致命令失败,可以增加 'skip inaccessible' 子句来避免这个问题。
为了加快检查速度,可以设置 parallelism 指定多个通道:
rman> configure device type disk parallelism 4;
rman> backup validate check logical database;
or
rman> run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
backup validate check logical database;
}
输出
坏块信息会被记录在视图 v$database_block_corruption 中。11g rman 会生成一个 trace 文件,详细描述坏块信息:
rman validate 屏幕输出:
file status marked corrupt empty blocks blocks examined high scn
---- ------ -------------- ------------ --------------- ----------
6 failed 0 501 640 1950088
file name: /oracle/dbs/users.dbf
block type blocks failing blocks processed
---------- -------------- ----------------
data 9 9
index 0 0
other 0 130
validate found one or more corrupt blocks
see trace file /oracle/log/diag/rdbms/orcl/orcl/trace/orcl_ora_28424.trc for details
finished validate at
trace 文件输出坏块信息,这个例子描述了 2 个坏块,一个物理坏块(file 6 block 9)和一个逻辑坏块(file 6 block 10):
corrupt block relative dba: 0x01000009 (file 4, block 9)
bad check value found during validation
data in bad block:
type: 16 format: 2 rdba: 0x01000009
last change scn: 0x0000.00000000 seq: 0xff flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x000010ff
check value in block header: 0xb4e0
computed block checksum: 0xa800
reread of blocknum=9, file=/oracle/dbs/users.dbf found same corrupt data
block checking: dba = 25165834, block type = ktb-managed data block
data header at 0x2b2deb49e07c
kdbchk: fsbo(144) wrong, (hsz 78)
error backing up file 6, block 10: logical corruption
坏块信息记录在视图 v$database_block_corruption 中:
sql> select * from v$database_block_corruption;
file# block# blocks corruption_change# corruptio
--------------- --------------- --------------- ------------------ ---------
6 10 1 8183236781662 logical
6 42 1 0 fractured
6 34 2 0 checksum
6 50 1 8183236781952 logical
6 26 4 0 fractured
5 rows selected.
注意:
•check logical 选项既会检查物理坏块也会检查逻辑坏块。
• 当发现逻辑坏块,alert 日志会更新以下的信息:
error backing up file , block : logical corruption
在 11g 会生成一个 trace 文件,描述坏块信息。
• 当发现物理坏块时,alert 日志也会更新下面的信息:
corrupt block relative dba: 0x01000009 (file 4, block 9)
bad check value found during validation
data in bad block:
type: 16 format: 2 rdba: 0x01000009
last change scn: 0x0000.00000000 seq: 0xff flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x000010ff
check value in block header: 0xb4e0
computed block checksum: 0xa800
reread of blocknum=9, file=/oracle/dbs/users.dbf found same corrupt data
•检查单独一个数据文件或者特定的数据文件,使用命令check logical validate datafile 1, 2。
• 监控 validate 命令运行的进度,请运行下面的查询: