Oracle數(shù)據(jù)庫(kù)RMAN恢復(fù)之表空間和數(shù)據(jù)塊介質(zhì)的恢復(fù)
之前我們介紹過:Oracle數(shù)據(jù)庫(kù)RMAN恢復(fù)之?dāng)?shù)據(jù)文件的恢復(fù)詳解,本文我們介紹一下Oracle數(shù)據(jù)庫(kù)REMAN恢復(fù)之表空間和數(shù)據(jù)塊介質(zhì)的恢復(fù),接下來我們就開始介紹一下這部分內(nèi)容,首先我們先介紹一下恢復(fù)非系統(tǒng)表空間的示例。
示例一:表空間的數(shù)據(jù)文件被誤刪除
open狀態(tài)下刪除表空間對(duì)應(yīng)的所有數(shù)據(jù)文件。
在open狀態(tài)下使用alter tablespace ... offline for recover 脫機(jī)表空間。
使用restore tablespace ...轉(zhuǎn)儲(chǔ)表空間所有的數(shù)據(jù)文件。
使用recover tablespace ...應(yīng)用歸檔日志。
最后使用alter tablespace ... online使表空間聯(lián)機(jī)。
--open狀態(tài)下刪除表空間對(duì)應(yīng)的所有數(shù)據(jù)文件。
[oracle@localhost ~]$ rm /oracle/10g/oracle/product/10.2.0/oradatabak/users01.dbf;
--恢復(fù)表空間
- [oracle@localhost ~]$ rman target sys/oracle@oralife nocatalog
 - RMAN> run {
 - 2> sql 'alter tablespace users offline for recover';
 - 3> restore tablespace users;
 - 4> recover tablespace users;
 - 5> sql 'alter tablespace users online';
 - 6> }
 
示例二:表空間的數(shù)據(jù)文件所在磁盤出現(xiàn)故障
open狀態(tài)下刪除表空間對(duì)應(yīng)的所有數(shù)據(jù)文件。
在open狀態(tài)下使用alter tablespace ... offline for recover 脫機(jī)表空間。
執(zhí)行set newname為數(shù)據(jù)文件指定新的位置。
使用restore tablespace ...轉(zhuǎn)儲(chǔ)表空間所有的數(shù)據(jù)文件。
執(zhí)行switch datafile改變控制文件中數(shù)據(jù)文件位置和名稱。
使用recover tablespace ...應(yīng)用歸檔日志。
最后使用alter tablespace ... online使表空間聯(lián)機(jī)。
--open狀態(tài)下刪除表空間對(duì)應(yīng)的所有數(shù)據(jù)文件。
- [oracle@localhost ~]$ rm /oracle/10g/oracle/product/10.2.0/oradatabak/users01.dbf;
 - SQL> select * from t_user;
 - select * from t_user
 - *
 - ERROR at line 1:
 - ORA-00376: file 4 cannot be read at this time
 - ORA-01110: data file 4:
 - '/oracle/10g/oracle/product/10.2.0/oradatabak/users01.dbf'
 - SQL> select file#,error from v$recover_file;
 - FILE# ERROR
 - ---------- -----------------------------------------------------------------
 - 4 FILE NOT FOUND
 - --恢復(fù)表空間
 - [oracle@localhost ~]$ rman target sys/oracle@oralife nocatalog
 - run {
 - sql 'alter tablespace users offline for recover';
 - set newname for datafile 4 to '$ORACLE_BASE/product/10.2.0/oradata/oralife/user01.dbf';
 - restore tablespace users;
 - switch datafile all;
 - recover tablespace users;
 - sql 'alter tablespace users online';
 - }
 - --已恢復(fù)
 - SQL> select * from t_user;
 - TEXT
 - --------------------
 - java_
 - SQL> select name from v$datafile where file# = 4;
 - NAME
 - --------------------------------------------------------------------------------
 - /oracle/10g/oracle/product/10.2.0/oradata/oralife/user01.dbf
 
數(shù)據(jù)塊介質(zhì)恢復(fù)
如果數(shù)據(jù)文件部分?jǐn)?shù)據(jù)塊出現(xiàn)損壞,可以使用blockrecover 命令恢復(fù)損壞數(shù)據(jù)塊。
如:
- RMAN> blockrecover device type disk
 - 2>datafile 5 block 2,7,88;
 
關(guān)于Oracle數(shù)據(jù)庫(kù)RMAN恢復(fù)之表空間和數(shù)據(jù)塊介質(zhì)的恢復(fù)方法就介紹到這里了,希望本次的介紹能夠?qū)δ兴鶐椭?/p>
【編輯推薦】
 
 
 
 














 
 
 