Вы находитесь на странице: 1из 5

Oracle Database Architecture overview -1-

There are two terms that are used with Oracle

• Database - A collection of physical operating system files


• Instance - A set of Oracle processes and a SGA (allocation of memory)

These two are very closely related but a database can be mounted and opened by many instances. An instance
may mount and open only a single database at any one point in time.

The File Structure

The are a number of different file types that make up a database

• Parameter File - These files tells Oracle were to find the control files. Also they detail how big the
meory area will be, etc
• Data Files - These hold the tables indexes and all other segments
• Temp Files - used for disk-based sorting and temporary storage
• Redo Log Files - Our transaction logs
• Archive Log Files - Redo log files which have been archived
• Control File - Details the location of data and log files and other relevant information about their state.
• Password File - Used to authenticate users logining into the database.
• Log files - alert.log contains database changes and events including startup information, trace files are
debugging files.

Parameter Files

The parameter file for Oracle is the commonly know file init.ora (or init<oracle sid>.ora). The file itself is a
very simple plain text file (on oracle >9i it can also be a binary file called spfile.ora) and details information
regarding block size, location of the control files, etc. On a windows server the file can be found in
[ORACLE_HOME]/admin/<sid>/pfile but can be in any location by using the "startup pfile = <location>" .
Sometimes a parameter may start with a underscore this normally refers to a undocumented parameter and is
normally only requested by Oracle support.

The main difference between the spfile and pfile is that instance parameters can be changed dynamically using a
spfile, where as you require a instance reboot to load pfile parameters.

Data Files

Normally there are at least two data files, one for system data and the other sysaux data .

• Segments - are database objects, a table, a index, rollback segments. Every object that consumes space is
a segment. Segments themselves consist of one or more extents.
• Extents - are a contiguous allocation of space in a file. Extents, in turn, consist of data blocks
• Blocks - are the smallest unit of space allocation in Oracle. Blocks normally are 2KB, 4KB, 8KB, 16KB
or 32KB in size but can be larger.

The relationship between segments, extents and blocks looks like this
Oracle Database Architecture overview -2-

The parameter DB_BLOCK_SIZE determines the default block size of the database. determining the block size
depends on what you are going to do with the database, if you are using small rows then use a small block size
(oracle recommends 8KB), if you are using LOB's then the block size should be larger.

You can have different block sizes within the database, each tablespace having a different block size depending
on what is storaged in the tablespace.

A data block will be made up of the following, the two main area's are the free space and the data area.

contains information regarding the type of block (a table block, index block, etc), transaction
Header information regarding active and past transactions on the block and the address (location) of the
block on the disk
Table Directory contains information about the tables that store rows in this block
contains information describing the rows that are to be found on the block. This is an array of
Row Directory
pointers to where the rows are to be found in the data portion of the block.
The three above pieces are know as the Block Overhead and are used by Oracle to manage the
Block overhead
block itself.
Free space available space within the block
Data data within the block

Temp Files
Oracle Database Architecture overview -3-

Oracle will use temorary files to store results of a large sort operation when there is insufficient memory to hold
all of it in RAM. Temporary files never have redo generaed for them, although they have UNDO generated.
Temporary data files never need to be backed up.

Redo log files

All the Oracle changes made to the db are recorded in the redo log files, these files along with any archived redo
logs enable a dba to recover the database to any point in the past. Oracle will write all commited changes to the
redo logs first before applying them to the data files. The redo logs guarantee that no committed changes are
ever lost. Redo log files consist of redo records which are group of change vectors each referring to specific
changes made to a data block in the db. The changes are first kept in the redo buffer but are quickly written to
the redo log files.

There are two types of redo log files online and archive. Oracle uses the concept of groups and a minimum of 2
is required each group having at least one file they are used in a circular fashion when one group fills up oracle
will switch to the next log group.

For more informtion on how to configure and maintain redo log on Oracle Redo.doc.

Archive Redo log

When a redo log file fills up and before it is used again the file is archived for safe keeping, this archive file
with other redo log files can recover a database to any point in time. It is best practice to turn on
ARCHIVELOG mode which performs the archiving automatically.

