Oracle學(xué)習(xí)之RMAN(十三)恢復(fù)實(shí)戰(zhàn)--數(shù)據(jù)塊修復(fù)

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

創(chuàng)新互聯(lián)基于成都重慶香港及美國(guó)等地區(qū)分布式IDC機(jī)房數(shù)據(jù)中心構(gòu)建的電信大帶寬,聯(lián)通大帶寬,移動(dòng)大帶寬,多線BGP大帶寬租用,是為眾多客戶提供專業(yè)服務(wù)器托管報(bào)價(jià),主機(jī)托管價(jià)格性價(jià)比高,為金融證券行業(yè)西云機(jī)房,ai人工智能服務(wù)器托管提供bgp線路100M獨(dú)享,G口帶寬及機(jī)柜租用的專業(yè)成都idc公司。

 1. 創(chuàng)建一個(gè)表空間,大小小一點(diǎn)。

SQL> conn / as sysdba
Connected.
SQL> create tablespace tbs_blkerr datafile '/u01/app/oracle/oradata/devdb/blkerr01.dbf' size 128K;

Tablespace created.

 2. 在這個(gè)表空間上創(chuàng)建一個(gè)表,并且裝滿數(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:12

4. 使用vi編輯數(shù)據(jù)文件blkerr01.dbf,對(duì)文件尾部做稍微的修改

  

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時(shí),沒有關(guān)閉數(shù)據(jù)庫(kù))我們先恢復(fù)數(shù)據(jù)文件。再次編輯文件。

此實(shí)驗(yàn)始終沒有做成功,后續(xù)有時(shí)間再研究。

恢復(fù)的方法如下:

RMAN TARGET / 
BLOCKRECOVER DATAFILE 12 BLOCK 12;

當(dāng)前標(biāo)題:Oracle學(xué)習(xí)之RMAN(十三)恢復(fù)實(shí)戰(zhàn)--數(shù)據(jù)塊修復(fù)
文章出自:http://www.muchs.cn/article44/pdhghe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站收錄、網(wǎng)站設(shè)計(jì)、全網(wǎng)營(yíng)銷推廣網(wǎng)站改版、云服務(wù)器

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁(yè)設(shè)計(jì)