Sie sind auf Seite 1von 21

ORACLE FUNDAMENTALS

ORACLE ARCHITECTURE

ORACLE INSTANCE ORACLE FILE STRUCTURE


(Physical Structure)
Shared pool
Operating System Files
Large Pool
Data Buffer Cache Data Files
Redo Log Buffer Control Files
Java Pool Redo Log Files
Large Pool Parameter File
Archive Files
Password File
INSTANCE
User
Process SGA
Shared Pool

Data Buffer Cache Redo Log Buffer


Library Cache
Server
Process
Data Dictonary Cache Java Pool Large Pool

PMO SMO DBW LGW CKPT OTRS


N N R R

Parameter File Archive Files


Data File Control File Redo Log File

Password File
ORACLE INSTANCE

INSTANCE
MEMORY
STRUCTURES Shared Pool SGA

Library Cache Data Buffer Cache Redo Log Buffer

Data Dictonary Cache Java Pool Large Pool

BGD PMO SMO DBW LGW CKPT OTRS


PROCESSES N N R R

An Oracle Instance :
Is a means to access the database.
Opens one and only one Database at a time.(Database can be identified by an
environmental variable ORACLE__SID.)
Consists of Memory structures (SGA) and Background Process Structures
Memory Structures consist of 2 memory areas :
SGA (System Global Area) :
Allocated at Instance startup and primary component of an oracle Instance.
Consists of several memory structures:
Shared Pool-- Contains recently used SQL stmts.
Database Buffer cache-- Contains recently used data blocks.
Redo Log buffer -- redo log entries which are written to redo logs
Other structures (like statistical data)
Background Process Structures :
This contains the background processes.
DBWR-- Data Base Writer process (can have upto 10 DBWR processes)
LGWR-- Log Writer process.
ARCN -- Archive process.
SMON -- System Monitor process
PMON -- Process Monitor process.
ORACLE DATABASE (Physical (file) structure)
Parameter File Archive Files
Data File Control File Redo Log File

Password File

DATABASE

An Oracle Database :
Is a collection of data that is treated as unit.
Is a set/collection of Operating system files.
Consists of 3 types of files :
Data files containing actual data in the database.
Online Redo log files containing record of changes made to the
database to enable recovery of data in case of failures.
Control files containing information necessary to maintain and verify database
integrity.Control file is the most important file of oracle database and hence must
be multiplexed (backed up).If any of the control file gets corrupted or is lost we
cannot start the database.

Other file structures :


The Parameter file defines the characteristics of the oracle instance.For
example,it contains parameters that size some of the memory structures in the
SGA.
The Password file user privileges for start up and shut down the oracle
instance.
Archive Redo log files are the offline copies of online redo log files that may
be necessary to recover from media failures.
ORACLE PROCESSES AND FILES

Data Files Redo Log Archive Control

CKPT R/W R/W

DBWn W

W R/W
LGWR

ARCn R W R/W

R/W R W R/W
Server
INITIALIZATION PARAMETER FILE
Entries are specific to the instance being started.
Changes in the file take effect based on the type of initialization parameter file
used.
Static Parameter file (PFILE) : If database is running using PFILE then
oracle must be shut down and restarted again in order to make the changes
take effect.Commonly referred as initSID.ORA
Persistent Server Parameter file (SPFILE) : This is a new concept from
Oracle 9i.This file does not exist in earlier versions.If database is running
using this file then changes can be made to take effect while database is up
and running.But only dynamic parameters can be changed.By using this file
changes can be made temporarily or permanent. Commonly referred as
spfile SID.ORA
STARTING UP AND SHUTTING DOWN DB
For starting up and shutting down the Database you user must have SYSDBA
privilege.
Starting up the database

STARTUP OPEN

Opening of online data files and


MOUNT online redo log files. If in
inconsistent state error is reported.
Locating and opening the control files specified in
the parameter file to obtain the status of the data
NO MOUNT
files and redo log files.

Instance started : Initialization parameter file is read ,


SHUTDOWN SGA is allocated , BG processes are started ,
AlertSID.LOG & alert files are opened.
Shutting Down the Data Base

Various Shut Down Modes :

Shut Down Modes A I T N

Allow New connections No No No No

Wait Until current sessions end No No No Yes

Wait until current transactions end No No Yes Yes

Force a check point and close the files No Yes Yes Yes

A : Abort T : Transactional

I : Immediate N : Normal
Contd...
When database is shut down using Normal/Immediate/Transactional options :
Data base buffer cache written to the Data files.
Uncommitted changes are rolled back.
All resources are released.
Database is in clean and consistent state.
No Instance Recovery is required for next start up.
When database is shut down using Abort option or there is instance failure :
Modified Data base buffers are not written to the Data files.
Uncommitted changes are not rolled back.
Database is in dirty and inconsistent state.
Undo segments are used to roll back uncommitted changes.
Resources are released.
Abort option is used if all other options fail.
DIAGNOSTIC FILES FOR MONITORING
Alert Log file
Records commands and results of major events.(e.g. tablespace offline)
Used for day-to-day operational information.
Used for diagnosing database errors.
Each entry has a particular time stamp associated with it.
This file must be maintained by DBA
Location is defined by Parameter BACKGROUND_DUMP_DEST
Back Ground Trace Files
Log errors detected by any back ground processes.
Created when back ground process encounters an error.
Location is defined by Parameter BACKGROUND_DUMP_DEST
User Trace Files
Produced by user process.can also generated by server process
Contains stats for traced SQL stmts.
Location defined by parameter USER_DUMP_DEST
REDO LOG FILES & ARCHIVE FILES
ONLINE REDO LOG FILES

