Oracle Architecture EASY

49
8/8/2019 Oracle Architecture EASY http://slidepdf.com/reader/full/oracle-architecture-easy 1/49  Basic Oracle Architecture Basic Oracle Architecture Presented to HIOUG Presented to HIOUG 21-Jun-2005 21-Jun-2005 By Byron Bush By Byron Bush

Transcript of Oracle Architecture EASY

Page 1: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 1/49

 

Basic Oracle ArchitectureBasic Oracle Architecture

Presented to HIOUGPresented to HIOUG21-Jun-200521-Jun-2005

By Byron BushBy Byron Bush

Page 2: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 2/49

 

Workshop ObjectivesWorkshop Objectives

• Identify high-level architecturalcomponents of an Oracle Database

• Describe the function of each of these

components• Identify Oracle Database internal data

structures

• Define the mechanisms used whenprocessing Insert/Update/Deletestatements

Page 3: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 3/49

 

Most people call it a “Database”Most people call it a “Database”

Technically an Oracle Database is broken

into two high-level components

1. INSTANCE – Non-persistent, memory-

based processes and structures

2. DATABASE – Persistent, disk-based data

and control files

Page 4: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 4/49

 

So Why Differentiate?So Why Differentiate?

Most Oracle installations consist of only a

single “Instance” and single “Database”…

Instance

Database

Page 5: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 5/49

 

Oracle RAC is DifferentOracle RAC is Different

Oracle “Real Application Clusters” allow

multiple “Instances” to interact with a

single “Database” to provide high

availability…

Instance 1

Database

Instance 3Instance 2

Page 6: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 6/49

 

““Instance” a Little Closer Instance” a Little Closer 

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

Page 7: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 7/49

 

Picture of an “Instance”Picture of an “Instance”

Instance

Library

Cache

Data

Dictionary

Cache

Shared PoolSGA

Database Buffer 

Cache

Redo Log

Buffer 

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-Ground

Processes

Page 8: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 8/49

 

““Database” a Little Closer Database” a Little Closer 

An Oracle Database…

 – Is a collection of data that is treated as a unit

 – Consists of three file types

Page 9: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 9/49

 

Picture of a “Database”Picture of a “Database”

Archived

Log Files

Parameter 

File

Password

File

Oracle Database

Data Files Control Files Redo Log Files

Page 10: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 10/49

 

Picture of an “Instance”Picture of an “Instance”

Instance

Library

Cache

Data

Dictionary

Cache

Shared PoolSGA

Database Buffer 

Cache

Redo Log

Buffer 

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-Ground

Processes

Page 11: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 11/49

 

Memory StructureMemory Structure

Oracle’s memory structure consists of two

memory areas known as:

1. System Global Area (SGA): Allocated at

instance start up, and is a fundamental

component of an Oracle Instance

2. Program Global Area (PGA): Allocated

when the server process is started

Page 12: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 12/49

 

System Global AreaSystem Global Area

• The SGA consists of several memory structures:

 – Shared Pool

 – Database Buffer Cache

 – Redo Log Buffer  – Other structures

• There are two additional memory structures that

can be configured within the SGA:

 – Large Pool

 – Java Pool

Page 13: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 13/49

 

System Global AreaSystem Global Area

• The size of the SGA is determined by the

parameters that set the sizes of the

various pools; these parameters are

dynamic

• The SGA_MAX_SIZE parameter sets the

maximum size of the SGA (so you can

limit it) and is not a dynamic parameter 

Thanks Ned!

Page 14: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 14/49

 

Picture of an “Instance”Picture of an “Instance”

Instance

Library

Cache

Data

Dictionary

Cache

Shared PoolSGA

Database Buffer 

Cache

Redo Log

Buffer 

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-Ground

Processes

Page 15: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 15/49

 

Shared PoolShared Pool

• Used to store: – Most recently executed SQL statements

 – Most recently used data definitions

• It consists of two key performance-relatedmemory structures: – Library Cache

 – Data Dictionary Cache• Sized by the parameter 

SHARED_POOL_SIZE

Page 16: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 16/49

 

Library CacheLibrary Cache

• Stores information about the most recently usedSQL and PL/SQL statements

• Enables the sharing of commonly used

statements• Is managed by a least recently used (LRU)algorithm

• Consists of two structures

 – Shared SQL area – Shared PL/SQL area

• Size is determined by the Shared Pool sizing

Page 17: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 17/49

 

Picture of an “Instance”Picture of an “Instance”

Instance

Library

Cache

Data

Dictionary

Cache

Shared PoolSGA

Database Buffer 

Cache

Redo Log

Buffer 

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-Ground

Processes

Page 18: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 18/49

 

Data Dictionary CacheData Dictionary Cache

• A collection of the most recently useddefinitions in the database

• Includes information about database files,

tables, indexes, columns, users,privileges, and other database objects

• During the parse phase, the server 

process looks at the data dictionary for information to resolve object names andvalidate access

Page 19: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 19/49

 

Database Buffer CacheDatabase Buffer Cache

• Stores copies of data blocks that have

been retrieved from the data files

• Enables great performance gains when

you obtain and update data

