控制文件
1.很小的二进制文件;
2.定义数据库物理现状;
3.维护数据库完整性;
4.要求:
数据库处于mount状态;
能够操作数据库
5.只连接到一个数据库;
6.丢失数据需要恢复(数据文件和重做日志文件不丢其他可恢复)
7.最初由create database建立
其大小由create database里面各种属性定义的大小决定
nomount----->读取spfile文件信息
mount---->读取控制文件,从控制文件获取到数据文件和重做日志文件信息,单还未读取和打开
open---->开始打开和读取数据文件和重做日志文件
控制文件内容:
? 数据库名称和标识符
? 创建数据库的时间戳
? 表空间的名称
? 数据文件和重做日志文件的名称和位置
? 当前重做日志的序列号
? 检查点(checkpoint)信息
? 还原段(undo segment)的开始和结尾
? 重做日志归档信息
? 备份信息
[oracle@server01 msp]$ strings control01.ctl | more
}|{z
_$@2
_$@28
>2MSP
>2MSP
W @2
W @2
W @2
W @2
/database/msp/redo01a.rdo
/database/msp/redo01b.rdo
/database/msp/redo02a.rdo
/database/msp/redo02b.rdo
/database/msp/redo03a.rdo
/database/msp/redo03b.rdo
/database/msp/system01.dbf
/database/msp/sysaux01.dbf
/database/msp/undotbs01.dbf
/database/msp/temp01.dbf
/database/msp/mspmytbs.dbf
/database/msp/redo01a.rdo
/database/msp/redo01b.rdo
/database/msp/redo02a.rdo
/database/msp/redo02b.rdo
/database/msp/redo03a.rdo
/database/msp/redo03b.rdo
/database/msp/system01.dbf
/database/msp/sysaux01.dbf
/database/msp/undotbs01.dbf
/database/msp/temp01.dbf
/database/msp/mspmytbs.dbf
SYSTEM
SYSAUX
UNDOTBS1
TEMP
MYTBS
SYSTEM
SYSAUX
UNDOTBS1
TEMP
MYTBS
........................
============================
注意:生产环境下把每个控制文件存储在不同的物理磁盘上,多路复用,容灾备份。
这几个控制文件是完全一样的,数据库启动默认只读其中一个。
====================================================
在其他盘拷贝存放另一个控制文件
SQL> show parameter contr
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /database/msp/control01.ctl, /
opt/oracle/fast_recovery_area/
msp/control02.ctl
control_management_pack_access string DIAGNOSTIC+TUNING
SQL> alter system set control_files='/database/msp/control01.ctl',
2 '/opt/oracle/fast_recovery_area/msp/control02.ctl','/database/msp/control03.ctl' scope=spfile; #新增另一个控制文件副本的存放位置路径
System altered.
SQL> shutdown immediate; #关闭数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !
[oracle@server01 msp]$ cd /database/msp/
[oracle@server01 msp]$ cp control01.ctl control03.ctl #到系统进行拷贝
[oracle@server01 msp]$ ll
total 1569444
-rw-r----- 1 oracle oinstall 16433152 Mar 24 16:57 control01.ctl
-rw-r----- 1 oracle oinstall 16433152 Mar 24 17:22 control03.ctl
................
[oracle@server01 database]$ exit
exit
SQL> startup #重启数据库
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 633343360 bytes
Database Buffers 192937984 bytes
Redo Buffers 6590464 bytes
Database mounted.
Database opened.
SQL> show parameter contr #查看当前控制文件存放路径
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /database/msp/control01.ctl, /
opt/oracle/fast_recovery_area/
msp/control02.ctl, /database/m
sp/control03.ctl
control_management_pack_access string DIAGNOSTIC+TUNING
============同样也可以通过PFILE去添加===================
SQL> create pfile from spfile;
File created.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> !
[oracle@server01 dbs]$ vi initmsp.ora
*.control_files='/database/msp/control01.ctl','/opt/oracle/fast_recovery_area/msp/control02.ctl','/database/msp/control03.ctl','/opt/oracle/fast_recovery_area/msp/cont
rol04.ctl' #新增副本存储路径
[oracle@server01 dbs]$ cd /opt/oracle/fast_recovery_area/
[oracle@server01 fast_recovery_area]$ cd msp/
[oracle@server01 msp]$ ll
total 16048
-rw-r----- 1 oracle oinstall 16433152 Mar 24 17:34 control02.ctl
[oracle@server01 msp]$ cp control02.ctl control04.ctl #拷贝副本
[oracle@server01 msp]$ ll
total 32096
-rw-r----- 1 oracle oinstall 16433152 Mar 24 17:34 control02.ctl
-rw-r----- 1 oracle oinstall 16433152 Mar 24 17:35 control04.ctl
SQL> startup pfile=$ORACLE_HOME/dbs/initmsp.ora #从PFILE启动数据库
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 633343360 bytes
Database Buffers 192937984 bytes
Redo Buffers 6590464 bytes
Database mounted.
Database opened. #启动过程不能正常mount数据库,可能是PFILE修改错误了
SQL> show parameter contr
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /database/msp/control01.ctl, /
opt/oracle/fast_recovery_area/
msp/control02.ctl, /database/m
sp/control03.ctl, /opt/oracle/
fast_recovery_area/msp/control
04.ctl
control_management_pack_access string DIAGNOSTIC+TUNING
SQL> create spfile from pfile; #从PFILE创建SPFILE
File created.
===============================================
获取控制文件信息:
检索。
? V$CONTROLFILE:列出与该例程相关联的所有控制文件
的名称和状态
? V$PARAMETER:列出所有参数的状态和位置
? V$CONTROLFILE_RECORD_SECTION:提供有关控制文件记录部分的信息
? SHOW PARAMETER CONTROL_FILES:列出控制文件的名称、状态和位置 #等同于查询V$PARAMETER
SQL> desc v$controlfile;
Name Null? Type
----------------------------------------- -------- ----------------------------
STATUS VARCHAR2(7)
NAME VARCHAR2(513)
IS_RECOVERY_DEST_FILE VARCHAR2(3)
BLOCK_SIZE NUMBER
FILE_SIZE_BLKS NUMBER
SQL> col name format a50; ##设置列格式规范化
SQL> select status,name from v$controlfile;
STATUS NAME
------- --------------------------------------------------
/database/msp/control01.ctl
/opt/oracle/fast_recovery_area/msp/control02.ctl
/database/msp/control03.ctl
/opt/oracle/fast_recovery_area/msp/control04.ctl
SQL> select type,records_total,records_used from v$controlfile_record_section;
TYPE RECORDS_TOTAL RECORDS_USED
---------------------------- ------------- ------------
DATABASE 1 1
CKPT PROGRESS 11 0
REDO THREAD 8 1
REDO LOG 32 3
DATAFILE 500 4
FILENAME 3114 11
TABLESPACE 500 5
TEMPORARY FILENAME 500 1
RMAN CONFIGURATION 50 0
LOG HISTORY 876 8
OFFLINE RANGE 572 0
TYPE RECORDS_TOTAL RECORDS_USED
---------------------------- ------------- ------------
ARCHIVED LOG 812 8
BACKUP SET 818 0
BACKUP PIECE 1000 0
BACKUP DATAFILE 1063 0
BACKUP REDOLOG 215 0
DATAFILE COPY 1000 0
BACKUP CORRUPTION 743 0
COPY CORRUPTION 818 0
DELETED OBJECT 818 0
PROXY COPY 1004 0
BACKUP SPFILE 131 0
TYPE RECORDS_TOTAL RECORDS_USED
---------------------------- ------------- ------------
DATABASE INCARNATION 292 1
FLASHBACK LOG 2048 0
RECOVERY DESTINATION 1 1
INSTANCE SPACE RESERVATION 1055 1
REMOVABLE RECOVERY FILES 1000 0
RMAN STATUS 141 0
THREAD INSTANCE NAME MAPPING 8 8
MTTR 8 1
DATAFILE HISTORY 57 0
STANDBY DATABASE MATRIX 31 31
GUARANTEED RESTORE POINT 2048 0
TYPE RECORDS_TOTAL RECORDS_USED
---------------------------- ------------- ------------
RESTORE POINT 2083 0
DATABASE BLOCK CORRUPTION 8384 0
ACM OPERATION 64 6
FOREIGN ARCHIVED LOG 1002 0
37 rows selected.
阅读(1182) | 评论(0) | 转发(0) |