Oracle 1Z031第六章管理控制文件

1Z031 第六章管理控制文件
学习目标
1、 说明 control file 的用途
2、 列出 control file 的内容
3、 复制和管理 control file
4、 OMF 管理 control file
5、 获取 control file 信息
一、 控制文件
控制文件是一个二进制文件,定义物理数据库的当前状态。
丢失 control file 需要恢复 (recovery)
mount 数据库的阶段需要读控制文件
操作的时候必须
与数据库一一对应
应该复制 ( 镜像 )
管理数据库的一致性
大小由 create database 初始化的
The control file is a small binary file necessary for the database to start and operate
successfully. Each control file is associated with only one Oracle database. Before a database
is opened, the control file is read to determine if the database is in a valid state to use. A
control file is updated continuously by the Oracle server during database use, so it must be
available for writing whenever the database is open. The information in the control file can
be modified only by the Oracle server; no database administrator or end user can edit the
control file. If for some reason the control file is not accessible, the database does not
function properly. If all copies of a database’s control files are lost, the database must be
recovered before it can be opened. At least one control file is required, but control files can
be multiplexed up to eight times.
Sizing the Control File
Keywords specified during the creation of the database affect the size of the control file. This
is particularly significant when the parameters have large values. The size of the control file
is influenced by the following keywords in the CREATE DATABASE or CREATE
CONTROLFILE commands:
• MAXLOGFILES
• MAXLOGMEMBERS
• MAXLOGHISTORY
• MAXDATAFILES
• MAXINSTANCES
控制文件的内容
1、           数据库名( database name )和标识( SID
2、           数据库创建时间戳
3、           表空间名
4、           数据文件、重做日志文件名字和位置
5、           当前重做日志文件序列号
6、           checkpoint 信息
7、           undo segment 的起始和结束
8、           重做日志归档信息
9、           备份信息
The information in the control file includes:
• Database name is taken from either the name specified by the initialization parameter
DB_NAME or the name used in the CREATE DATABASE statement.
• Database identifier is recorded when the database is created.
• Time stamp of database creation is also recorded at database creation.
• Names and locations of associated data files and online redo log files are updated when
a data file or redo log is added to, renamed in, or dropped from the database.
• Tablespace information is updated as tablespaces are added or dropped.
• Redo log history is recorded during log switches.
• Location and status of archived logs are recorded when archiving occurs.
• Location and status of backups are recorded by the Recovery Manager utility.
• Current log sequence number is recorded when log switches occur.
• Checkpoint information is recorded as checkpoints are made.
 
二、 通过 spfile 来镜像控制文件
步骤
1、           alter spfile
SQL> ALTER SYSTEM SET control files =
'$HOME/ORADATA/u01/ctrl01.ctl',
'$HOME/ORADATA/u02/ctrl02.ctl' SCOPE=SPFILE;
2、           shutdown normal
3、           create additional control file
通过 os copy 命令把 control file 复制到第一步中设定的位置
$ cp $HOME/ORADATA/u01/ctrl01.ctl
$HOME/ORADATA/u02/ctrl02.ctl
4、           启动数据库
sql>startup
通过 init.ora 来镜像 control file
1、           shutdown the database
2、           copy the existing control file to new name and location
3、              add the new control file name to init.ora
CONTROL_FILES=(/DISK1/control01.ctl,/DISK3/control02.ctl)
4、           startup the database
 
三、 通过 OMF 来管理 control file
Control files are OMF created if the
CONTROL_FILES parameter is not specified.
OMF control files are located at
DB_CREATE_ONLINE_LOG_DEST_N.
Control file names are uniquely generated and
displayed in the alertSID.log file when the files
are created.
四、 获取 control file 的信息
可以通过查询数据字典来获取 control file 的信息
1、           v$controlfile :列出所有当前实例的 control file 的名字和状态
2、           v$parameter :列出所有的控制文件的状态和名字
3、           v$controlfile_record_section :提供 control file 纪录段的信息
4、           show parameters control_files :列出 control file 的名字、状态、位置。
v$controlfile_record_section 补充说明
To obtain information about the different sections of the control files, query the
V$CONTROLFILE_RECORD_SECTION dynamic performance view.
SELECT type, record_size, records_total, records_used
FROM v$controlfile_record_section
WHERE type=’DATAFILE’;
TYPE RECORD_SIZ RECORDS_TO RECORDS_US
------- ---------- -------- ------------------
DATAFILE 180 30 4
1 row selected.
The column RECORDS_TO specifies the number of records allocated for a special section. For
example, you can view the maximum number of data files, in our example 30, which is
determined by the MAXDATAFILES parameter in the CREATE DATABASE command.
其他的几个需要读 control file 信息的动态视图
• V$BACKUP
• V$DATAFILE
• V$TEMPFILE
• V$TABLESPACE
• V$ARCHIVE
• V$LOG
• V$LOGFILE
• V$LOGHIST
• V$ARCHIVED_LOG
• V$DATEBASE
 
本章结束, control file oracle 非常重要的一个文件,如何安全的管理这个文件对数据库的日常维护,备份,恢复都有重要意义。
 

你可能感兴趣的:(Oracle 1Z031第六章管理控制文件)