0% found this document useful (0 votes)
710 views

Oracle Architecture PDF

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
710 views

Oracle Architecture PDF

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

ORACLE Database Architecture

Valentin ROBU - [email protected]


Technical Leader, ACS Global Delivery, DB

Oracle Academy - December, 2018

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy
Program Agenda

1 Oracle Memory Architecture

2 Oracle Processes – Overview

3 Oracle 12c – New Paradigm

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 3
Oracle Memory Architecture

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 4
Oracle TRANSACTION

A transaction is a logical, atomic unit of work that contains one or more SQL statements.
All Oracle transactions obey the basic properties of a database transaction, known as ACID properties.
ACID is an acronym for the following:
• Atomicity
All tasks of a transaction are performed or none of them are. There are no partial transactions.
• Consistency
The transaction takes the database from one consistent state to another consistent state.
• Isolation
The effect of a transaction is not visible to other transactions until the transaction is committed.
• Durability
Changes made by committed transactions are permanent. After a transaction completes, the database
ensures through its recovery mechanisms that changes from the transaction are not lost.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 5
Oracle Server Architecture

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 6
Oracle Instance and Database
• Oracle Database = Oracle Instance +
Database files (storage structures)

• Oracle Instance = Background


processes + Memory Structures

• Database (storage structures) =


Internal files (datafiles, dbf, control
files, On-line Redo Log files) + External
files (archived redo-log files, flashback
logs) + Additional files (parameter file,
password file, backup files, archived
redo-log files, trace files, alert log file)

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 7
Oracle Instance
• SGA – shared memory structures (used by all
server and background processes) that contain
data and control information for one Oracle
database instance.
• Background processes - perform maintenance
tasks required to operate the database and to
maximize performance for multiple users
– Mandatory
PMON, SMON, DBWR, LGWR,
CKPT, RECO, MMON+MMNL
(manageability processes), etc.
– Optional (may appear depending on options
or technologies used)
ARCH, RBAL, ACFS, etc.
• Server processes – opened in name of a user
connection (if dedicated server connection)

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 8
Oracle Database Instance Configurations

• In Single instance or RAC environment, an instance is associated with one and only
one database at a time.
• Even if there are multiple single instances on a machine, each one is accessing its
own database

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 9
Oracle Basic Memory Structures
• Basic memory structures associated
with Oracle instance are:

– SGA (system global area –


sometimes called shared global
area)

– PGA (program global area)

– UGA (user global area)

– Software code areas

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 10
System Global Area - SGA

Most important SGA components:


• Database Buffer Cache
• Redo Log Buffer
• Shared Pool
• Large Pool
• Java Pool
• Streams Pool
• Fixed SGA

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 11
Database Buffer Cache
Has 2 major goals:
- optimize physical I/O
- Keep frequently accessed blocks in the buffer cache
and write infrequently accessed blocks to disk
Buffer States (mutually exclusive)
- Unused
- Clean
- Dirty
A buffer could be:
- Pinned
- Free (unpinned)
Buffer Modes
- Current mode
- Consistent mode
Buffer Pools
- Default
ALTER SYSTEM SET DB_CACHE_SIZE = 96M; - Keep
- Recycle

The size of each buffer in the DEFAULT buffer cache is equal to the size of an Oracle block
(specified by the DB_BLOCK_SIZE parameter).

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 12
Redo Log Buffer

• Used in a circular manner


• Stores redo entries
• Written exclusively by LGWR
• Used in case of recovery of instance to
reconstruct lost changes
• LOG_BUFFER initialization parameter
specifies the amount of memory that
Oracle Database uses when buffering redo
entries.
ALTER SYSTEM SET LOG_BUFFER = 16M;

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 13
Shared Pool
Shared Pool components:
• Library Cache
– Shared SQL Area
– Private SQL Area
• Data Dictionary Cache
• Server Result Cache
– SQL Query Result Cache
– PL/SQL Function Result Cache
• Reserved Pool

ALTER SYSTEM SET SHARED_POOL_SIZE = 64M;

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 14
SGA Components: Library Cache

The library cache stores information about the most recently used SQL
and PL/SQL statements. The library cache:

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

Has its size determined by the shared pool sizing

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 15
Shared SQL Areas
Statement 1: SELECT empno, ename from SCOTT.EMP;

Statement 2: SELECT sum(sal), deptno from scott.emp GROUP BY deptno;

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 16
Processing a DML statement

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 17
COMMIT Processing

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 18
Tuning Shared Pool

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 19
SGA Components: Dictionary Cache

The data dictionary cache is a collection of the most recently used definitions
in the database.
– It 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 and validate access.
– Caching the data dictionary information into memory improves response
time on queries.
– Size is determined by the shared pool sizing.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 20
SGA Components: Large Pool
Optional area in SGA, used for large memory allocation in
case of:
- UGA for SHARED SERVER architecture
- Message buffers used in the parallel execution of
statements
- Buffers for Recovery Manager (RMAN) I/O slaves
Not deserved by a LRU algorithm

Sized by LARGE_POOL_SIZE parameter

ALTER SYSTEM SET LARGE_POOL_SIZE = 64M;

SELECT * FROM V$SGASTAT WHERE pool = ’large pool’;

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 21
SGA Components: Java Pool

• The Java pool is an area of memory that stores all session-specific Java code and data
within the Java Virtual Machine (JVM).
• For dedicated server connections, the Java pool includes the shared part of each Java
class, including methods and read-only memory (but not session state)
• For shared server, the pool includes the shared part of each class and some UGA used
for the state of each session. Each UGA grows and shrinks as necessary, but the total
UGA size must fit in the Java pool space.
• The Java Pool Advisor statistics provide information about library cache memory used
for Java and predict how changes in the size of the Java pool can affect the parse rate
(need STATISTICS_LEVEL = TYPICAL or higher)
• It is sized by the JAVA_POOL_SIZE parameter

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 22
SGA Components: Streams Pool

• The Streams pool is used exclusively by Oracle Streams feature.

• The Streams pool stores buffered queue messages and provides memory for Oracle
Streams capture processes and apply processes.

• Unless you specifically configure it, the size of the Streams pool starts at zero.

• The pool size grows dynamically as required by Oracle Streams.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 23
SGA Components: Fixed SGA

• The fixed SGA is an internal housekeeping area.

• For example, the fixed SGA contains:


– General information about the state of the database and the instance, which the background processes need
to access.
– Information communicated between processes, such as information about locks.

• The size of the fixed SGA is set by Oracle Database and cannot be altered manually.

• The fixed SGA size can change from release to release.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 24
SGA Components: Software Code Area

• Software code areas are portions of memory that store code that is being run or can be run.

• Oracle Database code is stored in a software area that is typically more exclusive and protected
than the location of user programs.

• Software areas are usually static in size, changing only when software is updated or reinstalled.

• The required size of these areas varies by operating system.

• Software areas are read-only and can be installed shared or non-shared (when possible, database
code is shared so that all users can access it)

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 25
Program Global Area – PGA

What is PGA
– Memory structure specific to a non-shared process
(never allocated in SGA)
– Memory heap containing session-dependent
variables (for a dedicated or shared process)
• Automatic tuning by
PGA_AGGREGATE_TARGET <> 0
• Comprising of:
– SQL Work Areas
– Private SQL Area

• WORKAREA_SIZE_POLICY = AUTO | MANUAL

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 26
Program Global Area – PGA (cont.)

SQL Work Area Private SQL Area

•Sort Area •Persistent Area


•Hash Area •Runtime Area
•Bitmap Merge Area

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 27
Program Global Area – PGA (cont.)
PGA – comparison between DEDICATED and SHARED SERVER architecture

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 28
SGA & PGA – content during life span

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 29
UGA and Oracle Shared Server

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 30
Diagram of typical relationships between caches

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 31
Automatic Memory Management (AMM)
10g approach 11g approach
Automatic Memory Management can now automatically
•Automatic Shared Memory Management (ASSM) provided
manage both the system global area (SGA) and the program
•Some structures are automatic resized based on loading global area (PGA).
•Automatically Managed SGA Components
Automatic memory management done by:
-Shared pool (for SQL and PL/SQL execution) -setting MEMORY_TARGET and MEMORY_MAX_TARGET
-unsetting SGA_TARGET and PGA_AGGREGATE_TARGET
-Java pool (for Java execution state)
-Large pool (for large allocations such as RMAN backup buffers)
-Buffer cache (default pool)
-Streams pool
•Manually Managed SGA Components
-Keep/Recycle buffer caches
-Additional buffer caches for non-standard block sizes
•Specify SGA_TARGET <> 0 (but <= SGA_MAX_SIZE) and
STATISTICS_LEVEL = TYPICAL or ALL

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 32
Automatic Memory Management – AMM (cont.)

Only one parameter required: MEMORY_TARGET <> 0

Oracle will automatically size the Program Global Area (PGA) and System Global
Area (SGA) based on the workload

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 33
Automatic Memory Management – AMM (cont.)

• The MEMORY_TARGET parameter is


somewhat a combination of the
SGA_TARGET parameter value and
the PGA_AGGREGATE_TARGET
parameter, representing the total
amount of memory that Oracle has
to allocate between the various SGA
and PGA structures.

• MEMORY_TARGET parameter is
dynamic and can be changed up to
and including the value of
MEMORY_MAX_TARGET.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 34
Automatic Memory Management – AMM (cont.)

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 35
Automatic Memory Management – AMM (cont.)
Automatic Memory Management – For Both SGA, PGA Oracle tunes:
• You set MEMORY_TARGET > 0 and optional •Total SGA size
MEMORY_MAX_TARGET •SGA component sizes
•Instance PGA size
•Individual PGA sizes

Automatic Shared Memory Management – For SGA Oracle tunes


• You set SGA_TARGET > 0 and optional SGA_MAX_TARGET •SGA component sizes

Manual Shared Memory Management – For SGA Oracle tunes:


• You set: •------
•Shared pool size
•Buffer cache size
•Java pool size
•Large pool size

Automatic PGA Memory Management – For PGA Oracle tunes:


•You set PGA_AGGREGATE_TARGET > 0 •Individual PGA sizes

Manual PGA Memory Management – For PGA Oracle tunes:


•not recommended •------

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 36
Automatic Memory Management – AMM (cont.)

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 37
Oracle Processes- Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 38
Oracle Process Types
Process = interface (link) between user -> storage structures -> memory structures

• Server Processes
– Created on behalf of a user application to perform tasks like:
• Parse or run SQL statements
• Execute PL/SQL code
• Reads data blocks from database file into buffer cache (DBWR writes back changes!)
• Returns data to application requested it
– In DEDICATED SERVER architecture one Server process is associated with one and only one client connection
– In SHARED SERVER architecture client connections are handled by a DISPATCHER process
• Background Processes
– Created by Oracle engine upon database startup and managed internally by Oracle code
– Could be:
• Mandatory (PMON, SMON, DBWR, LGWR, CKPT, RECO, etc.)
• Optional (ARCH, Dnnn, RBAL, etc.)
• Slave processes (background processes that perform work on behalf of other processes)

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 39
DEDICATED SERVER Architecture

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 40
SHARED SERVER Architecture

Controlled by parameters:
• SHARED_SERVERS
• MAX_SHARED_SERVERS
• SHARED_SERVER_SESSIONS
• DISPATCHERS
• MAX_DISPATCHERS
• CIRCUITS

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 41
Establishing a Connection and Creating a Session

Connecting to an Oracle instance consists of establishing a user


connection and creating a session.
•Connection: a connection is a communication pathway
between a user process and an Oracle server
•Session: a session is a specific connection of a user to an Oracle
server.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 42
Server Process
A server process is a program that directly interacts with the Oracle
server.
– It fulfills calls generated and returns results.
– Can be dedicated or shared server.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 43
Background Process
The relationship between the physical and memory structures is
maintained and enforced by Oracle’s background processes.

– Mandatory background processes


DBWn PMON CKPT
LGWR SMON RECO

– Optional background processes


ARCn LMON (Global Enqueue Service Monitor - RAC)
QMNC LMDn (Global Enqueue Service daemon – RAC)
CJQ0 Pnnn (parallel)
LCKn Dnnn (dispatcher)

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 44
Database Writer (DBWn)

DBWn writes when:


– Checkpoint (CKPT process)
– Dirty buffers threshold reached
– No free buffers
– Tablespace offline
– Tablespace read only
– Table DROP or TRUNCATE
– Tablespace BEGIN BACKUP

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 45
Log Writer (LGWR)

LGWR writes:
– At commit
– When one-third full
– When there is 1 MB of redo
– Every 3 seconds
– Before DBWn writes

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 46
System Monitor (SMON)

Responsibilities:
–Instance recovery:
‒Rolls forward changes in the redo logs
‒Opens the database for user access
‒Rolls back uncommitted transactions
–Coalesces free space ever 3 sec
–Deallocates temporary segments

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 47
Process Monitor (PMON)