• Managed through an LRU algorithm

• DB_BLOCK_SIZE determines primaryblock size

Page 20: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 20/49

 

Picture of an “Instance”Picture of an “Instance”

Instance

Library

Cache

Data

Dictionary

Cache

Shared PoolSGA

Database Buffer 

Cache

Redo Log

Buffer 

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-Ground

Processes

Page 21: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 21/49

 

Redo Log Buffer Redo Log Buffer 

• Records all changes made to the

database data blocks

• Primary purpose is recovery

• Changes recorded within are called redo

entries

• Redo entries contain information toreconstruct or redo changes

• Size defined by LOG_BUFFER

Page 22: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 22/49

 

Large PoolLarge Pool

• An optional area of memory in the SGA

• Relieves the burden place on the Shared Pool

• Used for:

 – Session memory for the Shared Server 

 – I/O server processes

 – Backup and restore operations for RMAN

• Does not use an LRU list• Sized by LARGE_POOL_SIZE

• Can be dynamically resized

Page 23: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 23/49

 

Java PoolJava Pool

• Services parsing requirements for Java

commands

• Required if installing and using Java

• Sized by JAVA_POOL_SIZE parameter 

Page 24: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 24/49

 

Oracle “Process” StructureOracle “Process” Structure

• Oracle takes advantage of various types

of Processes:

 – User Process: Started at the time a database

user requests connection to the Oracle Server 

 – Server Process: Connects to the Oracle

instance and is started when a user 

establishes a session – Background Processes: Started when an

Oracle instance is started

Page 25: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 25/49

 

User ProcessUser Process

• A program that requests interaction with the

Oracle server 

• Must first establish a connection

• Does not interact directly with the Oracle server 

Server 

Process

User 

ProcessConnection

Established

Page 26: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 26/49

 

Server ProcessServer Process

• A program that directly interacts with the

Oracle server 

• Fulfills calls generated and returns results

• Can be dedicated or shared server 

Page 27: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 27/49

 

Picture of an “Instance”Picture of an “Instance”

Instance

Library

Cache

Data

Dictionary

Cache

Shared PoolSGA

Database Buffer 

Cache

Redo Log

Buffer 

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

MemoryStructures

Back-Ground

Processes

Page 28: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 28/49

 

Background ProcessesBackground Processes

• Maintains and enforces relationships betweenphysical and memory structures

 – Mandatory background processes:

DBWn PMON CKPTLGWR SMON

 – Optional background processes:

ARCn LMDn QMNn

CJQ0 LMON RECODnnn LMS Snnn

LCKn Pnnn

Page 29: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 29/49

 

Database Writer (DBWn)Database Writer (DBWn)

DBWn writes when:• Checkpoint occurs

• Dirty buffers reach

threshold

• There are no free

buffers• Timeout occurs

• Tablespace OFFLINE

• Tablespace READ

ONLY

• Table DROP or 

TRUNCATE

• Tablespace BEGIN

BACKUP

Oracle

DatabaseData Files Control Files Redo Log Files

Instance

Shared Pool

Library

Cache

Data

Dictionary

Cache

SGA

Database Buffer 

Cache

Redo Log

Buffer 

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

Shared Pool

Page 30: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 30/49

 

Log Writer (LGWR)Log Writer (LGWR)

LGWR writes:• At commit

• When one-third full

• When there is 1 MB of 

redo

• Every three seconds• Before DBWn writes

Instance

Shared Pool

Library

Cache

Data

Dictionary

Cache

SGA

Database Buffer 

Cache

Redo Log

Buffer 

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

Oracle

DatabaseData Files Control Files Redo Log Files

Page 31: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 31/49

 

System Monitor (SMON)System Monitor (SMON)

Responsibilities:• Instance recovery

 – Rolls forward

changes in online

redo log files

 – Opens database for 

user access – Rolls back

uncommitted

transactions

• Coalesces free space

• Deallocates temporary

segments

Oracle

DatabaseData Files Control Files Redo Log Files

Instance

Shared Pool

Library

Cache

Data

Dictionary

Cache

SGA

Database Buffer 

Cache

Redo Log

Buffer 

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

Shared Pool

Page 32: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 32/49

 

Process Monitor (PMON)Process Monitor (PMON)

Cleans up after failedprocesses by:

• Rolling back the

transaction

• Releasing locks

• Releasing other resources

• Restarting dead

dispactchers

Database Buffer 

Cache

Oracle

DatabaseData Files Control Files Redo Log Files

Instance

Shared Pool

Library

Cache

Data

Dictionary

Cache

SGA

Redo Log

Buffer 

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

Shared Pool

Page 33: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 33/49

 

Checkpoint (CKPT)Checkpoint (CKPT)

Responsible for:• Signaling DBWn at

checkpoints

• Updating datafile

headers with

checkpoint information

• Updating control files

with checkpoint

information

Instance

Shared Pool

Library

Cache

Data

Dictionary

Cache

SGA

Database Buffer 

Cache

Redo Log

Buffer 

Java Pool Large Pool

PMON SMON DBWR LGWR CKPT Others

Oracle

DatabaseData Files Control Files Redo Log Files

Shared Pool

