本帖最后由 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. |