无RMAN备份集情况下的坏块恢复(四)

2015-01-21 12:22:22 · 作者: · 浏览: 26
-- ----------- ----------- ----------
286? ? 286? ? 1? 1? EXPIRED? ? DISK? ? ? ? /u01/app/oracle/flash_recovery_area/ORA10G/backupset/2014_11_12/o1_mf_nnndf_TAG20141112T141548_b65yrnkg_.bkp
deleted backup piece
backup piece handle=/u01/app/oracle/flash_recovery_area/ORA10G/backupset/2014_11_12/o1_mf_nnndf_TAG20141112T141548_b65yrnkg_.bkp recid=286 stamp=863446548
Deleted 1 EXPIRED objects


?



RMAN> list backup summary;


?



RMAN> list backup;


?



RMAN> exit



好了,现在数据库的RMAN备份彻底没有了,继续我们的测试:



--开启测试表空间热备份模式
SQL> alter tablespace zlm begin backup;



Tablespace altered.



SQL> select * from v$backup;



FILE# STATUS? ? ? ? ? ? ? ? CHANGE# TIME
----- ------------------ ---------- ----------
? ? 1 NOT ACTIVE? ? ? ? ? ? ? ? ? 0
? ? 2 NOT ACTIVE? ? ? ? ? ? ? ? ? 0
? ? 3 NOT ACTIVE? ? ? ? ? ? ? ? ? 0
? ? 4 NOT ACTIVE? ? ? ? ? ? ? ? ? 0
? ? 5 NOT ACTIVE? ? ? ? ? ? ? ? ? 0
? ? 6 ACTIVE? ? ? ? ? ? ? ? 1317685 2014-11-26



6 rows selected.



此时可以看到,开启热备模式以后,6号文件的状态从NOT ACTIVE变成了ACTIVE



SQL> select name,checkpoint_change# from v$datafile;



NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CHECKPOINT_CHANGE#
--------------------------------------------- ------------------
/u01/app/oracle/oradata/ora10g/system01.dbf? ? ? ? ? ? ? 1306748
/u01/app/oracle/oradata/ora10g/undotbs01.dbf? ? ? ? ? ? 1306748
/u01/app/oracle/oradata/ora10g/sysaux01.dbf? ? ? ? ? ? ? 1306748
/u01/app/oracle/oradata/ora10g/users01.dbf? ? ? ? ? ? ? 1306748
/u01/app/oracle/oradata/ora10g/example01.dbf? ? ? ? ? ? 1306748
/u01/app/oracle/oradata/ora10g/zlm01.dbf? ? ? ? ? ? ? ? 1319387



6 rows selected.



SCN也比其他文件的要大,因为相当于对6号文件单独进行存档了,只不过SCN还没有写进数据文件头,这个时候这个数据文件是废的,要保持一致性,必须要依靠归档来实现



--OS级别热备份6号数据文件
SQL> !cp $ORACLE_BASE/oradata/zlm01.dbf /u01/zlm01_bak.dbf
cp: cannot stat `/u01/app/oracle/oradata/zlm01.dbf': No such file or directory



SQL> !cp $ORACLE_BASE/oradata/ora10g/zlm01.dbf /u01/zlm01_bak.dbf



--关闭热备模式
SQL> alter tablespace zlm end backup;



Tablespace altered.


?



SQL> select * from v$backup;



? ? FILE# STATUS? ? ? ? ? ? ? ? CHANGE# TIME
---------- ------------------ ---------- ----------
? ? ? ? 1 NOT ACTIVE? ? ? ? ? ? ? ? ? 0
? ? ? ? 2 NOT ACTIVE? ? ? ? ? ? ? ? ? 0
? ? ? ? 3 NOT ACTIVE? ? ? ? ? ? ? ? ? 0
? ? ? ? 4 NOT ACTIVE? ? ? ? ? ? ? ? ? 0
? ? ? ? 5 NOT ACTIVE? ? ? ? ? ? ? ? ? 0
? ? ? ? 6 NOT ACTIVE? ? ? ? ? ? 1319387 2014-11-26



6 rows selected.



现在6号文件的状态又变回了NOT ACTIVE,说明热备结束了



SQL> select name,checkpoint_change# from v$datafile;



NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CHECKPOINT_CHANGE#
--------------------------------------------- ------------------
/u01/app/oracle/oradata/ora10g/system01.dbf? ? ? ? ? ? ? 1306748
/u01/app/oracle/oradata/ora10g/undotbs01.dbf? ? ? ? ? ? 1306748
/u01/app/oracle/oradata/ora10g/sysaux01.dbf? ? ? ? ? ? ? 1306748
/u01/app/oracle/oradata/ora10g/users01.dbf? ? ? ? ? ? ? 1306748
/u01/app/oracle/oradata/ora10g/example01.dbf? ? ? ? ? ? 1306748
/u01/app/oracle/oradata/ora10g/zlm01.dbf? ? ? ? ? ? ? ? 1319387



6 rows selected.



数据文件的SCN依然是之前的,还没有变化



SQL> select header_block from dba_segments where segment_name='CORRUPT_TEST';


?


HEADER_BLOCK
------------
? ? ? ? ? 11



通过dba_segments视图,得知6号文件的段头块是11



--模拟出现坏块
SQL> !
[oracle@ora10g backupsets]$ dd of=/u01/app/oracle/oradata/ora10g/zlm01.dbf bs=8192 conv=notrunc seek=12 <> corruption
> EOF
0+1 records in
0+1 records out
11 bytes (11 B) copied, 0.000168204 seconds, 65.4 kB/s



seek=12表示跳过12个block开始写入,因为我不想破坏段头块,只是在文件尾部写了废数据“corruption”,那么这个块就会标识为逻辑坏块



[oracle@ora10g backupsets]$ sqlplus /nolog



SQL*Plus: Release 10.2.0.1.0 - Production on 16 15:52:41 2014



Copyright (c) 1982, 200