一、控制文件:
小型的二进制文件;定义了数据库当前的物理结构;维护数据库的完整性;在 数据库的启动过程中(mount状态)和对数据库进行操作时会用到它;在create database时初始化大小;每个控制文件只对应一个数据库;在mount时读取,确定数据库处于可用状态;获得数据文件和redo log file文件的名字和位置(但不会验证这些文件是否存在或可用)。
在数据库运行过程中,被server持续的更新,不能人为的直接更新它的内容。没有控制文件,数据库将无法启动。
在操作系统下可以用strings命令查看到信息。
这些参数会影响控制文件的大小:MAXLOGFILES;MAXLOGMEMBERS;MAXLOGHISTORY;MAXDATAFILES;MAXINSTANCES。
包含的内容:
         数据库名字和标识。
         数据库创建时间。
         记录数据库文件、在线重做日志文件的名字和位置,并更新这些的信息,如:添加、重命名、移除等。
         记录并更新表空间信息,如:添加或移除。
         online redo log file的历史记录(during log switches)
         当archiving发生时记录archive log的位置和状态。
         记录RMAN备份的文件状态和位置。
         记录当前log序号(when log switches occur.)。
         记录checkpoint信息(as checkpoints are made)。
一个控制文件包含两段(两种类型):
         • Reusable
• Not reusable
Reusable sections store RMAN information, such as backup data file names and backup online redo log file names. They are used in a circular manner and can be reused only by RMAN
二、复用控制文件:     
Oracle 9i学习日志(10)--控制文件 _Oracle日志
 
用spfile设置复用control file :
SQL> show parameter control_files
 
NAME                                   TYPE                   VALUE
------------------------------------ ----------- ------------------------------
control_files                        string           u01/oradata/lty/control01.ctl,
                                                            /u01/oradat/lty/control03.ctl
                                                            , /u01/oradata/lty/cba/control
                                                            04.ctl
alter system set control_file=alter system set control_files='/u01/oradata/lty/control01.ctl','/u01/oradata/lty/control02.ctl','/u01/oradata/lty/control03.ctl','/u01/oradata/lty/cba/control04.ctl' scope=spfile;
SQL> shutdown immediate
$cd /u01/oradata/lty
$mkdir cba
$ cp control01.ctl cba/control04.ctl
SQL> startup
SQL> show parameter control_files;
 
NAME                            TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files                        string /u01/oradata/lty/control01.ctl
                                           , /u01/oradata/lty/control02.c
                                           tl, /u01/oradata/lty/control03
                                           .ctl, /u01/oradata/lty/cba/con
                                           trol04.ctl
 用spfile设置复用control file :
 
Oracle 9i学习日志(10)--控制文件 _职场_02
注意:database启动时只会去读取参数文件里第一个control file,若第一个读取失败就会报错,数据也起不来。读取第一成功后,数据库会确认后面的几个control file文件是否可用(包括写权限,若不能写则会报错),若不可用则数据库起不来。Control file可以是任意名字(推荐按OFA规范)。
 
三、获得control file信息:
         V$CONTROLFILE:列出了所有与instance相关的control file。
         V$PARAMETER:所有参数和参数值列表。
         V$CONTROLFILE_RECORD_SECTION:提供control file段记录信息。
以下这些动态性能视图信息是根据control file获得的:
•V$BACKUP
•V$DATAFILE
•V$TEMPFILE
•V$TABLESPACE
•V$ARCHIVE
•V$LOG
•V$LOGFILE
•V$LOGHIST
•V$ARCHIVED_LOG
•V$DATABASE

四、练习

1 Where is the existing control file located and what is the name?
Hint: Query the V$CONTROLFILE dynamic performance view.
Note: You can also use V$PARAMETER, or execute the SHOW PARAMETER
command to display the name and the location of the control file.
2a Try to start the database without any control files. Simulate this by changing the
name of the control file in the parameter file or changing the control file name. What
happens?
Hints
- Connect as user SYS.
- Shut down the database using the IMMEDIATE option.
- Using OS command line, copy the control file .ctl as a .bak extension.
- Remove the control file .ctl.
- Start the database.
2b To resolve the ORA-00205 error:
- Shut down the database.
- Rename the copied control file to the appropriate name.
- Start up the database.
3a Multiplex the existing control file, using the u02 directory, and name the new
control file ctrl02.ctl. Make sure that the Oracle server is able to write to the
new control file. For example, on UNIX use the chmod 660 command.
Hints
- Before shutting down the database alter the SPFILE (SCOPE=SPILE) to add
the new control file to the initialization file.
- Shut down the database, and copy the existing control file to a new file with the
name ctrl02.ctl in the u02 directory. Use the chmod 660 command on
UNIX. Note: Normally the permissions on the file would not be changed; this is
for the classroom environment.
- Start up the database.
b Confirm that the control file was multiplexed and is now being used.
Hint: Query the V$CONTROLFILE or V$PARAMETER dynamic performance
views, or use the SHOW PARAMETER command to confirm that both control files
are being used.
4 What is the initial sizing of the data file section in your control file?
Hint: Query the V$CONTROLFILE_RECORD_SECTION dynamic performance
view.
解析:SQL> select type, records_total, records_used from v$controlfile_record_section ; 
Tomas大师总结:Oracle 9i学习日志(10)--控制文件 _休闲_03
 
本文出自 “冰冷的太阳” 博客,请务必保留此出处http://luotaoyang.blog.51cto.com/545649/284399