Oracle 11gR2 RMAN 配置控制檔案自動備份(control file autobackup)

feelpurple發表於2015-12-09
透過在 RMAN 中配置 control file autobackup,RMAN 會自動備份控制檔案和引數檔案到預先設定好的路徑。

觸發情況:

1、當資料庫的結構發生改變時(資料庫執行在歸檔模式)
2、當完成 RMAN 備份後

好處:

即使資料庫丟失了控制檔案和恢復目錄(recovery catalog),控制檔案和引數檔案也可以從自動備份的控制檔案中進行恢復,讓資料庫多了一層保護,而且從autobackup中恢復控制檔案和引數檔案更加快速方便。

設定方法:

檢視現有的 RMAN 配置引數,可以看到沒有啟用控制檔案自動備份,引數依舊是預設值

[oracle@ATFDB1 admin]$ rman target /


Recovery Manager: Release 11.2.0.3.0 - Production on Wed Dec 9 09:19:07 2015


Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.


connected to target database: FIRE (DBID=917673527)

RMAN> show all;


using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name FIRE are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u02/app/oracle/product/11.2.0/db_1/dbs/snapcf_fire.f'; # default

啟用控制檔案自動備份特性

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

配置控制檔案自動備份的路徑和格式

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/ORADATA/controlfile/cf_%F';


new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/ORADATA/controlfile/cf_%F';
new RMAN configuration parameters are successfully stored

檢視重新設定的引數

RMAN> show all;


RMAN configuration parameters for database with db_unique_name FIRE are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/ORADATA/controlfile/cf_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u02/app/oracle/product/11.2.0/db_1/dbs/snapcf_fire.f'; # default

透過 RMAN 備份資料庫,檢視是否生成控制檔案自動備份。在 RMAN 備份結束後,可以看到自動備份的相關資訊。

RMAN> backup database plus archivelog delete all input;

Starting backup at 2015-12-09 09:41:59
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=59 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
……
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2015-12-09 09:42:07


Starting backup at 2015-12-09 09:42:07
using channel ORA_DISK_1
specification does not match any archived log in the repository
backup cancelled because there are no files to backup
Finished backup at 2015-12-09 09:42:07


Starting Control File and SPFILE Autobackup at 2015-12-09 09:42:07
piece handle=/ORADATA/controlfile/cf_c-917673527-20151209-00 comment=NONE
Finished Control File and SPFILE Autobackup at 2015-12-09 09:42:08

檢視磁碟上生產的控制檔案自動備份,生成的備份檔案的格式中包含了 DBID,下面的紅色字部分就是資料庫的 DBID

[oracle@ATFDB1 ~]$ ll /ORADATA/controlfile
total 9888
-rw-r----- 1 oracle oinstall 10125312 Dec  9 09:42 cf_c-917673527-20151209-00

使用控制檔案自動備份恢復引數檔案

SQL> shutdown immediate
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.

Total System Global Area 1.0021E+10 bytes
Fixed Size    2236968 bytes
Variable Size 1543507416 bytes
Database Buffers 8455716864 bytes
Redo Buffers   19918848 bytes

[oracle@ATFDB1 controlfile]$ rman target /


Recovery Manager: Release 11.2.0.3.0 - Production on Wed Dec 9 14:03:28 2015


Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.


connected to target database: FIRE (not mounted)


RMAN> RESTORE SPFILE TO '/home/oracle/spfileTEMP.ora' from '/ORADATA/controlfile/cf_c-917673527-20151209-00';


Starting restore at 2015-12-09 14:03:35
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=254 device type=DISK


channel ORA_DISK_1: restoring spfile from AUTOBACKUP /ORADATA/controlfile/cf_c-917673527-20151209-00
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 2015-12-09 14:03:36

使用控制檔案自動備份恢復控制檔案

RMAN> RESTORE CONTROLFILE TO '/home/oracle/controlTEMP.ora' from '/ORADATA/controlfile/cf_c-917673527-20151209-00';

Starting restore at 2015-12-09 14:04:26
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 2015-12-09 14:04:28


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

相關文章