在很多情況下,數(shù)據(jù)庫只是某個數(shù)據(jù)文件的些許數(shù)據(jù)塊發(fā)生損壞。這種情況,我們當然可是使用數(shù)據(jù)庫恢復或者數(shù)據(jù)文件恢復的方式來解決問題。但是有點高射炮打蚊子的感覺。幸好RMAN提供了塊級別的恢復。下面我們來演示一下。

1. 創(chuàng)建一個表空間,大小小一點。
SQL> conn / as sysdba Connected. SQL> create tablespace tbs_blkerr datafile '/u01/app/oracle/oradata/devdb/blkerr01.dbf' size 128K; Tablespace created.2. 在這個表空間上創(chuàng)建一個表,并且裝滿數(shù)據(jù)。
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. 備份該表空間或者數(shù)據(jù)文件。
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:124. 使用vi編輯數(shù)據(jù)文件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此次修改破壞了文件的頭部,發(fā)生了意外。(也可能是編輯datafile時,沒有關(guān)閉數(shù)據(jù)庫)我們先恢復數(shù)據(jù)文件。再次編輯文件。
此實驗始終沒有做成功,后續(xù)有時間再研究。
恢復的方法如下:
RMAN TARGET / BLOCKRECOVER DATAFILE 12 BLOCK 12;另外有需要云服務器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
網(wǎng)頁題目:Oracle學習之RMAN(十三)恢復實戰(zhàn)--數(shù)據(jù)塊修復-創(chuàng)新互聯(lián)
URL鏈接:http://chinadenli.net/article4/dhoeie.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供電子商務、網(wǎng)站制作、標簽優(yōu)化、網(wǎng)站改版、網(wǎng)站建設、面包屑導航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容