RMAN修复坏块试验

本帖最后由 kevin.zhang 于 2010-11-4 16:06 编辑

Project Leader让做了几个试验, 并记录下来,整理成公司内交流文档。先发来分享下!
In this training we will damage a block and learn how to fix it with RMAN in 11g version.
Before this experiment begin, make sure that you already have a full database backupset as well as all archivelogs from backupset timepoint to now, cause they will be required by RMAN when RMAN repairs a corrupted block.


1.Create test table t2 ;
duck_11 > create table t2 tablespace DB_USERS as select object_id from DBA_objects;
duck_11 > select dbms_rowid.rowid_relative_fno(rowid) file_id,dbms_rowid.rowid_block_number(rowid) from t2 where rownum=1;

FILE_ID DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
---------- ------------------------------------
6              187
duck_11 > select NAME from v$datafile where file#=6;
NAME
--------------------------------------------------------------------------------
/duckdb/oracle/duck_11/data/db_users02.dbf

2.Modify block 187 through BBED tool.
a)Cause oracle don't provide bbed lib files in11g, you need to copy then from10g directories.
cp $ORA10g_HOME/rdbms/lib/ssbbded.o  $ORA11g_HOME/rdbms/lib
cp $ORA10g_HOME/rdbms/lib/sbbdpt.o  $ORA11g_HOME/rdbms/lib
cp $ORA10g_HOME/rdbms/mesg/bbedus.msb   $ORA11g_HOME/rdbms/mesg
cp $ORA10g_HOME/rdbms/mesg/bbedus.msg    $ORA11g_HOME/rdbms/mesg
cp $ORA10g_HOME/rdbms/mesg/bbedar.msb    $ORA11g_HOME/rdbms/mesg
b)Link BBED
oracle $    make  -f     ins_rdbms.mk    $ORACLE_HOME/rdbms/lib/bbed
c)Configure BBED parameter file.
oracle $    vi      filelist.txt
6 /duckdb/oracle/duck_11/data/db_users02.dbf 104865792
oracle $    vi      par.bbd
blocksize=8192 listfile=filelist.txt mode=edit
d)Damage target block using BBED. The default password for BBED is "blockedit" .
oracle $    ./bbed     parfile=par.bbd

BBED>    modify 0 block 187

(Note:You can prove that the block was already corrupted by press:  )
BBED>     verify

(Note: or you can use dbv command in os.  )
oracle $ dbv file= /duckdb/oracle/duck_11/data/db_users02.dbf blocksize=8192


3.Check the data in target database.
duck_11 > Shutdown immediate
duck_11 > startup
duck_11 > select count(*) from t2;
select count(*) from t2
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 187)
ORA-01110: data file 6: '/duckdb/oracle/duck_11/data/db_users02.dbf'


4.Recover the corrupted block using rman
oracle $ rman target /
RMAN> blockrecover datafile 6 block 187;


5.Now check wheather the table t2 in the database is correct now.Check it yourself.
标签: 暂无标签
kevin.zhang

写了 32 篇文章,拥有财富 308,被 10 人关注

转播转播 分享分享 分享淘帖
回复

使用道具

P6 | 发表于 2010-11-4 16:06:36
这个实验有一些缺陷,在实际的工作中,坏一个块的情况比较少,有可能同时坏多个。
因此重点就是:如何定位一批的坏块,如何同时进行一次性的修复。
例如,面对一次坏了2000个数据块。
总之是不错,继续努力。
回复

使用道具

P4 | 发表于 2010-11-4 17:04:26
定位坏快比较简单,dbv命令即可:
oracle $ dbv file= /duckdb/oracle/duck_11/data/db_users02.dbf blocksize=8192

DBVERIFY: Release 11.2.0.1.0 - Production on Thu Nov 4 02:46:14 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = /duckdb/oracle/duck_11/data/db_users02.dbf
Page 187 is marked corrupt
Corrupt block relative dba: 0x018000bb (file 6, block 187)
Bad check value found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x018000bb
last change scn: 0x0000.01b40593 seq: 0x1 flg: 0x04
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x05930601
check value in block header: 0x6247
computed block checksum: 0xf506



DBVERIFY - Verification complete

Total Pages Examined         : 12800
Total Pages Processed (Data) : 274
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 93
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 12337
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 95
Total Pages Marked Corrupt   : 1
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 28834302 (0.28834302)

oracle@cfserver01.softtek.com [duck_11] /oracle

但是如果坏块很多,那该怎么恢复?还是要一个坏块一个坏快用rman恢复吗?
或者直接offline datafile,然后用rman restore + recover datafile ?
回复

使用道具

P6 | 发表于 2010-11-8 16:20:29
看我的课件,里面写的很清楚。
在备份恢复章节。
回复

使用道具

P4 | 发表于 2013-8-22 09:47:43
谢谢分享!可以学习!
回复

使用道具

您需要登录后才可以回帖 登录 | 加入社区

本版积分规则

意见
反馈