Control file

The control is one of the most important files within Oracle, the file contains data and redo log location
information, current log sequence numbers, backup set details and the SCN. This file should have multiple
copies due to it's importance. This file is used in recovery as the control file notes all checkpoint information
which allows oracle to recover data from the redo logs. This file is the first file that Oracle consults when
starting up.

The view V$CONTROLFILE can be used to list the control files.

See Oracle recover critical files.doc for control file recovery.

Password file

This file optional and contains the names of the database users who have been granted the special SYSDBA and
SYSOPER admin privilege.

Log files

The alert.log file contains important startup information major database changes and system events, this will
probably be the first file that will be looked when you have database issues. The file contains log switches, db
errors, warnings and other messages.If this file is removed Oracle creates another one automatically. Traces files
Oracle Database Architecture overview -4-

are debugging files which can trace background process information (LGWR, DBWn, etc), core dump
information (ora-600 errors, etc) and user processing information (SQL).

Tablespaces

A tablespace is a container which holds segments. Each and every segment belongs to exactly one tablespace.
Segments never cross tablespace boundaries. A tablespace itself has one or more files associated with it. An
extent will be contained entirely within one data file.

So in summary the Oracle hierarchy is as follows:

• A database is made up of one or more tablespaces


• A tablespace is made up of one or more data files, a tablespace contains segments
• A segment (table, index, etc) is made up of one or more extents. A segment exists in a tablespace but
may have data in many data files within a tablespace.
• An extent is a continuous set of blocks on a disk. An extent is in a single tablespace and is always in a
single file within that tablespace.
• A block is the smallest unit of allocation in the database. A block is the smallest unit of i/o used by the
database.

The minimum tablespaces required are the system and sysaux tablepsaces, the following reasons are why
tablespaces are used.

• Tablespaces make it easier to allocate space quotas to users in the database


• Tablespaces enable you to perform partial backups and recoveries based on the tablespace as a unit
• Tablespaces can be allocated to different disks and controllers to improve performance
• You can take tablespaces offline without affecting the entire database
• You can import and export specific application data by using the import and export utilities at the
tablespace.

Tablespaces can be manged either locally or by the data dictionary

Space information is stored within the data files and are tracked by bitmaps. The data dicitonary
Locally is not used so recursive SQL operations are significantly reduced. This is the default option
when you create a tablespace in Oracle 10g.
The data dictionary is used to store space information, recursive SQL operations are used to
Dictionary
retrieve this information which generates undo activity which can produce performance issues

There are a number of types that a tablespace can be

• Bigfile tablespaces, will have only one file which can range from 8-128 terabytes.
• Smallfile tablespaces (default), can have multiple files but the files are smaller than a bigfile tablespace.
• Temporary tablespaces, contain data that only persists for the duration a users session, used for sorting
• Permanent tablespaces, any tablespace that is not temporary one.
• Undo tablespaces, Oracle uses this to rollback or undo changes to the db.
• Read-only, no write operations are allowed.
Oracle Database Architecture overview -5-

See Oracle tablespaces.doc for information regarding tablespaces such as creating, resizing, etc

Oracle Managed Files

The OMF feature aims to set a standard way of laying out Oracle files, there is no need to worry about file
names and the physical location of the files themselves. The method is suited in small to meduim environments,
OMF simplifies the initial db creation as well as on going file management.

System change number (SCN)

The SCN is an important quantifier that oracle uses to keep track of its state at any given point in time. The
SCN is used to keep track of all changes within the database, its a logical timestamp that is used by oracle to
order events that have occurred within the database. SCN's are increasing sequence numbers and are used in
redo logs to confirm that transactions have been comitted, all SCN's are unique. SCN's are used in crash
recovery as the control maintains a SCN for each datafile, if the datafiles are out of sync after a crash oracle can
reapply the redo log information to bring the database backup to the point of the crash. You can even take the
database back in time to a specific SCN number (or point in time).

Вам также может понравиться