rman操作

freshairpeng發表於2009-02-25

 

建立恢復目錄

第一步,在目錄資料庫中建立恢復目錄所用表空間:

SQL> create tablespace rman_ts datafile 'E:\ora10g\ora10gdata\pskdb\rman_ts.dbf' size 20M;

表空間已建立。

第二步,在目錄資料庫中建立RMAN 使用者並授權:

SQL> create user rman identified by rman default tablespace rman_ts temporary

  tablespace temp quota unlimited on rman_ts;

 

SQL> grant recovery_catalog_owner to rman;

 

SQL> grant connect, resource to rman;

第三步,在目錄資料庫中建立恢復目錄

 

C:\> rman target sys/stephen@pskDB catalog rman/rman@pskDB –連線到目的資料庫跟恢復資料庫

 

RMAN>create catalog tablespace rman_ts  --建立目錄成功

 

register database  --註冊恢復資料庫

resync catalog  --同步全部恢復目錄

第四步,通過rman進行相關備份的操作

Rman>show all;---- 顯示所有的rman 引數設定

Rman>configure controlfile autobackup on;---更改相關的設定

Rman> backup database plus archivelog delete input;-- 備份整個資料 執行命令後提示如下:

 

 

 

 以上說明資料庫不是在歸檔模式下,需要修改成歸檔模式.

Sql>shutdown immediate;

Sql>startup mount;

Sql>alter database archivelog;

Sql>alter database open;

rman>backup database plus archivelog delete input; --執行後介面如下 會在flash_recovery_area下建立相關的檔案

 

第五步,通過rman進行相關恢復的操作

Rman>shutdown immediate; ----先關閉資料庫

Rman>startup nomount; ---把資料庫啟動到nomount狀態下,此時還沒用到控制檔案。

 

Rman>restore controlfile from autobackup; ------autobackup到恢復控制檔案,假設資料庫控制檔案壞啦或是不能啟動資料庫啦。

Rman>alter database mount;  ------把資料庫切換到mount狀態下

Rman>restore database;  ---恢復資料庫(主要針對data file,)

 

資料檔案,redo log 開啟後就可以把資料庫切換到open模式下

Rman>alter database open resetlogs;

 

 

第六步:恢復表空間

Sql>alter tablespace users offline;

C:\rman target sys/stephen@pskDB catalog rman/rman@pskDB;

Rman>restore tablespace users;

Rman>recover tablespace users;

Rman>exit;

Sql>conn /as sysdba;

Sql>alter tablespace users online;

 

 

Rman>recover database; ---恢復資料庫(主要針對線上redo log)

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

相關文章