Page 34: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 34/49

 

Archiver (ARCn)Archiver (ARCn)

• Optional background process• Automatically archives online redo log files when

ARCHIVELOG mode is set• Preserves the record of all changes made to the

databaseOracle

DatabaseData Files Control Files Redo Log Files Archived Logs

ARCn

Page 35: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 35/49

 

Oracle Data StorageOracle Data Storage

Oracle keeps all system and user data in

two basic storage containers:

1. Tablespace… a logical entity known

only to Oracle

2. Data Files… physical files that may

(typically) be seen from the operating

system

Page 36: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 36/49

 

TablespacesTablespaces

• Can belong to only one database at a time

• Consist of one or more data files

• Are further divided into logical units of store

Page 37: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 37/49

 

Data FilesData Files

• Can belong to only one tablespace and

one database

• Are a repository for schema object data

DataFile DataFile

Database

Tablespace

Page 38: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 38/49

 

2 Types of Tablespace2 Types of Tablespace

1. Tablespaces required by Oracle for 

normal operations

2. Tablespaces that contain data and

indexes that support your applications

Page 39: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 39/49

 

Required TablespacesRequired Tablespaces

• System – Contains the Oracle Data

Dictionary

• Sysaux - New to 10g; supports historic

monitoring / tuning

• Temporary – Used for disk-based sorting

of data (select...from…order by)

• Undo – Used for transaction consistency

during Insert / Update / Delete statements

Page 40: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 40/49

 

SQL Statements (IUDS)SQL Statements (IUDS)

• Insert

• Update

• Delete• Select

What happens when

someone connects to

the database and

issues one of thesestatements?

Page 41: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 41/49

 

Connect to Oracle – What HappensConnect to Oracle – What Happens

Server 

Process

User 

ProcessConnect User/Pwd

• Are “User” definition and privileges in SGA“Dictionary Cache”? – If not, try to fetch from the “System”

tablespace

 – If there, validate Pwd and privileges to login – Allow connection if all is right; otherwise

decline connection

Page 42: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 42/49

 

““Select” – What Happens First?Select” – What Happens First?

• Is this statement in the “Library Cache”?

 – If statement cached then it has been recently

been “parsed” and “executed”

 – If not cached then “parse” the statement

 – If cached then skip parsing stage and executestatement

Select *

From MyTabOrder by 1;

Page 43: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 43/49

 

““Select” – Parsing the StatementSelect” – Parsing the Statement

• Does “MyTab” exist?

• Does user have Privs to select from

“MyTab”

• What columns are in “MyTab”

• What is the first column in “MyTab”

Select *

From MyTabOrder by 1;

Page 44: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 44/49

 

““Select” – Executing the StatementSelect” – Executing the Statement

• Is “MyTab” data in the SGA “Buffer Cache”?

 – If not, fetch data into Buffer Cache

• Sort data in “MyTab” by the first column

 – If can sort records in memory then do so

 – If cannot sort in memory then use “Temporary”tablespace as disk-based staging area

• Return records to client process

Select *

From MyTabOrder by 1;

Page 45: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 45/49

 

““I/U/D” – What Happens First?I/U/D” – What Happens First?

• Is this statement in the “Library Cache”?

 – If statement cached then it has been recently

been “parsed” and “executed”

 – If not cached then “parse” the statement

 – If cached then skip parsing stage and executestatement

Insert (a,b,c)

Into MyTab;

Page 46: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 46/49

 

““I/U/D” – Executing the StatementI/U/D” – Executing the Statement

• Validate values to be inserted

• Execute the statement – Keep DB version of the record in “Undo”

tablespace until Commit or Rollback

 – Record changes in SGA “Redo Log Buffer” – Change records in SGA “Buffer Cache”

 – DBWn writes changed records to data file(s)as part of buffer cache management

Insert (a,b,c)

Into MyTab;

Page 47: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 47/49

 

““I/U/D” – Executing the StatementI/U/D” – Executing the Statement

• If “Commit” then…

 – LGWn writes “Redo Log Buffer” entries to

“Redo Logs”

 – Undo entries are invalidated

• If “Rollback” then… – Migrate DB version of record in Undo back to

tablespace/data file

Insert (a,b,c)

Into MyTab;

Commit;

or 

Rollback;

Page 48: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 48/49

 

Archivelog ModeArchivelog Mode

Oracle

DatabaseData Files Control Files Redo Log Files Archived Logs

ARCn

• If Instance in “Archivelog” mode Redo LogFiles are “Archived” to Archive Logs;

which may be used to recover your 

database in the case of disaster 

Page 49: Oracle Architecture EASY

8/8/2019 Oracle Architecture EASY

http://slidepdf.com/reader/full/oracle-architecture-easy 49/49

SummarySummary• What we called a “Database” is really an

“Instance” and a “Database.”• An Oracle “Instance” is not persistent. It consists

of the System Global Area (SGA) and acollection of processes.

• An Oracle “Database” is persistent. It consists of a collection of “Required” and “User”tablespaces (with corresponding data files)along with other supporting files.

• Nearly every component of the “Instance” and“Database” are mobilized to execute SQLstatements.