【rman 備份與恢復】恢復丟失所有的控制檔案

楊奇龍發表於2010-08-07

1  建表,實驗資料。。

SQL> conn yang/yang
已連線。
SQL> create table test (int number);
表已建立。
SQL> insert into test values (1);
已建立 1 行。
SQL> insert into test values (2);
已建立 1 行。
SQL> insert into test values (3);
已建立 1 行。
SQL> insert into test values (4);
已建立 1 行。
SQL> commit;
提交完成。
SQL> select * from test;
       INT
----------
         1
         2
         3
         4
SQL> shutdown immediate
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。

2 模擬 控制檔案丟失。
SQL> host del f:\oracl\oradata\orcl\*.ctl;
SQL> exit;
從 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 斷開

3 使用rman 恢復

   1 rman target /
   2 一定要 startup nomount
   3 restore controlfile from ‘備份的控制檔案的路徑’
   4 sql 'alter database mount'
   5 RESTORE DATABASE
   6 recover database
   7 sql'alter database open resetlogs’


 4  驗證
C:\Documents and Settings\Administrator>sqlplus yang/yang
SQL*Plus: Release 11.1.0.6.0 - Production on 星期六 8月 7 23:19:22 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.

連線到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from test;

       INT
----------
         1
         2
         3
         4


成功。。。

小結:

  1.rman恢復控制檔案,要在DB startup  nomount之後才行。
   2.為什麼要set dbid=.....?
    因為目標資料庫控制檔案丟失,在此處必須指定dbid 需要找到目標資料庫。
   3.restore controlfile from autobackup;
    語句需要配置自動控制檔案備份開啟才行:
    configure controlfile autobackup on.
    如果以前修改過AUTOBACKUP的格式和路徑,那麼在恢復之前需要進行重新設      置指明自動備份所在路徑。也可以說使用命令
   restore controlfile from 'f:\backup\CTL_0ILKPB59_1_1.BAK';
   類似命令來手動指定控制檔案備份源。
   4.為什麼使用alter database open resetlogs啟動資料庫?
     由於使用備份的控制檔案恢復,該檔案內不包含目標資料庫redologs和資料文頭部scn資訊,所以必須透過resetlogs方式open

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-670499/,如需轉載,請註明出處,否則將追究法律責任。

相關文章