您的位置:首页 > 数据库 > Oracle

我的Oracle 9i学习日志(10)--控制文件

2010-03-16 20:37 477 查看
[align=left]一、控制文件:[/align]
小型的二进制文件;定义了数据库当前的物理结构;维护数据库的完整性;在数据库的启动过程中(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)。
一个控制文件包含两段(两种类型):
[align=left] • Reusable[/align]
[align=left]• Not reusable[/align]
[align=left]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。[/align]
[align=left]二、复用控制文件: [/align]




[align=left]用spfile设置复用control file :[/align]
[align=left]SQL> show parameter control_files[/align]
[align=left] [/align]
[align=left]NAME TYPE VALUE[/align]
[align=left]------------------------------------ ----------- ------------------------------[/align]
[align=left]control_files string u01/oradata/lty/control01.ctl,[/align]
[align=left] /u01/oradat/lty/control03.ctl[/align]
[align=left] , /u01/oradata/lty/cba/control[/align]
[align=left] 04.ctl[/align]
[align=left]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;[/align]
[align=left]SQL> shutdown immediate[/align]
[align=left]$cd /u01/oradata/lty[/align]
[align=left]$mkdir cba[/align]
[align=left]$ cp control01.ctl cba/control04.ctl[/align]
[align=left]SQL> startup[/align]
[align=left]SQL> show parameter control_files;[/align]
[align=left] [/align]
[align=left]NAME TYPE VALUE[/align]
[align=left]------------------------------------ ----------- ------------------------------[/align]
[align=left]control_files string /u01/oradata/lty/control01.ctl[/align]
[align=left] , /u01/oradata/lty/control02.c[/align]
[align=left] tl, /u01/oradata/lty/control03[/align]
[align=left] .ctl, /u01/oradata/lty/cba/con[/align]
[align=left] trol04.ctl[/align]
[align=left] 用spfile设置复用control file :[/align]
[align=left] [/align]




注意:database启动时只会去读取参数文件里第一个control file,若第一个读取失败就会报错,数据也起不来。读取第一成功后,数据库会确认后面的几个control file文件是否可用(包括写权限,若不能写则会报错),若不可用则数据库起不来。Control file可以是任意名字(推荐按OFA规范)。
[align=left] [/align]
[align=left]三、获得control file信息:[/align]
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

四、练习

[align=left]1 Where is the existing control file located and what is the name?[/align]
[align=left]Hint: Query the V$CONTROLFILE dynamic performance view.[/align]
[align=left]Note: You can also use V$PARAMETER, or execute the SHOW PARAMETER[/align]
[align=left]command to display the name and the location of the control file.[/align]
[align=left]2a Try to start the database without any control files. Simulate this by changing the[/align]
[align=left]name of the control file in the parameter file or changing the control file name. What[/align]
[align=left]happens?[/align]
[align=left]Hints[/align]
[align=left]- Connect as user SYS.[/align]
[align=left]- Shut down the database using the IMMEDIATE option.[/align]
[align=left]- Using OS command line, copy the control file .ctl as a .bak extension.[/align]
[align=left]- Remove the control file .ctl.[/align]
[align=left]- Start the database.[/align]
[align=left]2b To resolve the ORA-00205 error:[/align]
[align=left]- Shut down the database.[/align]
[align=left]- Rename the copied control file to the appropriate name.[/align]
[align=left]- Start up the database.[/align]
[align=left]3a Multiplex the existing control file, using the u02 directory, and name the new[/align]
[align=left]control file ctrl02.ctl. Make sure that the Oracle server is able to write to the[/align]
[align=left]new control file. For example, on UNIX use the chmod 660 command.[/align]
[align=left]Hints[/align]
[align=left]- Before shutting down the database alter the SPFILE (SCOPE=SPILE) to add[/align]
[align=left]the new control file to the initialization file.[/align]
[align=left]- Shut down the database, and copy the existing control file to a new file with the[/align]
[align=left]name ctrl02.ctl in the u02 directory. Use the chmod 660 command on[/align]
[align=left]UNIX. Note: Normally the permissions on the file would not be changed; this is[/align]
[align=left]for the classroom environment.[/align]
[align=left]- Start up the database.[/align]
[align=left]b Confirm that the control file was multiplexed and is now being used.[/align]
[align=left]Hint: Query the V$CONTROLFILE or V$PARAMETER dynamic performance[/align]
[align=left]views, or use the SHOW PARAMETER command to confirm that both control files[/align]
[align=left]are being used.[/align]
[align=left]4 What is the initial sizing of the data file section in your control file?[/align]
[align=left]Hint: Query the V$CONTROLFILE_RECORD_SECTION dynamic performance[/align]
view.
解析:SQL> select type, records_total, records_used from v$controlfile_record_section ;
Tomas大师总结:



本文出自 “冰冷的太阳” 博客,请务必保留此出处http://luotaoyang.blog.51cto.com/545649/284399
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: