2988489 oracle architecture
TRANSCRIPT
-
8/4/2019 2988489 Oracle Architecture
1/37
Oracle Instance Architecture
By:-Ankit Shinde
IndiaMail:- [email protected]
-
8/4/2019 2988489 Oracle Architecture
2/37
OracleArchitecture
Overview
-
8/4/2019 2988489 Oracle Architecture
3/37
Oracle ArchitectureThe Oracle Server
Oracle server
Oracle server
-
8/4/2019 2988489 Oracle Architecture
4/37
Oracle ArchitectureInstance Architecture
Shared pool
Library
Cache
Data
Dict io ary
Cache
Redo
Log
Buffer
Databa e
Buffer
Cache
SGA
I ta ce
DBWR LGWR SMON PMON ARC
RECO CKPT LCK SNP D
S
-
8/4/2019 2988489 Oracle Architecture
5/37
Oracle ArchitectureInstance
An Oracle instance:
Is a means to access an Oracle database Always opens one and only one database
Consists of:
Internal memory structures
Processes
-
8/4/2019 2988489 Oracle Architecture
6/37
Oracle ArchitectureInteraction with the Database ( Dedicated Server)
SGA
Reque
t Re
po
e
Shared SQL
Po ol D ataba
e Buffer CacheRedo log Buffer
Databa
e File Redo Log F i le
Dedicated
Se r
er
U
er
Proce
D BW R LG W R AR C
P MONS MONCKP T
-
8/4/2019 2988489 Oracle Architecture
7/37
SG
R
q
t R
po
S
r d SQL
Pool D
t
b
B
ff
r C
R do log B ff r
D t b
Fi l R
do Log Fil
U
r
Pr o
DBW R LG WR
RC
PM
NSM
N
D
di
t
d
S
r
rD di t d
S
r
rS
r d
S
r
r
U
r
Pr o
U
r
Pr o
U
r
Pr o
U
rPr o
Di
p
t
r
CKPT
r l r it t r Interaction with the Database ( Shared Server)
-
8/4/2019 2988489 Oracle Architecture
8/37
Oracle ArchitectureInternal Memory Structures SGA
System or shared Global Area (SGA)
Database buffer cache Redo log buffer
Shared pool
Request & response queues (shared server)
-
8/4/2019 2988489 Oracle Architecture
9/37
Oracle ArchitectureDatabase buffer cache
Used to hold data blocks read from datafiles by server
processes Contains dirty or modified blocks and clean or
unused or unchanged bocks
Dirty and clean blocks are managed in lists called the
dirty list and the LRU
Free space is created by DBWR writing out dirty
blocks or aging out blocks from the LRU
Size is managed by the parameter
DB_BLOCK_BUFFERS
-
8/4/2019 2988489 Oracle Architecture
10/37
Oracle ArchitectureLeast Recently Used (LRU)
LRU and the database buffer cache
Every time a data block is read from disk it is placedin the database buffer cache at the head of the LRU
list
If a block is already in the cache and it is read again
it is moved to the head of the list
Data not used frequently is aged out of the cache
while frequently used data remains
-
8/4/2019 2988489 Oracle Architecture
11/37
Oracle ArchitectureRedo Log Buffer
A circular buffer that contains redo entries
Redo entries reflect changes made to the database Redo entries take up contiguous, sequential
space in the buffer
Data stored in the redo log buffer is periodically
written to the online redo log files Size is managed by the parameter
LOG_BUFFER Default is 4 times the maximum data block size for
the operating system
-
8/4/2019 2988489 Oracle Architecture
12/37
Oracle ArchitectureShared Pool
Consists of multiple smaller memory areas Library cache
Shared SQL area
Contains parsed SQL and execution plans for statements alreadyrun against the database
Procedure and package storage
Dictionary cache
Names of all tables andv
iews in the database Names and datatypes of columns in the database tables
Privileges of all users
Managed via an LRU algorithm
Size determined by the parameter
SHARE
D_POO
L_SIZE
-
8/4/2019 2988489 Oracle Architecture
13/37
Oracle ArchitectureLeast Recently Used (LRU)
LRU and the shared pool
Every time a SQL statement is parsed it is placed inthe shared pool for reuse
If a SQL statement is already in the shared pool itwill not re-parse but it is placed at the head of theLRU
SQL statements not used frequently are aged outof the shared pool while frequently used statementsremain
A SQL statement may be artificially retained at thehead of the LRU by pinning the statement
-
8/4/2019 2988489 Oracle Architecture
14/37
Oracle ArchitectureInternal Memory Structures PGA
Program or process Global Area (PGA)
Used for a single process Not shareable with other processes
Writable only by the server process
Allocated when a process is created anddeallocated when a process is terminated
Contains: Sort area Used for any sorts required by SQL processing
Session information Includes user privileges
Cursor state Indicates stage of SQL processing
Stack space Contains session variables
-
8/4/2019 2988489 Oracle Architecture
15/37
Oracle ArchitectureBackground Processes - DBWR
Writes contents of database buffers to datafiles
Primary job is to keep the database bufferclean
Writes least recently used (LRU) dirty buffersto disk first
Writes to datafiles in optimal batch writes Only process that writes directly to datafiles
Mandatory process
-
8/4/2019 2988489 Oracle Architecture
16/37
Oracle ArchitectureBackground Processes - DBWR
DBWR writes to disk when:
A server process cannot find a clean reusable buffer A timeout occurs (3 sec)
A checkpoint occurs
DBWR cannot write out dirty buffers before they
have been written to the online redo log files
-
8/4/2019 2988489 Oracle Architecture
17/37
Oracle ArchitectureCommit Command
The SQL command O I allows users tosave transactions that have been made against
a database. This functionality is available for
any A , I , r
transaction; it is not available for changes todatabase objects (such as A A
commands)
-
8/4/2019 2988489 Oracle Architecture
18/37
Oracle ArchitectureBackground Processes - LGWR
Writes contents of redo log buffers to online
redo log files Primary job is to keep the redo log buffer
clean
Writes out redo log buffer blocks sequentially
to the redo log files May write multiple redo entries per write during
high utilization periods
Mandatory process
-
8/4/2019 2988489 Oracle Architecture
19/37
Oracle ArchitectureBackground Processes - LGWR
LGWR writes to disk when:
A transaction is COMMITED A timeout occurs (3 sec)
The redo log buffer is 1/3 full
There is more than 1 megabyte of redo entries
Before DBWR writes out dirty blocks to datafiles
-
8/4/2019 2988489 Oracle Architecture
20/37
Oracle ArchitectureBackground Processes - SMON
Performs automatic instance recovery
Reclaims space used by temporary segmentsno longer in use
Merges contiguous areas of free space in the
datafiles (if PCTINCREASE > 0)
SMON wakes up regularly to check whether it
is needed or it may be called directly
Mandatory process
-
8/4/2019 2988489 Oracle Architecture
21/37
Oracle ArchitectureBackground Processes - SMON
SMON recovers transactions marked as DEAD
within the instance during instance recovery All non committed work will be rolled back by SMON
in the event of server failure
SMON makes multiple passes through DEAD
transactions and only applies a specified number ofundo records per pass, this prevents short
transactions having to wait for long transactions to
recover
SMON primarily cleans up server-side failures
-
8/4/2019 2988489 Oracle Architecture
22/37
Oracle ArchitectureBackground Processes - PMON
Performs automatic process recovery
Cleans up abnormally terminated connections Rolls back non committed transactions
Releases resources held by abnormally terminatedtransactions
Restarts failed shared server and dispatcherprocesses
PMON wakes up regularly to check whether itis needed or it may be called directly
Mandatory process
-
8/4/2019 2988489 Oracle Architecture
23/37
Oracle ArchitectureBackground Processes - PMON
Detects both user and server aborted database
processes Automatically resolves aborted processes
PMON rolls back the current transaction of the
aborted process
Releases resources used by the process If the process is a background process the instance
most likely cannot continue and will be shut down
PMON primarily cleans up client-side failures
-
8/4/2019 2988489 Oracle Architecture
24/37
Oracle ArchitectureBackground Processes - CKPT
Forces all modified data in the SGA to be written todatafile Occurs whether or not the data has been committed
CKPT does not actually write out buffer data only DBWR canwrite to the datafiles
Updates the datafile headers This ensures all datafiles are synchronized
Helps reduce the amount of time needed to performinstance recovery
Frequency can be adjusted with parameters
-
8/4/2019 2988489 Oracle Architecture
25/37
Oracle ArchitectureBackground Processes - ARCH
Automatically copies online redo log files to
designated storage once they have become full
-
8/4/2019 2988489 Oracle Architecture
26/37
Oracle ArchitectureServer Processes
Services a single user process in the dedicated
server configuration or many user processes inthe shared server configuration
Use an exclusive PGA
Include the Oracle Program Interface (OPI)
Process calls generated by the client Return results to the client in the dedicated
server configuration or to the dispatcher in theshared server configuration
-
8/4/2019 2988489 Oracle Architecture
27/37
Oracle ArchitectureUser Processes
Run on the client machine
Are spawned when a tool or an application isinvoked
SQL*Plus, Server Manager, Oracle Enterprise
Manager, Developer/2000
Custom applications
Include the User Program Interface (UPI)
Generate calls to the Oracle server
-
8/4/2019 2988489 Oracle Architecture
28/37
Oracle ArchitectureTransaction Example - Update
SGA
Databa
e
Buffer
Cache
Shared Pool
Redo
Lo g
Buffer
Databa
e File Redo Lo g Fi le
Dedicated
Se r
er
U
er
Proce
DB W R L G W R
P MONSMONCKP T
Rol lback
S egme t
1
2
UPDAT table
S T u er = SHIP RT
WH R id = 12345
-
8/4/2019 2988489 Oracle Architecture
29/37
Oracle ArchitectureTransaction Example - Update
SGA
Databa
e
Buffer
Cache
Shared Pool
Redo
Lo g
Buffer
Databa
e File Redo Lo g Fi le
Dedicated
Se r
er
U
er
Proce
DB W R L G W R
P MONSMONCKP T
Rol lback
S egme t
-
8/4/2019 2988489 Oracle Architecture
30/37
Oracle ArchitectureTransaction Example - Update
SGA
Databa
e
Buffer
Cache
Shared Pool
Redo
Lo g
Buffer
Databa
e File Redo Lo g Fi le
Dedicated
Se r!
er
U
er
Proce
DB W R L G W R
P MONSMONCKP T
Rol lback
S egme " t
#
-
8/4/2019 2988489 Oracle Architecture
31/37
Oracle ArchitectureTransaction Example - Update
SGA
Databa$
e
Buffer
Cache
Shared Pool
Redo
Lo g
Buffer
Databa$
e File$ Redo Lo g Fi le
$
Dedicated
Se r%
er
U$
er
Proce$ $
DB W R L G W R
P MONSMONCKP T
Rol lback
S egme & t
'
-
8/4/2019 2988489 Oracle Architecture
32/37
Oracle ArchitectureTransaction Example - Update
SGA
Databa(
e
Buffer
Cache
Shared Pool
Redo
Log
Buffer
Databa(
e File(
Redo Log File(
Dedicated
Ser)
er
U(
er
Proce( (
DBWR LGWR
PMONSMONCKPT
Rollback
Segme 0 t
6
-
8/4/2019 2988489 Oracle Architecture
33/37
Oracle ArchitectureTransaction Example - Update
SGA
Databa1
e
Buffer
Cache
Shared Pool
Redo
Log
Buffer
Databa1
e File1
Redo Log File1
Dedicated
Ser2
er
U1
er
Proce1 1
DBWR LGWR
PMONSMONCKPT
Rollback
Segme 3 t
7
-
8/4/2019 2988489 Oracle Architecture
34/37
Oracle ArchitectureTransaction Example - Update
SGA
Databa4
e
Buffer
Cache
Shared Pool
Redo
Log
Buffer
Databa4
e File4
Redo Log File4
Dedicated
Ser5
er
U4
er
Proce4 4
DBWR LGWR
PMONSMONCKPT
Rollback
Segme 6 t
8ROW UPDAT D
-
8/4/2019 2988489 Oracle Architecture
35/37
Oracle ArchitectureTransaction Example - Update
SGA
Databa7
e
Buffer
Cache
Shared Pool
Redo
Log
Buffer
Databa7
e File7
Redo Log File7
Dedicated
Ser8
er
U7
er
Proce7 7
DBWR LGWR
PMONSMONCKPT
Rollback
Segme 9 t
109COMMIT
-
8/4/2019 2988489 Oracle Architecture
36/37
Oracle ArchitectureTransaction Example - Update
SGA
Databa@
e
Buffer
Cache
Shared Pool
Redo
Log
Buffer
Databa@
e File@
Redo Log File@
Dedicated
SerA
er
U@
er
Proce@ @
DBWR LGWR
PMONSMONCKPT
Rollback
Segme B t
11COMMIT
SUCC SSFUL
-
8/4/2019 2988489 Oracle Architecture
37/37
Oracle ArchitectureTransaction Example - Update
SGA
DatabaC
e
Buffer
Cache
Shared Pool
Redo
Log
Buffer
DatabaC
e FileC
Redo Log FileC
DBWR LGWR
PMONSMONCKPT
Rollback
Segme D t
12