您好,登錄后才能下訂單哦!
在很多情況下,數據庫只是某個數據文件的些許數據塊發生損壞。這種情況,我們當然可是使用數據庫恢復或者數據文件恢復的方式來解決問題。但是有點高射炮打蚊子的感覺。幸好RMAN提供了塊級別的恢復。下面我們來演示一下。
1. 創建一個表空間,大小小一點。
SQL> conn / as sysdba Connected. SQL> create tablespace tbs_blkerr datafile '/u01/app/oracle/oradata/devdb/blkerr01.dbf' size 128K; Tablespace created.
2. 在這個表空間上創建一個表,并且裝滿數據。
SQL> create table emp_blk tablespace tbs_blkerr as select * from scott.emp; Table created. SQL> insert into emp_blk select * from scott.emp; 14 rows created. SQL> / 14 rows created. 。。。。 SQL> insert into emp_blk select * from scott.emp; insert into emp_blk select * from scott.emp * ERROR at line 1: ORA-01653: unable to extend table SYS.EMP_BLK by 8 in tablespace TBS_BLKERR SQL> commit; Commit complete. SQL> select count(*) from emp_blk; COUNT(*) ---------- 686 SQL>
3. 備份該表空間或者數據文件。
RMAN> backup datafile '/u01/app/oracle/oradata/devdb/blkerr01.dbf'; Starting backup at 2015/07/09 10:30:11 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00007 name=/u01/app/oracle/oradata/devdb/blkerr01.dbf channel ORA_DISK_1: starting piece 1 at 2015/07/09 10:30:11 channel ORA_DISK_1: finished piece 1 at 2015/07/09 10:30:12 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkp tag=TAG20150709T103011 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2015/07/09 10:30:12
4. 使用vi編輯數據文件blkerr01.dbf,對文件尾部做稍微的修改
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup ORACLE instance started. Total System Global Area 839282688 bytes Fixed Size 2233000 bytes Variable Size 553651544 bytes Database Buffers 281018368 bytes Redo Buffers 2379776 bytes Database mounted. ORA-01157: cannot identify/lock data file 7 - see DBWR trace file ORA-01110: data file 7: '/u01/app/oracle/oradata/devdb/blkerr01.dbf' RMAN> restore datafile 7; Starting restore at 2015/07/09 10:36:25 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=20 device type=DISK channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/devdb/blkerr01.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T103011_bsvq5mw9_.bkp tag=TAG20150709T103011 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 2015/07/09 10:36:27 RMAN> recover datafile 7; Starting recover at 2015/07/09 10:36:40 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:00 Finished recover at 2015/07/09 10:36:41
此次修改破壞了文件的頭部,發生了意外。(也可能是編輯datafile時,沒有關閉數據庫)我們先恢復數據文件。再次編輯文件。
此實驗始終沒有做成功,后續有時間再研究。
恢復的方法如下:
RMAN TARGET / BLOCKRECOVER DATAFILE 12 BLOCK 12;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。