--=============================
-- Oracle 控制文件(CONTROLFILE)
--=============================
一、Oracle 控制文件
为二进制文件,初始化大小由CREATE DATABASE指定,可以使用RMAN备份
记录了当前数据库的结构信息,同时也包含数据文件及日志文件的信息以及相关的状态,归档信息等等
在参数文件中描述其位置,个数等等。通常采用分散放开,多路复用的原则。在mount阶段被读取,open阶段一直被使用
维护数据库一致性(数据库启动时会比较控制文件与联机日志文件中的ckpt,即起始scn号,如相等则正常启动,否则需要介质恢复)
一个控制文件只能属于一个数据库
控制文件的任意修改将写入到初始化参数中指定的所有控制文件中,读取时则仅读取第一个控制文件
控制文件只能连接一个数据库,控制文件的大小一般不要超过MB,最多为个,最少一个,互为镜像
控制文件中包含的内容
数据库的名字、ID、创建的时间戳
表空间的名字
联机日志文件、数据文件的位置、个数、名字
联机日志的Sequence号码
检查点的信息
撤销段的开始或结束
归档信息
备份信息
二、查看控制文件的相关信息
1.使用相关视图来查看
V$CONTROLFILE --列出实例中所有控制文件的名字及状态信息
V$PARAMETER --列出所有参数的位置及状态信息
V$CONTROLFILE_RECORD_SECTION --列出控制文件中记录的部分信息
SHOW PARAMETER CONTROL_FILES --列出控制文件的名字、状态、位置等
SQL> select * from v$controlfile;
STATUS NAME IS_ BLOCK_SIZE FILE_SIZE_BLKS
------- -------------------------------------------------- --- ---------- --------------
/u01/app/oracle/oradata/orcl/control01.ctl NO 16384 430
/u01/app/oracle/oradata/orcl/control02.ctl NO 16384 430
/u01/app/oracle/oradata/orcl/control03.ctl NO 16384 430
SQL> select name,type,value from v$parameter where name like '%control%';
NAME TYPE VALUE
------------------------------ ---------- ------------------------------------------------------------
control_files 2 /u01/app/oracle/oradata/orcl/control01.ctl, /u01/app/oracle/
oradata/orcl/control02.ctl, /u01/app/oracle/oradata/orcl/con
trol03.ctl
control_file_record_keep_time 3 7
SQL> select * from v$controlfile_record_section;
TYPE RECORD_SIZE RECORDS_TOTAL RECORDS_USED FIRST_INDEX LAST_INDEX LAST_RECID
---------------------------- ----------- ------------- ------------ ----------- ---------- ----------
DATABASE 316 1 1 0 0 0
CKPT PROGRESS 8180 11 0 0 0 0
REDO THREAD 256 8 1 0 0 0
REDO LOG 72 16 9 0 0 20
DATAFILE 428 100 8 0 0 28
FILENAME 524 2298 21 0 0 0
TABLESPACE 68 100 7 0 0 7
TEMPORARY FILENAME 56 100 1 0 0 1
RMAN CONFIGURATION 1108 50 0 0 0 0
LOG HISTORY 56 292 35 1 35 35
OFFLINE RANGE 200 163 0 0 0 0
TYPE RECORD_SIZE RECORDS_TOTAL RECORDS_USED FIRST_INDEX LAST_INDEX LAST_RECID
---------------------------- ----------- ------------- ------------ ----------- ---------- ----------
ARCHIVED LOG 584 28 20 1 20 20
BACKUP SET 40 409 0 0 0 0
BACKUP PIECE 736 200 0 0 0 0
BACKUP DATAFILE 116 282 0 0 0 0
BACKUP REDOLOG 76 215 0 0 0 0
DATAFILE COPY 660 223 1 1 1 1
BACKUP CORRUPTION 44 371 0 0 0 0
COPY CORRUPTION 40 409 0 0 0 0
DELETED OBJECT 20 818 3 1 3 3
PROXY COPY 852 249 0 0 0 0
BACKUP SPFILE 36 454 0 0 0 0
TYPE RECORD_SIZE RECORDS_TOTAL RECORDS_USED FIRST_INDEX LAST_INDEX LAST_RECID
---------------------------- ----------- ------------- ------------ ----------- ---------- ----------
DATABASE INCARNATION 56 292 2 1 2 2
FLASHBACK LOG 84 2048 0 0 0 0
RECOVERY DESTINATION 180 1 1 0 0 0
INSTANCE SPACE RESERVATION 28 1055 1 0 0 0
REMOVABLE RECOVERY FILES 32 1000 0 0 0 0
RMAN STATUS 116 141 0 0 0 0
THREAD INSTANCE NAME MAPPING 80 8 8 0 0 0
MTTR 100 8 1 0 0 0
DATAFILE HISTORY 568 57 0 0 0 0
STANDBY DATABASE MATRIX 400 10 10 0 0 0
GUARANTEED RESTORE POINT 212 2048 0 0 0 0
TYPE RECORD_SIZE RECORDS_TOTAL RECORDS_USED FIRST_INDEX LAST_INDEX LAST_RECID
---------------------------- ----------- ------------- ------------ ----------- ---------- ----------
RESTORE POINT 212 2083 0 0 0 0
SQL> show parameter control_files;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/oradata/orcl/c
ontrol01.ctl, /u01/app/oracle/
oradata/orcl/control02.ctl, /u
01/app/oracle/oradata/orcl/con
trol03.ctl
SQL> select controlfile_sequence# from v$database;
CONTROLFILE_SEQUENCE#
---------------------
985
2.使用STRINGS命令来查看控制文件中的具体内容
SQL> host strings /u01/app/oracle/oradata/orcl/control01.ctl | more
}|{z
JORCL
L-+RG
+ORCL
+ORCL
orcl
orcl
-+-='
-+-='
/u01/app/oracle/oradata/orcl/redo03.log
/u01/app/oracle/oradata/orcl/redo3.log
/u01/app/oracle/oradata/orcl/redo02.log
/u01/app/oracle/oradata/orcl/redo2.log
/u01/app/oracle/oradata/orcl/redo01.log
/u01/app/oracle/oradata/orcl/tbs1_2.dbf
/u01/app/oracle/oradata/orcl/tbs1_1.dbf
/u01/app/oracle/oradata/orcl/example01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/system01.dbf
u01/app/oracle/oradata/orcl/undotbs02.dbf
/u01/app/oracle/oradata/orcl/redo03.log
/u01/app/oracle/oradata/orcl/redo3.log
/u01/app/oracle/oradata/orcl/redo02.log
/u01/app/oracle/oradata/orcl/redo2.log
/u01/app/oracle/oradata/orcl/redo01.log
/u01/app/oracle/oradata/orcl/tbs1_2.dbf
/u01/app/oracle/oradata/orcl/tbs1_1.dbf
/u01/app/oracle/oradata/orcl/example01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/system01.dbf
u01/app/oracle/oradata/orcl/undotbs02.dbf
SYSTEM
UNDOTBS1
SYSAUX
USERS
EXAMPLE
TBS1
TEMP