Oracle 11gR2 RMAN 配置控制文件自动备份(control file autobackup)
通过在 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
触发情况:
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> 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
使用控制文件自动备份恢复参数文件
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
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/
喜欢请赞赏一下啦^_^
微信赞赏
支付宝赞赏