Oracle Architectural Components PDF
Oracle Architectural Components PDF
Components
Date: 14.10.2009
Instructor: Sl. Dr. Ing. Ciprian Dobre
1
Overview of Primary Components
Instance
User
process Shared Pool SGA
An Oracle server:
Oracle server
• Is a database management
system that provides an
open, comprehensive,
integrated approach to
information management
• Consists of an Oracle
instance and an Oracle
database
Oracle Server
The Oracle server is the key to information management. In general, an Oracle
server must reliably manage a large amount of data in a multiuser environment
so that many users can concurrently access the same data. All this must be
accomplished while delivering high performance. An Oracle server must also
prevent unauthorized access and provide efficient solutions for failure recovery.
3
Oracle Instance
An Oracle instance:
• Is a means to access an Oracle database
• Always opens one and only one database
• Consists of memory and background process
structures
Instance
Shared Pool SGA
Memory
Library Redo Log structures
Database
Cache Buffer
Buffer Cache
Data Dictionary
Cache Java Pool Large Pool
Background
PMON SMON DBWR LGWR CKPT Others process structures
Oracle Instance
An Oracle instance consists of the System Global Area (SGA) memory structure
and the background processes that are used to manage a database. An instance
is identified by using methods specific to each operating system. The instance
can open and use only one database at a time.
4
Establishing a Connection
and Creating a Session
Database user
An Oracle database:
• Is a collection of data that is treated as a unit
• Consists of three file types
Oracle Database
Redo
Parameter Data Control Log Archived
files files
file files Log files
Password
file
Oracle Database
The general purpose of a database is to store and retrieve related information.
An Oracle database has a logical and a physical structure. The physical
structure of the database is the set of operating system files in the database. An
Oracle database consists of three file types.
Data files containing the actual data in the database
Online redo log files containing a record of changes made to the database
to enable recovery of the data in case of failures
Control files containing information necessary to maintain and verify
database integrity
Other Key File Structures
The Oracle server also uses other files that are not part of the database:
The parameter file defines the characteristics of an Oracle instance. For
example, it contains parameters that size some of the memory structures
in the SGA.
The password file authenticates users privileged to start up and shut
down an Oracle instance.
Archived redo log files are offline copies of the online redo log files that
may be necessary to recover from media failures.
6
Physical Structure
Header
Control
Data files
files
Online (includes
Redo Log Data
files Dictionary)
Physical Structure
The physical structure of an Oracle database includes three types of files: control
files, data files, and online redo log files.
7
Memory Structure
8
System Global Area
9
System Global Area
• Is dynamic
• Sized by the SGA_MAX_SIZE parameter
• Allocated and tracked in granules by SGA
components
– Contiguous virtual memory allocation
– Granule size based on total estimated SGA_MAX_SIZE
10
Shared Pool
• Used to store:
– Most recently executed SQL statements
– Most recently used data definitions
• It consists of two key performance-related memory
structures:
– Library Cache
– Data Dictionary Cache
Shared Pool
• Sized by the parameter Library
SHARED_POOL_SIZE Cache
Data
ALTER SYSTEM SET Dictionary
SHARED_POOL_SIZE = 64M; Cache
Shared Pool
The Shared Pool environment contains both fixed and variable structures. The
fixed structures remain relatively the same size, whereas the variable structures
grow and shrink based on user and program requirements. The actual sizing for
the fixed and variable structures is based on an initialization parameter and the
work of an Oracle internal algorithm.
Sizing the Shared Pool
Because the Shared Pool is used for objects that can be shared globally, such
as reusable SQL execution plans, PL/SQL packages, procedures, functions, and
cursor information, it must be sized to accommodate the needs of both the fixed
and variable areas. Memory allocation for the Shared Pool is determined by the
SHARED_POOL_SIZE initialization parameter. It can be dynamically resized
using ALTER SYSTEM SET. After performance analysis, this can be adjusted
but the total SGA size cannot exceed SGA_MAX_SIZE.
11
Library Cache
Library Cache
The Library Cache size is based on the sizing defined for the Shared Pool.
Memory is allocated when a statement is parsed or a program unit is called. If
the size of the Shared Pool is too small, statements are continually reloaded into
the Library Cache, which affects performance. The Library Cache is managed by
an LRU algorithm. As the cache fills, less recently used execution paths and
parse trees are removed from the Library Cache to make room for the new
entries. If the SQL or PL/SQL statements are not reused, they eventually are
aged out.
The Library Cache consists of two structures:
Shared SQL: The Shared SQL stores and shares the execution plan and
parse tree for SQL statements run against the database. The second time
that an identical SQL statement is run, it is able to take advantage of the
parse information available in the shared SQL to expedite its execution.
To ensure that SQL statements use a shared SQL area whenever
possible, the text, schema, and bind variables must be exactly the same.
Shared PL/SQL: The Shared PL/SQL area stores and shares the most
recently executed PL/SQL statements. Parsed and compiled program
units and procedures (functions, packages, and triggers) are stored in this
area.
12
Data Dictionary Cache
13
Database Buffer Cache
Database Buffer
Cache
14
Database Buffer Cache
15
Redo Log Buffer
Redo Log
Buffer
16
Large Pool
Large Pool
By allocating session memory from the Large Pool for Shared Server, Oracle
XA, or parallel query buffers, Oracle can use the Shared Pool primarily for
caching Shared SQL statements. Thus relieving the burden on areas within the
Shared Pool. The Shared Pool does not have to give up memory for caching
SQL parse trees in favor of Shared Server session information, I/O, and backup
and recover processes. The performance gain is from the reduction of overhead
from increasing and shrinkage of the shared SQL cache.
Backup and Restore
Recovery Manager (RMAN) uses the Large Pool when the BACKUP_DISK_IO=n
and BACKUP_TAPE_IO_SLAVE=TRUE parameters are set. If the Large Pool is
configured but is not large enough, the allocation of memory from the Large Pool
fails. RMAN writes an error message to the alert log file and does not use I/O
slaves for backup or restore.
Parallel Execution
The Large Pool is used if PARALLEL_AUTOMATIC_TUNING is set to TRUE,
otherwise, these buffers are allocated to the Shared Pool.
17
Java Pool
Java Pool
The Java Pool is an optional setting but is required if you are installing and using
Java. Its size is set, in bytes, using the JAVA_POOL_SIZE parameter. In
Oracle9i, the default size of the Java Pool is 24 MB.
18
Program Global Area
19
Process Structure
20
User Process
Server
process
User
process
Connection
established
Database user
User Process
A database user who needs to request information from the database must first
make a connection with the Oracle server. The connection is requested using a
database interface tool, such as SQL*Plus, and beginning the user process. The
user process does not interact directly with the Oracle server. Rather it
generates calls through the user program interface (UPI), which creates a
session and starts a server process.
21
Server Process
Database user
Server Process
Once a user has established a connection, a server process is started to handle
the user processes requests. A server process can be either a dedicated server
process or a shared server process. In a dedicated server environment, the
server process handles the request of a single user process. Once a user
process disconnects, the server process is terminated. In a shared server
environment, the server process handles the request of several user processes.
The server process communicates with the Oracle server using the Oracle
Program Interface (OPI).
Note: Allocation of server process in a dedicated environment versus a shared
environment is covered in further detail in the Oracle9i Database Performance
Tuning course.
22
Background Processes
Background Processes
The Oracle architecture has five mandatory background processes that are
discussed further in this lesson. In addition to the mandatory list, Oracle has
many optional background process that are started when their option is being
used. These optional processes are not within the scope of this course, with the
exception of the background process, ARCn. Following is a list of some optional
background processes:
ARCn: Archiver
CJQ0: Coordinator Job Queue background process
Dnnn: Dispatcher
LCKn: RAC Lock Manager–Instance Locks
LMDn: RAC DLM Monitor–Remote Locks
LMON: RAC DLM Monitor–Global Locks
LMS: RAC Global Cache Service
Pnnn: Parallel Query Slaves
QMNn: Advanced Queuing
RECO: Recoverer
Snnn: Shared Server
23
Database Writer (DBWn)
Redo
Data Control Log
files files files
Database
25
System Monitor (SMON)
Instance Responsibilities:
SGA • Instance recovery
– Rolls forward
changes in online
redo log files
SMON – Opens database
for user access
Redo
– Rolls back
Data Control Log uncommitted
files files files
transactions
• Coalesces free space
Database
• Deallocates
temporary segments
27
Checkpoint (CKPT)
Instance
SGA
Responsible for:
• Signaling DBWn at
checkpoints
• Updating datafile
headers with
DBWn LGWR CKPT
checkpoint
information
• Updating control
Redo
Data Control Log files with checkpoint
files files files information
Database
Checkpoint (CKPT)
Every three seconds the CKPT process stores data in the control file to identify
that place in the online redo log file where recovery is to begin, which is called a
checkpoint. The purpose of a checkpoint is to ensure that all of the buffers in the
Database Buffer Cache that were modified prior to a point in time have been
written to the data files. This point in time (called the checkpoint position) is
where database recovery is to begin in the event of an instance failure. DBWn
will already have written all of the buffers in the Database Buffer Cache that were
modified prior to that point in time. Prior to Oracle9i, this was done at the end of
the online redo log file. In the event of a log switch CKPT also writes this
checkpoint information to the headers of the data files.
Checkpoints are initiated for the following reasons:
To ensure that modified data blocks in memory are written to disk
regularly so that data is not lost in case of a system or database failure.
To reduce the time required for instance recovery. Only the online redo
log file entries following the last checkpoint need to be processed for
recovery to occur.
To ensure that all committed data has been written to the data files during
shut down.
Checkpoint information written by CKPT includes checkpoint position, system
change number, location in the online redo log file to begin recovery, information
about logs, and so on. 28
Archiver (ARCn)
Redo ARCn
Data Control log Archived
files files redo log
files files
Archiver (ARCn)
ARCn is an optional background process, however, it is crucial to recovering a
database after the loss of a disk. As online redo log files get filled, the Oracle
server begins writing to the next online redo log file. The process of switching
from one online redo log file to another is called a log switch. The ARCn process
initiates backing up, or archiving, of the filled log group at every log switch. It
automatically archives the online redo log file before the log can be reused, so all
of the changes made to the database are preserved. This enables recovery of
the database to the point of failure even if a disk drive is damaged.
Archiving Online Redo Log Files
One of the important decisions that a DBA has to make is whether to configure
the database to operate in ARCHIVELOG or in NOARCHIVELOG mode.
NOARCHIVELOG mode: In NOARCHIVELOG mode, the online redo log files are
overwritten each time a log switch occurs. LGWR does not overwrite an online
redo log file group until the checkpoint for that group is complete. This ensures
that committed data can be recovered if there is an instance crash. During the
instance crash, only the SGA is lost. There is no loss of disks, only memory. For
example, an operating system crash causes an instance crash.
29
Logical Structure
Datafile
Segment Segment
Extent Blocks
Logical Structure
A logical structure hierarchy exists as follows:
An Oracle database contains 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.
The Oracle database architecture includes logical and physical structures that
make up the database.
The physical structure includes the control files, online redo log files, and
data files that make up the database.
The logical structure includes tablespaces, segments, extents, and data
blocks.
The Oracle server enables fine-grained control of disk space use through
tablespace and logical storage structures, including segments, extents, and data
blocks.
30
Processing SQL Statements
31
SQL Statement Processing Phases
Open Close
Processing Phases
The four most important phases in SQL statement processing are parsing,
binding, executing, and fetching.
The reverse arrows indicate processing scenarios; for example, Fetch—
(Re)Bind—Execute—Fetch.
The Fetch phase applies only to queries and DML statements with a returning
clause.
32