rman給歸檔指定備份位置;庫先備份盤同時到帶庫;更改控制檔案自備路徑;時間點的恢復

shilei1發表於2012-07-18

在常規rman備份的時候,如果沒有在rman配置裡設定備份路徑,需要給歸檔也制定個備份路徑,否則會備份到D:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_1\DATABASE\ 下。

BACKUP DATABASE SKIP INACCESSIBLE FILESPERSET 10

INCLUDE CURRENT CONTROLFILE

format 'g:\bk\%t_%u'

 PLUS ARCHIVELOG FILESPERSET 20 format='g:\bk\arch_%U_%T'

DELETE ALL INPUT;



該例子就備份到了上面路徑下

 BACKUP DATABASE SKIP INACCESSIBLE FILESPERSET 10

INCLUDE CURRENT CONTROLFILE

format 'g:\bk\%t_%u'

 PLUS ARCHIVELOG FILESPERSET 20

DELETE ALL INPUT;


一個資料庫先是備份到本地磁碟,後來也備份到磁帶。備份指令碼需要修改,否則在執行delete noprompt obsolete 語句的時候會報錯。需要分配個維護通道如下:

RMAN> connect target *

2> RUN {

3> ALLOCATE CHANNEL CH1 DEVICE TYPE DISK;

4> ALLOCATE CHANNEL CH2 DEVICE TYPE DISK;

5> BACKUP DATABASE SKIP INACCESSIBLE FILESPERSET 10

6>    INCLUDE CURRENT CONTROLFILE

7>    PLUS ARCHIVELOG FILESPERSET 20

8>    DELETE ALL INPUT;

9> RELEASE CHANNEL CH1;

10> RELEASE CHANNEL CH2;

11> }

12> allocate channel for maintenance type disk; 

13> delete noprompt obsolete device type disk; 

14> release channel;

15> 


在Oracle10g中,如果我們使用了閃回區,那麼控制檔案的自動備份會儲存在閃回區中。

有時候為了安全,我們需要將控制檔案的自動備份轉移到其他目錄下,這可以使用如下命令。

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/oracle/obak/control%F';


new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/oracle/obak/control%F';

new RMAN configuration parameters are successfully stored


當然,開啟控制檔案自動備份需要使用如下命令:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;


new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored


我們建議使用者一定要開啟這個功能。

現在控制檔案的自動備份將指向新的目錄:

RMAN> backup datafile 1;


Starting backup at 07-JAN-08

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=12 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/opt/oracle/oradata/eygle/system01.dbf

channel ORA_DISK_1: starting piece 1 at 07-JAN-08

channel ORA_DISK_1: finished piece 1 at 07-JAN-08

piece handle=/opt/oracle/obak/bkup_3fj5jbqp_1_1 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36

Finished backup at 07-JAN-08


Starting Control File and SPFILE Autobackup at 07-JAN-08

piece handle=/opt/oracle/obak/controlc-1407686520-20080107-00 comment=NONE

Finished Control File and SPFILE Autobackup at 07-JAN-08



基於時間點的恢復

11:58:04 SQL> startup mount;

  ORACLE instance started.

  Total System Global Area 101785428 bytes

  Fixed Size 454484 bytes

  Variable Size 75497472 bytes

  Database Buffers 25165824 bytes

  Redo Buffers 667648 bytes

  Database mounted.

  SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

  11:58:15 SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

  Session altered.

  Elapsed: 00:00:00.00

  11:58:17 SQL> recover database until time '2005-01-17 11:57:28';

  Media recovery complete.

  recover database until time '2010-10-19 18:25:03';

  --恢復到提交完成時刻

  11:58:33 SQL> alter database open resetlogs;

  Database altered.

  Elapsed: 00:00:05.08

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

相關文章