managing control files

一、oracle控制文件管理

1、什么是控制文件?
每个oracle数据库都有控制文件,控制文件是一个二进制文件,它记录了数据库物理结构信息,控制文件包括如下:
(1)数据库名
(2)相关联的数据文件、日志文件的名字和路径
(3)数据库创建的时间戳
(4)当前日志的scn
(5)检查点的信息

没有控制文件,数据库不能被mount,同时恢复备份也很复杂;如果丢失控制文件或者想修改其中的参数,可以重建控制文件

1.1、使用control_files指定控制文件名
在mount数据库时,实例识别、打开control_files指定的所有控制文件名,在数据库操作期间,实例写入和保存所有的控制文件

1.2、在不同的硬盘上多路复制控制文件
Every Oracle Database should have at least two control files, each stored on a different 
physical disk. If a control file is damaged due to a disk failure, the associated instance 
must be shut down. Once the disk drive is repaired, the damaged control file can be 
restored using the intact copy of the control file from the other disk and the instance 
can be restarted. In this case, no media recovery is required.

每个oracle数据库都应该有至少两个控制文件,各自放置在不同的硬盘上。如果控制文件因为介质错误被损坏,对应的实例肯定关闭。一旦硬盘被修复,实例启动时被损坏的控制文件可以被恢复。在这种情况下,不需要介质恢复

多路复制控制文件的行为特征是这样的:
(1)数据库会写入control_files参数指定的所有控制文件
(2)数据库读control_files参数指定的第一个控制文件
(3)如果任何一个控制文件都变得不可用,实例就会abort关闭

oracle强烈建议:数据库有至少两个控制文件,它们放置在不同的硬盘上
Note: Oracle strongly recommends that your database has a 
minimum of two control files and that they are located on separate 
physical disks.

多路复制控制文件的一种方式是如果日志做了多路复制,把控制文件拷贝保存到不同日志组硬盘上

1.3、备份控制文件
备份控制文件非常重要。建数据库最初、每次改变数据库的物理结构都要备份控制文件,比如以下结构改变:
(1)增加、删除、重命名控制文件
(2)增加、删除、切换表空间的状态
(3)增加、删除重做日志文件或者日志组

使用alter database backup controlfile语句备份控制文件,它有两个选项:
(1)把控制文件备份成二进制文件
alter database backup controlfile to '';
(2)产生一个重建控制文件的脚本
alter database backup controfile to trace;
(3)使用rman自动备份控制文件
一旦数据库物理结构改变,rman自动备份控制文件

RMAN is critical to ASM and is responsible for tracking the ASM filenames and for 
deleting obsolete ASM files. Because ASM files cannot be copied through normal 
operating system interfaces (other than with the XML DB repository through FTP or 
HTTP/WebDAV), RMAN is the preferred means of copying ASM files. RMAN is the 
only method for performing backups of a database containing ASM files.
RMAN can also be used for moving databases or files into ASM storage.
See Also:
■ Oracle Database Backup and Recovery Basics
■ Oracle Database Backup and Recovery Advanced User's Guide

rman对asm来说是迫切需要的,rman负责地跟踪asm文件,同时删除过时的asm文件。因为通过常规的操作系统接口无法拷贝asm文件,在拷贝asm文件时,rman招人喜爱。rman也可以用作移动表空间或者文件到asm存储


二、创建控制文件
1、创建初始化控制文件 Creating Initial Control Files
The names of the control files are specified by the CONTROL_FILES parameter in the initialization parameter file used during database creation. 
控制文件的名称由在创建数据库期间使用的初始化参数文件的control_files指定,例如:
CONTROL_FILES = (/u01/oracle/prod/control01.ctl,
 /u02/oracle/prod/control02.ctl, 
 /u03/oracle/prod/control03.ctl)

If files with the specified names currently exist at the time of database creation, you must specify the CONTROLFILE REUSE clause in the CREATE DATABASE statement, 
or else an error occurs. Also, if the size of the old control file differs from the SIZE parameter of the new one, you cannot use the REUSE clause. 
如果在创建数据库期间,指定名字的文件已经存在,那么你在create database的语句中必须指定controlfile reuse条目,否则就会出现一个错误。

You can subsequently change the value of the CONTROL_FILES initialization parameter to add more control files or to change the names or locations of existing control files.
你可以随后修改control_files的值,从而增加控制文件或者改变控制文件的名称、位置等

2、创建附加、重命名、迁移控制文件 Creating Additional Copies, Renaming, and Relocating Control Files

3、创建新的控制文件 Creating New Control Files
3.1、何时创建一个新的控制文件?
(1)所有的控制文件损坏,并且没有备份控制文件
(2)想要修改数据库名
You can change the database name and DBID (internal database identifier) using the DBNEWID utility. See Oracle Database Utilities for information about using this utility.
(3)
The compatibility level is set to a value that is earlier than 10.2.0, and you must make a change to an area of database configuration that relates to any of the 
following parameters from the CREATE DATABASE or CREATE CONTROLFILE commands: MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY, and 
MAXINSTANCES. If compatibility is 10.2.0 or later, you do not have to create new control files when you make such a change; the control files automatically expand, 
if necessary, to accommodate the new configuration information.
oracle10.2.0之前,你必须修改 与任何参数相关的数据库配置的一个区域。如果兼容性是10.2.0或者之后的,你不必创建新的控制文件;控制文件是自动扩展,如果需要,从而适应新的配置信息


Cautions:
■ The CREATE CONTROLFILE statement can potentially damage specified datafiles and redo log files. Omitting a filename can 
cause loss of the data in that file, or loss of access to the entire database. Use caution when issuing this statement and be sure 
to follow the instructions in "Steps for Creating New Control Files".
create controlfile语句会潜在地损坏指定的数据文件和日志文件。忽略存在的文件名会引起数据文件数据的丢失,或者,可访问数据库的丢失。当运行这个语句时,小心使用,并且
确认跟随在"Steps for Creating New Control Files"的操作
■ If the database had forced logging enabled before creating the new control file, and you want it to continue to be enabled, 
then you must specify the FORCE LOGGING clause in the CREATE CONTROLFILE statement. See "Specifying FORCE LOGGING Mode" on page 2-18. 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值