Cleans up after failed processes by:


–Rolling back the transaction
–Releasing locks
–Releasing other resources
–Restarts dead dispatchers

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 48
Checkpoint Process (CKPT)

Responsible for:
–Signaling DBWn at checkpoints
–Updating datafile headers with
checkpoint information
–Updating control files with
checkpoint information

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 49
Archiver Process (ARCn)

• Optional background process


• Automatically archives online redo logs when ARCHIVELOG
mode is set
• Preserves the record of all changes made to the database

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 50
Physical Database Structure

• Mandatory Files

• Additional Files

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 51
Database Storage Structure
Oracle Database storage
• Physical structure
• Logical structure

The Oracle database stores data logically in


tablespaces and physically in data files.
• Tablespaces:
‒ Can belong to only one database
‒ Consist of one or more data files
‒ Are further divided into logical units of storage
• Data files:
‒ Can belong to only one tablespace and one
database
‒ Are a repository for schema object data

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 52
Initialization Parameter file

When you start the instance, an initialization parameter file is read. There are
two types of parameter files:
– Server parameter file: This is the preferred type of initialization parameter
file (binary file)
– Text initialization parameter file: This type of initialization parameter file can
be read by the database server, but it is not written to by the server

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 53
Starting Up Oracle Instance

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 54
Starting Up Oracle Instance (cont.)

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 55
Shutting Down Oracle Instance

Shutdown Modes

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 56
Shutting Down Oracle Instance (cont.)

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 57
Oracle 12c – New Paradigm

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 58
Oracle 12c Multitenant Architecture
Requires memory, processes and database files
System Resources

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 59
Oracle 12c – New Multitenant Architecture
Memory and processes required at multitenant container level only
System Resources

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 60
Oracle Multitenant Database Architecture
 The multitenant architecture enables an Oracle database to function as a multitenant
container database (CDB) that includes zero, one, or many customer-created pluggable
databases (PDBs).
 A PDB is a portable collection of schemas, schema objects, and non-schema objects that
appears to an Oracle Net client as a non-CDB. All Oracle databases before Oracle Database
12c were non-CDBs.
 A container is either a PDB or the root container (also called the root). The root is a collection
of schemas, schema objects, and non-schema objects to which all PDBs belong
 Every CDB has the following containers:
 Exactly one root
 Exactly one seed PDB
 Zero or more user-created PDBs

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 61
Oracle 12c Multitenant Architecture (cont.)
 Sample of a CDB with four containers:
 Root
 Seed
 Two PDBs (hr and sales).
 Each PDB has its own dedicated application,
managed by its own PDB administrator.
 A common user exists across a CDB with a
single identity. In this example, common
user SYS can manage the root and every PDB.
 A local user is specific to a particular PDB and
owns a schema in this PDB.
 At the physical level, this CDB has a database
instance and database files, just as a non-
CDB does.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 62
Oracle 12c Multitenant Architecture (cont.)

 From a physical perspective, a CDB has basically the same structure as a non-CDB, except that each PDB has
its own set of tablespaces (including its ownSYSTEM and SYSAUX tablespaces) and data files (example: a CDB
with two PDBs: hrpdb and salespdb).

http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/poster/OUTPUT_poster/poster.html

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 63
Oracle 12c Multitenant Architecture (cont.)

PDBs

Root
Pluggable Databases (PDBs)
CDB

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 64
Oracle 12c Multitenant Architecture (cont.)

• Multitenant architecture can currently support up


• to 252 PDBs
Database
Link
• A PDB feels and operates identically to a non-CDB

• You cannot tell, from the viewpoint of a connected


client, if you’re using a PDB or a non-CDB

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 65
Oracle 12c – CDB & PDB big picture
background
control files redo log files flashback log files SGA
processes
Root
SYS Public CDBA
Oracle Supplied Common Users/Schemas/Objects
Customer Common Users
SYSTEM SYSAUX UNDO TEMP
(global) (global)

SYS CDBA SYS CDBA SYS CDBA SYS

PDB DW PDB CRM


PDB SEED PDB ERP
SYSTEM SYSTEM
SYSTEM SYSTEM
SYSAUX SYSAUX
SYSAUX SYSAUX TEMP TEMP
ERP DW CRM
Public Public ERP Public DW Public CRM

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 67
[email protected]

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle ACS for Oracle Academy 68

You might also like