ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 使用rman恢复坏块(2)

使用rman恢复坏块(2)

原创 Linux操作系统 作者:lsq_008 时间:2012-07-30 12:48:00 0 删除 编辑
如果有大量数据块损坏,那么又该如何修复呢?

1. 通过ue修改大量数据块,模拟数据块损坏:

2.用dbv检查数据文件

[oracle@rhel mbs]$  dbv file=users01.dbf blocksize=8192

DBVERIFY: Release 10.2.0.1.0 - Production on Wed Jul 18 13:39:46 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

DBVERIFY - Verification starting : FILE = users01.dbf
Page 2127 is marked corrupt
Corrupt block relative dba: 0x00c0084f (file 3, block 2127)
Bad check value found during dbv: 
Data in bad block:
 type: 6 format: 2 rdba: 0x00c0084f
 last change scn: 0x0000.00061a0f seq: 0x1 flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x1a0f0601
 check value in block header: 0x44e3
 computed block checksum: 0x1c50

Page 5278 is marked corrupt
Corrupt block relative dba: 0x00c0149e (file 3, block 5278)
Bad check value found during dbv: 
Data in bad block:
 type: 6 format: 2 rdba: 0x00c0149e
 last change scn: 0x0000.00061a1c seq: 0x1 flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x1a1c0601
 check value in block header: 0xde1f
 computed block checksum: 0x2310

Page 5279 is marked corrupt
Corrupt block relative dba: 0x00c0149f (file 3, block 5279)
Bad check value found during dbv: 
Data in bad block:
 type: 6 format: 2 rdba: 0x00c0149f
 last change scn: 0x0000.00061a1c seq: 0x1 flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x1a1c0601
 check value in block header: 0xa0c3
 computed block checksum: 0x4500

Page 5650 is marked corrupt
Corrupt block relative dba: 0x00c01612 (file 3, block 5650)
Bad check value found during dbv: 
Data in bad block:
 type: 6 format: 2 rdba: 0x00c01612
 last change scn: 0x0000.00061a1e seq: 0x1 flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x1a1e0601
 check value in block header: 0x5165
 computed block checksum: 0x3919

Page 6906 is marked corrupt
Corrupt block relative dba: 0x00c01afa (file 3, block 6906)
Bad check value found during dbv: 
Data in bad block:
 type: 6 format: 2 rdba: 0x00c01afa
 last change scn: 0x0000.00061a22 seq: 0x1 flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x1a220601
 check value in block header: 0xf383
 computed block checksum: 0x3723

Page 7572 is marked corrupt
Corrupt block relative dba: 0x00c01d94 (file 3, block 7572)
Bad check value found during dbv: 
Data in bad block:
 type: 6 format: 2 rdba: 0x00c01d94
 last change scn: 0x0000.00061a26 seq: 0x1 flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x1a260601
 check value in block header: 0x9b44
 computed block checksum: 0x5076

Page 8777 is marked corrupt
Corrupt block relative dba: 0x00c02249 (file 3, block 8777)
Bad check value found during dbv: 
Data in bad block:
 type: 6 format: 2 rdba: 0x00c02249
 last change scn: 0x0000.00061a2a seq: 0x1 flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x1a2a0601
 check value in block header: 0x2008
 computed block checksum: 0x320



DBVERIFY - Verification complete

Total Pages Examined         : 12800
Total Pages Processed (Data) : 10087
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 11
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 2695
Total Pages Marked Corrupt   : 7
Total Pages Influx           : 0
Highest block SCN            : 399919 (0.399919)

可见,共有7个数据块损坏。

3.通过rman来检查有哪些数据块损坏

RMAN> backup validate database;

Starting backup at 18-JUL-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=144 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/home/db/oracle/oradata/mbs/MBS/datafile/o1_mf_system_80bnvf2j_.dbf
input datafile fno=00002 name=/home/db/oracle/oradata/mbs/MBS/datafile/o1_mf_undotbs1_80bnvm5g_.dbf
input datafile fno=00003 name=/home/db/oracle/oradata/mbs/MBS/datafile/o1_mf_sysaux_80bnvnr8_.dbf
input datafile fno=00004 name=/home/db/oracle/oradata/mbs/users01.dbf
input datafile fno=00005 name=/home/db/oracle/oradata/mbs/users02.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 18-JUL-12

RMAN> exit

SQL> select * from v$database_block_corruption;

     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
         4       5650          1                  0 CHECKSUM
         4       6906          1                  0 CHECKSUM
         4       2127          1                  0 CHECKSUM
         4       8777          1                  0 CHECKSUM
         4       7572          1                  0 CHECKSUM
         4       5278          2                  0 CHECKSUM

也可以通过视图V$BACKUP_CORRUPTION来查询曾经有哪些坏块:
SQL> select * from V$BACKUP_CORRUPTION;

     RECID      STAMP  SET_STAMP  SET_COUNT     PIECE#      FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# MAR CORRUPTIO
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------------------ --- ---------
         1  788964343  788964338          3          1          5        321          1                  0 YES CHECKSUM
         2  788965956  788965953         13          1          5        183          1                  0 YES CHECKSUM
         3  788967874  788967871         15          1          4       2127          1                  0 YES CHECKSUM
         4  788967874  788967871         15          1          4       5278          2                  0 YES CHECKSUM
         5  788967874  788967871         15          1          4       5650          1                  0 YES CHECKSUM
         6  788967874  788967871         15          1          4       6906          1                  0 YES CHECKSUM
         7  788967874  788967871         15          1          4       7572          1                  0 YES CHECKSUM
         8  788967874  788967871         15          1          4       8777          1                  0 YES CHECKSUM

8 rows selected.

4. 使用RMAN将所有的坏块修复

RMAN> BLOCKRECOVER CORRUPTION LIST;

Starting blockrecover at 18-JUL-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece /home/db/oracle/recovery/MBS/backupset/2012_07_18/o1_mf_nnndf_TAG20120718T130004_80djpnlt_.bkp
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/home/db/oracle/recovery/MBS/backupset/2012_07_18/o1_mf_nnndf_TAG20120718T130004_80djpnlt_.bkp tag=TAG20120718T130004
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01

starting media recovery
media recovery complete, elapsed time: 00:00:03

Finished blockrecover at 18-JUL-12

5.再次用DBV检查数据文件
[oracle@rhel mbs]$  dbv file=users01.dbf blocksize=8192

DBVERIFY: Release 10.2.0.1.0 - Production on Wed Jul 18 13:49:54 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

DBVERIFY - Verification starting : FILE = users01.dbf


DBVERIFY - Verification complete

Total Pages Examined         : 12800
Total Pages Processed (Data) : 10094
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 11
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 2695
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Highest block SCN            : 399919 (0.399919)

可见,所有的坏块都已经被修复。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10972173/viewspace-738651/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: ASM的配置与管理
请登录后发表评论 登录
全部评论
十余年大型金融及电信系统数据库管理经验,曾服务于中国建设银行、中国移动。对oracle,mysql数据库有深入了解。 擅长python开发,独立开发了开源数据库自动化监控运维平台Power Monitor。

注册时间:2008-02-29

  • 博文量
    335
  • 访问量
    1369110