之前做好備份
SQL> conn scott/abc123
SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'; 2012-04-24 10:10:53
SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
SYSDATE
-------------------
2012-03-12 01:28:15
SQL> drop table emp;
SQL> commit;
SQL> shutdown abort;
SQL> startup mount
SQL> !rman target /
RMAN> run {
set until time "to_date('2012-04-24 10:10:53','yyyy-mm-dd hh24:mi:ss')";
restore database;
recover database;
alter database open resetlogs;
}
資料庫直接打開
scott使用者檢視emp表
==============================================
所有檔案丢失,參數檔案也丢失
RMAN> backup database;
1.删除所有檔案
[oracle@sq123 ~]$ cd /oracle/app/oradata/TEST/
[oracle@sq123 TEST]$ rm -rf *
cd /oracle/app/oracle/product/10.2.0/db_1/dbs
[oracle@sq123 dbs]$ rm -rf spfileTEST.ora
[oracle@sq123 dbs]$ rm -rf initdw.ora
SQL> startup
(失敗,找不到參數檔案)
2.[oracle@sq123 ~]$ cd /oracle/app/admin/TEST/bdump/
[oracle@sq123 bdump]$ tail -500 alert_TEST.log |more
(找到之前啟動時的參數)
processes = 150
__shared_pool_size = 79691776
__large_pool_size = 4194304
__java_pool_size = 4194304
__streams_pool_size = 0
nls_language = AMERICAN
sga_target = 285212672
control_files = /oracle/app/oradata/TEST/control01.ctl, /oracle/app/orad
ata/TEST/control02.ctl, /oracle/app/oradata/TEST/control03.ctl
db_block_size = 8192
__db_cache_size = 192937984
compatible = 10.2.0.1.0
db_file_multiblock_read_count= 16
db_recovery_file_dest = /oracle/app/flash_recovery_area
db_recovery_file_dest_size= 2147483648
undo_management = AUTO
undo_tablespace = UNDOTBS1
remote_login_passwordfile= EXCLUSIVE
db_domain =
dispatchers = (PROTOCOL=TCP) (SERVICE=TESTXDB)
job_queue_processes = 10
background_dump_dest = /oracle/app/admin/TEST/bdump
user_dump_dest = /oracle/app/admin/TEST/udump
core_dump_dest = /oracle/app/admin/TEST/cdump
audit_file_dest = /oracle/app/admin/TEST/adump
db_name = TEST
open_cursors = 300
pga_aggregate_target = 94371840
3.[oracle@sq123 ~]$ vi initnew.ora
把上面的複制過來
不要複制的行
db_domain =
4.SQL> startup nomount pfile=/home/oracle/initnew.ora
(啟動正常)
5.恢複spfile
RMAN> restore spfile from '/oracle/app/flash_recovery_area/TEST/backupset/2012_03_12/o1_mf_ncsnf_TAG20120312T003337_7oso413h_.bkp';
[oracle@sq123 ~]$ cd /oracle/app/oracle/product/10.2.0/db_1/dbs
[oracle@sq123 dbs]$ ls(spfile 已經恢複)
6.SQL> startup nomount force;(用恢複的spfile啟動)
恢複控制檔案
RMAN> restore controlfile from '/oracle/app/flash_recovery_area/TEST/backupset/2012_03_12/o1_mf_ncsnf_TAG20120312T003337_7oso413h_.bkp';
7.恢複資料檔案
RMAN> alter database mount;
RMAN> restore database;
RMAN> recover database;(報錯因為沒有日志了,但必須運作)
RMAN> alter database open resetlogs;
(資料庫正常)
測試備份是否有用
RMAN> restore database validate;
(測試不真正恢複)
[oracle@sq123 2012_03_12]$ echo "a" >>o1_mf_nnndf_TAG20120312T003337_7osnz2q6_.bkp
(模拟備份實效)
RMAN> restore database validate;(報錯)
檢視那些檔案需要備份
RMAN> report need backup;
==========================================
免除表空間
RMAN>configure exclude for tablespace user03;
RMAN>backup database;
=======================================
塊恢複
RMAN> blockrecover datafile 12 block 2718618 from backupset;
本文轉自陳繼松 51CTO部落格,原文連結:http://blog.51cto.com/chenjisong/1737394,如需轉載請自行聯系原作者