Online Redo log files contain the changes made to the database to enable
recovery of data in case of failures.
Online redo log files are managed according to groups which in turn contain
log members (actual OS files).This is done for multiplexing of online redo log
files.All entries are written simultaneously to all log members.Ideally log
members of same group must be placed on separate disks.
Online redo log groups are used in cyclic fashion.As online redo log files get
filled,oracle starts writing to next online redo log file.Switching from one online
redo log file to another is called as log switch.

GROUP 1 GROUP 2 GROUP 3


Log file 1 Log file 2 Log file 3

Log file 4 Log file 5 Log file 6


ARCHIVE LOG FILES

Archive log files are offline backup of the online redo log files.
A production server must be in the Archive Log mode.
As redo logs are used in cyclic fashion.The inactive groups of filled online redo
log files must be archived before they can be reused.This is a sort of backup of
the redo log groups.This is done only if the database is running in the Archive log
mode.If database is not running in Archive log mode then the contents of redo log
files are overwritten.
ARCn process is used by oracle to archive the online redo log files.
Setting the database in the Archive mode ensures minimum (almost nil) data
loss in case of database failures.
DBA can use the physical backup of the data files and the archived redo
log files to recover the database without losing any committed data because
of any single point of failure,including the loss of a disk.

Properly managed databases have their redo log files and archive log files on
different disks.
LOGICAL STRUCTURE

Table Space

Data File
Segment Segment

Data Blocks
Extents
Hierarchy of the Logical structure is as follows :
An Oracle database consists at least one tablespace.
A tablespace contains one or more segments.
A segment is made up of extents.
An extent is made up of logical blocks.
A block is the smallest unit for read and write operations.

An oracle database architecture includes logical and physical structures that make
up the database.
The physical structure includes control file,data files and online redo log files
that make up the database.
The logical structure includes the Tablespaces,segments,extents and data blocks.
TABLESPACES

A Tablespace is a logical structure of the database which contain one or more


data files(operating system files).
A database contains at least one tablespace I.e. System Tablespace.
A tablespace can belong to one and only one database at a time.
A table space may contain one or more segments.
A Table space can be brought online while database is up and running.
Except the system table space or a tablespace with active undo
segment,tablespace can be taken offline,leaving database running.
The size of the tablespace can be increased by the addition of a data file,size of
which is specified at the time of addition.
Ideally tablespaces for tables and tablespaces for indexes are placed on separate
disk.
Ideally system tablespace should not contain the objects other than data
dictionary or system objects.
SPACE MANAGEMENT IN TABLESPACES

Locally Managed Tablespaces :


Free extents are managed in the tablespace itself.
Bit map is used to record the free extents.
Each bit corresponds to a block or a group of blocks.
Bit value indicated free or used.
It reduces the contention on Data dictionary tables.
It is a default beginning with Oracle 9i.

Dictionary Managed Tablespaces :


Free extents are managed by the data dictionary.(This can increase the contention
on data dictionary tables)
Appropriate tables in data dictionary are updated when extents are allocated or
de-allocated.
Coalescing is required.
UNDO TABLESPACE

This is a new concept from Oracle 9i onwards.In earlier versions Undo data was
managed by rollback segments.
This is used to store undo segments.
Cannot contain any other objects.
Extents are locally managed.
Can have more than one UNDO tablespaces but only one is active at a time.
It is used by a transaction which is making changes to the database.Before
changing the data or index blocks the old image of the data is stored in UNDO
tablespace which allows the user to undo the changes made.
When transaction is rolled back,the old image of the data is restored back from
undo tablespace.
UNDO tablespace ensures the data consistency.
OPTIMIZERS
There are 2 kinds of optimizers in Oracle.
Cost Based Optimizer (CBO) :
This optimizer relies heavily on the accuracy of the statistics gathered of the
objects.If the data is frequently modified ,then the statistics become stale
rapidly.In that case the performance of some queries may get affected,therefore
degrading the performance of the database.If the statistics of the objects are
found stale then they must be refreshed by using either COMPUTE or
ESTIMATE options.But you should not use the COMPUTE option during peak
hours because it locks a table while it gathers the statistics.

Rule Based Optimizer (RBO) :


This optimizer relies heavily on the data dictionary information about structure of
referenced objects and the syntax of the SQL statements.

** In SAP the default optimizer used is CBO **

Das könnte Ihnen auch gefallen