在10G中,ORACLE引入了控制文件的自动备份,如果数据库的结构发生了变化,那么ORACLE
会自动将控制文件备份到指定目录中。
前提是数据库处于归档模式,并且CONTROLFILE AUTOBACKUP设置为ON。
首先看一下10G的情况:
- SQL> select * from v$version;
- BANNER
- --------------------------------------------------------------------------------
- Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
- PL/SQL Release 10.2.0.5.0 - Production
- CORE 10.2.0.5.0 Production
- TNS for Linux: Version 10.2.0.5.0 - Production
- NLSRTL Version 10.2.0.5.0 - Production
- SQL> conn / as sysdba
- Connected.
- SQL> archive log list
- Database log mode Archive Mode
- Automatic archival Enabled
- Archive destination USE_DB_RECOVERY_FILE_DEST
- Oldest online log sequence 121
- Next log sequence to archive 124
- Current log sequence 124
- [oracle@dbserver ~]$ rman target /
- Recovery Manager: Release 10.2.0.5.0 - Production on Fri Sep 14 11:00:13 2012
- Copyright (c) 1982, 2007, Oracle. All rights reserved.
- connected to target database: REPORTDB (DBID=3119636991)
- RMAN> show controlfile autobackup;
- using target database control file instead of recovery catalog
- RMAN configuration parameters are:
- CONFIGURE CONTROLFILE AUTOBACKUP ON;
- RMAN>
这是一个10.2.0.5的数据库,数据库处于归档模式,并且controlfile autobackup设置为ON。
- SQL> create tablespace test datafile '/u01/app/oracle/oradata/reportdb/test01.dbf' size 2m;
- Tablespace created.
- SQL> alter database drop logfile group 5;
- Database altered.
日志文件中将会看到控制文件的自动备份情况。
- Fri Sep 14 10:32:12 CST 2012
- create tablespace test datafile '/u01/app/oracle/oradata/reportdb/test01.dbf' size 2m
- Fri Sep 14 10:32:13 CST 2012
- Starting control autobackup
- Control autobackup written to DISK device
- handle '/u01/app/oracle/flash_recovery_area/REPORTDB/autobackup/2012_09_14/o1_mf_s_793967533_8555sgkh_.bkp'
- Completed: create tablespace test datafile '/u01/app/oracle/oradata/reportdb/test01.dbf' size 2m
- Fri Sep 14 10:32:33 CST 2012
- alter database drop logfile group 5
- Fri Sep 14 10:32:33 CST 2012
- Starting control autobackup
- Control autobackup written to DISK device
- handle '/u01/app/oracle/flash_recovery_area/REPORTDB/autobackup/2012_09_14/o1_mf_s_793967553_8555t1q6_.bkp'
- Completed: alter database drop logfile group 5
ls -ltr 也可以看出文件的创建时间可以看出备份文件被立马创建。
[oracle@dbserver REPORTDB]$ ls -ltr /u01/app/oracle/flash_recovery_area/REPORTDB/autobackup/2012_09_14/
total 36380
-rw-r----- 1 oracle oinstall 7438336 Sep 14 10:32 o1_mf_s_793967533_8555sgkh_.bkp
-rw-r----- 1 oracle oinstall 7438336 Sep 14 10:32 o1_mf_s_793967553_8555t1q6_.bkp
从ORACLE DATABASE 11GR2开始,引入了控制文件自动备份延迟创建的特性。
即使你设置了控制文件的自动备份,在数据库结构发现变化的时候不会立即看到控制文件的备份,而是过一段时间才会看到。
这是ORACLE为了改变性能而引入的,防止你在一个脚本中多次对数据库结构的变化而创建多个控制文件备份。
譬如CREATE TABLEPACE,DROP LOGFILE,ADD LOGEILE等,11G只会备份一个控制文件,而不是多个。
对于10G只要对数据库结构改变,就会自动备份一个。
上面的例子我创建了一个表空间,删除了一个日志文件组,后台自动生成了2个控制文件备份。
下面看一下11G的情况:
- [oracle@db2server ~]$ rman target /
- Recovery Manager: Release 11.2.0.1.0 - Production on Tue Sep 11 22:35:09 2012
- Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
- connected to target database: HUATENG (DBID=2134565240)
- RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/archivelog/autobackup/%F';
- new RMAN configuration parameters:
- CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/archivelog/autobackup/%F';
- new RMAN configuration parameters are successfully stored
- RMAN> SHOW CONTROLFILE AUTOBACKUP ;
- RMAN configuration parameters for database with db_unique_name HUATENG are:
- CONFIGURE CONTROLFILE AUTOBACKUP ON;
- RMAN>
- SQL> archive log list
- Database log mode Archive Mode
- Automatic archival Enabled
- Archive destination /archivelog
- Oldest online log sequence 7
- Next log sequence to archive 9
- Current log sequence 9
- SQL> create tablespace test datafile '/u01/app/oracle/oradata/huateng/test01.dbf' size 2m;
- Tablespace created.
- Incremental checkpoint up to RBA [0x9.346f.0], current log tail at RBA [0x9.346f.0]
- Tue Sep 11 22:38:02 2012
- create tablespace test datafile '/u01/app/oracle/oradata/huateng/test01.dbf' size 2m
- Completed: create tablespace test datafile '/u01/app/oracle/oradata/huateng/test01.dbf' size 2m
- Tue Sep 11 22:38:20 2012
- Incremental checkpoint up to RBA [0x9.346f.0], current log tail at RBA [0x9.3501.0]
日志文件中仅仅显示了表空间创建成功的信息,并没有控制文件的自动备份信息。
而且备份目录下也没有发现任何的控制文件备份文件。
[oracle@db2server autobackup]$ pwd
/archivelog/autobackup
[oracle@db2server autobackup]$ ls -ltr
total 0
[oracle@db2server autobackup]$
MOS [ID 1068182.1]对这个问题进行了如下阐述:
In this release, the controlfile autobackups are created by MMON slaves after few minutes of the structural changes,
which increases performance.
So, It's the expected behaviour to get the controlfile autobackup several minutes after the structural change on the database
and it's also expected that no message about controlfile autobackup creation will appear in the alert.log.
There will be generated one MMON slave trace file with the controlfile creation information, that will be a file named:
SID__m000_.trc
在经过6分钟后,终于看到备份文件了:
[oracle@db2server autobackup]$ ls -ltr
total 9616
-rw-r----- 1 oracle oinstall 9830400 Sep 11 22:44 c-2134565240-20120911-00
oracle后台进程m000的TRACE文件中记录此次备份信息,ALERT文件中不再记录了。
- [oracle@db2server trace]$ more huateng_m000_8971.trc
- Trace file /u01/app/oracle/diag/rdbms/huateng/huateng/trace/huateng_m000_8971.trc
- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- ORACLE_HOME = /u01/app/oracle/product/db11gr2
- System name: Linux
- Node name: db2server
- Release: 2.6.18-92.el5
- Version: #1 SMP Tue Jun 10 18:49:47 EDT 2008
- Machine: i686
- Instance name: huateng
- Redo thread mounted by this instance: 1
- Oracle process number: 30
- Unix process pid: 8971, image: oracle@db2server (M000)
- *** 2012-09-11 22:44:03.648
- *** SESSION ID:(50.5) 2012-09-11 22:44:03.648
- *** CLIENT ID:() 2012-09-11 22:44:03.648
- *** SERVICE NAME:(SYS$BACKGROUND) 2012-09-11 22:44:03.648
- *** MODULE NAME:(MMON_SLAVE) 2012-09-11 22:44:03.648
- *** ACTION NAME:(Autobackup Control File) 2012-09-11 22:44:03.648
- Starting control autobackup
- *** 2012-09-11 22:44:06.515
- Control autobackup written to DISK device
- handle '/archivelog/autobackup/c-2134565240-20120911-00'
ORACLE通过隐含参数controlfile_autobackup_delay来控制这种行为,默认是300秒。
阅读(5151) | 评论(0) | 转发(1) |