Sunteți pe pagina 1din 7

Control Files

What is the purpose of control file

• To maintain the metadata about database


• Required during instance start up and regular
operations
• It is updated continuously and should be available all
the time to the instance.
• Database will stop functioning if control file is
damaged or lost

What is inside a control file


• It is a binary file. Do not edit it. Oracle processes
(lgwr-log seq no., ckpt-checkpoint info, arch-archive
log file name) write to control file.
• Database name (DB_NAME)
• Database creation timestamp
• Data files – name, location, online/offline status
• Redo log files – name, location
• Redo log archive information
• Tablespace names
• Current log sequence number – increases at log switch
• Most recent checkpoint information – Checkpoint occurs
when modified (committed and uncommitted) blocks are
written to data files.
• Begin and end of undo segments
• RMAN backup information
• SCN info for each datafile (start and stop SCN)

Note: Every three seconds, the checkpoint process (CKPT)


records information in the control file about the
checkpoint position in the online redo log. This
information is used during database recovery to tell Oracle
that all redo entries recorded before this point in the
online redo log file are not necessary for database
recovery; they were already written to the datafile.

Control File Contents(sections)


select type, record_size, records_used from
v$controlfile_record_section;

TYPE RECORD_SIZE RECORDS_USED


---------------------------- ----------- ------------
DATABASE 316 1
CKPT PROGRESS 8180 0
REDO THREAD 256 1
REDO LOG 72 3
DATAFILE 428 7
FILENAME 524 12
TABLESPACE 68 9
TEMPORARY FILENAME 56 2
RMAN CONFIGURATION 1108 0
LOG HISTORY 56 155
OFFLINE RANGE 200 0
ARCHIVED LOG 584 64
Size of control file depends upon MAX clauses in “create
database” command. – MAXLOGFILES, MAXLOGMEMBERS,
MAXDATAFILES

Why & how are control files multiplexed


Multiplexing is making & managing a mirrored copy of a file
for safety

• Safety
• Performance goes down but safety increases
• Oracle Multiplexing – use CONTROL_FILES parameter
1. Shut down the database.
2. Copy the control file to more locations by using
an operating system command.
3. Change the initialization parameter file to
include the new control file name(s) in the
parameter CONTROL_FILES
4. Start up the database.
• You can also use hardware mirroring (RAID 1) – DBA
will not be involved

Why & how is Control File created

• Why
• If you the DBA is stupid or unfortunate – all
control files are lost
• Want to change MAX clauses (MAXLOGFILES,
MAXLOGMEMBERS, MAXDATAFILES) in “create database”
command – poor planning on DBA’s part
• Change the name of the database – again, poor
planning

• How
o Shutdown the database
o Startup nomount – cannot execute startup mount
because we do not have the control file.
o Create control file using the following command.
It will create control file/s at the location
specified in CONTROL_FILES in init.ora
NORESETLOGS – means do not ignore the contents of
these redo log files.

o Alter database open


o Shutdown and the a cold backup

How and when to backup control file

• Anytime you make a structural change to the database.


o Add a new tablespace
o Add a file to a tablespace
o Mirrored redo logs
• Alter database backup controlfile to ‘/opt/ctrl.ctl’
reuse;
• Alter database backup controlfile to trace;  Check in
USER_DUMP_DEST
How to find more information about control file
What is SCN and How to find current SCN
• SCN (System Change Number) is the number of
transactions in oracle since the database was created.
• Whenever someone starts a query, there is a current
system SCN, say 490249. Now, every block's SCN is
compared to 490249. If this blocks SCN is grater this
490249 (that is, the block has been changed since the
query began), Oracle looks for a block that was actual
with SCN 490249. This is a consistent get.
• SQL> select current_scn from v$database;

CURRENT_SCN
-----------
4431570
Note: SCN in data file header should match with SCN in
control file at instance startup.

What is a checkpoint and how to find current checkpoint


• Checking is flushing of buffer cache to datafile
(committed or uncommitted)
• A checkpoint performs the following three operations:
• Every dirty block in the buffer cache is written to
the data files. That is, it synchronizes the
datablocks in the buffer cache with the datafiles on
disk.
• The latest SCN is written (updated) into the
datafile header (ckpt).
• The latest SCN is also written to the controlfiles
(ckpt)

SQL>select checkpoint_change# from v$database

CHECKPOINT_CHANGE#

------------------

4433137

Why checkpoints are done

• For faster recovery – in case of an instance


crash(shutdown abort)

When does checkpoint happen

• At log switch (alter system switch logs)


• Alter system checkpoint;
• When database is shutdown
• When tablespace status is changed to read only
• When tablesapce is put in backup mode
• FAST_START_MTTR_TARGET (in seconds)
Initialization Parameters Discussed in this section

• DB_NAME
• CONTROL_FILES
• USER_DUMP_DEST
• FAST_START_MTTR_TARGET

Commands discussed in this section

• Create controlfile
• Startup nomount
• Alter database open
• Alter database backup controlfile to ‘/opt/ctrl.ctl’
reuse;
• Alter database backup controlfile to trace
• Show parameter control_files
• Alter system switch logs;
• Alter system checkpoint;

Data Dictionary views discussed in the section


• V$datafile
• V$controlfile
• V$controlfile_record_sections
• V$database

S-ar putea să vă placă și