Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2896027
  • 博文数量: 599
  • 博客积分: 16398
  • 博客等级: 上将
  • 技术积分: 6875
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-30 12:04
个人简介

WINDOWS下的程序员出身,偶尔也写一些linux平台下小程序, 后转行数据库行业,专注于ORACLE和DB2的运维和优化。 同时也是ios移动开发者。欢迎志同道合的朋友一起研究技术。 数据库技术交流群:58308065,23618606

文章分类

全部博文(599)

文章存档

2014年(12)

2013年(56)

2012年(199)

2011年(105)

2010年(128)

2009年(99)

分类: Oracle

2012-09-14 11:34:59


在10G中,ORACLE引入了控制文件的自动备份,如果数据库的结构发生了变化,那么ORACLE
会自动将控制文件备份到指定目录中。
前提是数据库处于归档模式,并且CONTROLFILE AUTOBACKUP设置为ON。
首先看一下10G的情况:
 

点击(此处)折叠或打开

  1. SQL> select * from v$version;

  2. BANNER
  3. --------------------------------------------------------------------------------

  4. Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
  5. PL/SQL Release 10.2.0.5.0 - Production
  6. CORE 10.2.0.5.0 Production
  7. TNS for Linux: Version 10.2.0.5.0 - Production
  8. NLSRTL Version 10.2.0.5.0 - Production

  9. SQL> conn / as sysdba
  10. Connected.
  11. SQL> archive log list
  12. Database log mode Archive Mode
  13. Automatic archival Enabled
  14. Archive destination USE_DB_RECOVERY_FILE_DEST
  15. Oldest online log sequence 121
  16. Next log sequence to archive 124
  17. Current log sequence 124

  18. [oracle@dbserver ~]$ rman target /

  19. Recovery Manager: Release 10.2.0.5.0 - Production on Fri Sep 14 11:00:13 2012

  20. Copyright (c) 1982, 2007, Oracle. All rights reserved.

  21. connected to target database: REPORTDB (DBID=3119636991)

  22. RMAN> show controlfile autobackup;

  23. using target database control file instead of recovery catalog
  24. RMAN configuration parameters are:
  25. CONFIGURE CONTROLFILE AUTOBACKUP ON;

  26. RMAN>
这是一个10.2.0.5的数据库,数据库处于归档模式,并且controlfile autobackup设置为ON。

点击(此处)折叠或打开

  1. SQL> create tablespace test datafile '/u01/app/oracle/oradata/reportdb/test01.dbf' size 2m;

  2. Tablespace created.

  3. SQL> alter database drop logfile group 5;

  4. Database altered.

日志文件中将会看到控制文件的自动备份情况。

点击(此处)折叠或打开

  1. Fri Sep 14 10:32:12 CST 2012
  2.  create tablespace test datafile '/u01/app/oracle/oradata/reportdb/test01.dbf' size 2m
  3. Fri Sep 14 10:32:13 CST 2012
  4. Starting control autobackup
  5. Control autobackup written to DISK device
  6.         handle '/u01/app/oracle/flash_recovery_area/REPORTDB/autobackup/2012_09_14/o1_mf_s_793967533_8555sgkh_.bkp'
  7. Completed: create tablespace test datafile '/u01/app/oracle/oradata/reportdb/test01.dbf' size 2m
  8. Fri Sep 14 10:32:33 CST 2012
  9.  alter database drop logfile group 5
  10. Fri Sep 14 10:32:33 CST 2012
  11. Starting control autobackup
  12. Control autobackup written to DISK device
  13.         handle '/u01/app/oracle/flash_recovery_area/REPORTDB/autobackup/2012_09_14/o1_mf_s_793967553_8555t1q6_.bkp'
  14. 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的情况:

点击(此处)折叠或打开

  1. [oracle@db2server ~]$ rman target /

  2. Recovery Manager: Release 11.2.0.1.0 - Production on Tue Sep 11 22:35:09 2012

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

  4. connected to target database: HUATENG (DBID=2134565240)

  5. RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/archivelog/autobackup/%F';

  6. new RMAN configuration parameters:
  7. CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/archivelog/autobackup/%F';
  8. new RMAN configuration parameters are successfully stored

  9. RMAN> SHOW CONTROLFILE AUTOBACKUP ;

  10. RMAN configuration parameters for database with db_unique_name HUATENG are:
  11. CONFIGURE CONTROLFILE AUTOBACKUP ON;

  12. RMAN>


  13. SQL> archive log list
  14. Database log mode Archive Mode
  15. Automatic archival Enabled
  16. Archive destination /archivelog
  17. Oldest online log sequence 7
  18. Next log sequence to archive 9
  19. Current log sequence 9

  20. SQL> create tablespace test datafile '/u01/app/oracle/oradata/huateng/test01.dbf' size 2m;

  21. Tablespace created.


  22. Incremental checkpoint up to RBA [0x9.346f.0], current log tail at RBA [0x9.346f.0]
  23. Tue Sep 11 22:38:02 2012
  24. create tablespace test datafile '/u01/app/oracle/oradata/huateng/test01.dbf' size 2m
  25. Completed: create tablespace test datafile '/u01/app/oracle/oradata/huateng/test01.dbf' size 2m
  26. Tue Sep 11 22:38:20 2012
  27. 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文件中不再记录了。
 

点击(此处)折叠或打开

  1. [oracle@db2server trace]$ more huateng_m000_8971.trc
  2. Trace file /u01/app/oracle/diag/rdbms/huateng/huateng/trace/huateng_m000_8971.trc
  3. Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
  4. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  5. ORACLE_HOME = /u01/app/oracle/product/db11gr2
  6. System name: Linux
  7. Node name: db2server
  8. Release: 2.6.18-92.el5
  9. Version: #1 SMP Tue Jun 10 18:49:47 EDT 2008
  10. Machine: i686
  11. Instance name: huateng
  12. Redo thread mounted by this instance: 1
  13. Oracle process number: 30
  14. Unix process pid: 8971, image: oracle@db2server (M000)


  15. *** 2012-09-11 22:44:03.648
  16. *** SESSION ID:(50.5) 2012-09-11 22:44:03.648
  17. *** CLIENT ID:() 2012-09-11 22:44:03.648
  18. *** SERVICE NAME:(SYS$BACKGROUND) 2012-09-11 22:44:03.648
  19. *** MODULE NAME:(MMON_SLAVE) 2012-09-11 22:44:03.648
  20. *** ACTION NAME:(Autobackup Control File) 2012-09-11 22:44:03.648

  21. Starting control autobackup

  22. *** 2012-09-11 22:44:06.515
  23. Control autobackup written to DISK device
  24.         handle '/archivelog/autobackup/c-2134565240-20120911-00'

ORACLE通过隐含参数controlfile_autobackup_delay来控制这种行为,默认是300秒。
阅读(5183) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~