Oracle DB Architecture
Oracle DB Architecture
md 2024-02-11
Instance
The Instance represents the set of memory structures and background processes that manage the database's
operation.
The SGA is a shared memory region containing data and control information for the instance.
Memory Structures:
Buffer Cache: Stores copies of data blocks read from data files.
Shared Pool: Contains shared SQL and PL/SQL code, including cached data dictionary
information.
Redo Log Buffer: Stores redo entries generated by DML operations before they are written to the
redo log files.
Large Pool: Used for large memory allocations, such as parallel execution buffers and I/O server
processes.
Java Pool: Used for Java-related memory allocations.
Streams Pool: Used for Oracle Streams-related memory allocations.
Fixed SGA: Contains fixed-size structures such as locks and kernel variables.
When a user's session executes a query in Oracle Database, the Program Global Area (PGA) plays a crucial role
in managing memory and resources.
1. Session Initialization:
PGA Allocation: When a user session connects to the database, Oracle allocates PGA memory to
manage session-specific data and operations.
Example: When User A connects to the database and executes a query, Oracle allocates
PGA memory for User A's session.
Description: Within the PGA, each user's session has a private SQL area that stores information
related to SQL statement processing.
Example: When User A executes a query, Oracle creates a private SQL area to hold the
parsed representation of the SQL statement, bind variable values, and execution context
for User A's session.
3. Session Memory:
1 / 18
Oracle DB Architecture.md 2024-02-11
Description: PGA allocates memory for session-specific data structures and variables needed for
query execution.
Example: User A's session memory holds session parameters, cursor state, and other
session-specific variables required for processing the query.
Description: PGA provides a SQL work area for sorting, hashing, and other operations performed
during query execution.
Example: When sorting or hashing is required for User A's query, PGA dynamically
allocates memory within the SQL work area to perform these operations.
5. Stack Space:
Description: PGA allocates stack space for managing program flow, local variables, and function
calls during query execution.
Example: If User A's query involves PL/SQL functions or procedures, PGA allocates stack
space to manage function calls and local variables.
6. Cursor State:
Description: PGA maintains cursor state information for each open cursor within a session,
including current position and fetch status.
Example: PGA tracks the cursor state for User A's query, ensuring consistency and
integrity during query processing.
Background Processes
Background processes are responsible for managing memory, handling user connections, and performing
various background tasks.
Database Writer (DBWn): Writes modified data blocks from the buffer cache to the data files.
Log Writer (LGWR): Writes redo log entries from the redo log buffer to the redo log files.
Checkpoint (CKPT): Signals when checkpoints should occur to update the data files and control file.
System Monitor (SMON): Performs crash recovery, coalesces free space, and recovers terminated
transactions.
Process Monitor (PMON): Cleans up failed sessions and releases resources held by terminated sessions.
Archiver (ARCn): Archives filled redo log files to disk or tape for backup and recovery purposes.
Recoverer (RECO): Resolves distributed transaction failures.
Dispatcher (Dnnn): Dispatches user connection requests to shared server processes.
Job Queue Processes (Jnnn): Executes jobs scheduled by the Oracle job scheduler.
Database Structure
The Database Structure refers to the physical and logical organization of data within the database.
Datafiles
Primary Datafiles
2 / 18
Oracle DB Architecture.md 2024-02-11
Temporary Datafiles
Read-Only Datafiles
Control Files (Metadata files)
Control Files
Control files contain critical information about the database's physical structure.
Tablespaces
Permanent Tablespaces
Temporary Tablespaces
Undo Tablespaces
Segments
Segments contain data for database objects like tables and indexes.
Data Segments
Undo Segments
Temporary Segments
Password File
Password files contain encrypted credentials for users with administrative privileges.
3 / 18
Oracle DB Architecture.md 2024-02-11
Archived redo log files are copies of redo log files that have been archived to secondary storage for backup
and recovery purposes.
│
├── Instance
│ ├── System Global Area (SGA)
│ │ ├── Memory Structures
│ │ │ ├── Buffer Cache
│ │ │ ├── Shared Pool
│ │ │ ├── Redo Log Buffer
│ │ │ ├── Large Pool
│ │ │ ├── Java Pool
│ │ │ ├── Streams Pool
│ │ │ └── Fixed SGA
│ │ └── Background Processes
│ │ ├── Database Writer (DBWn)
│ │ ├── Log Writer (LGWR)
│ │ ├── Checkpoint (CKPT)
│ │ ├── System Monitor (SMON)
│ │ ├── Process Monitor (PMON)
│ │ ├── Archiver (ARCn)
│ │ ├── Recoverer (RECO)
│ │ ├── Dispatcher (Dnnn)
│ │ └── Job Queue Processes (Jnnn)
│ ├── Initialization Parameter Files
│ │ ├── SPFILE (Server Parameter File)
│ │ └── PFILE (Parameter File)
│ ├── Program Global Area (PGA)
│ │ ├── Stack Space
│ │ ├── Session Memory
│ │ └── Private SQL Area
│ │ ├── SQL Work Area
│ │ ├── Cursor State
│ │ └── Runtime Area
│ └── Control Files
│
└── Database Structure
├── Datafiles
│ ├── Primary Datafiles
│ ├── Temporary Datafiles
│ ├── Read-Only Datafiles
│ └── Control Files
├── Redo Log Files
│ ├── Online Redo Log Files
│ └── Archived Redo Log Files
├── Control Files
│ ├── Primary Control Files
│ └── Multiplexed Control Files
├── Tablespaces
│ ├── Permanent Tablespaces
4 / 18
Oracle DB Architecture.md 2024-02-11
If the listener is not already running, you may need to start it to enable client connections to the database.
Example (Linux/Unix):
lsnrctl start
You can start the Oracle instance using SQL*Plus or SQLcl, connecting as a user with administrative privileges
(e.g., SYSDBA).
Example (SQL*Plus):
CONNECT / AS SYSDBA;
STARTUP;
Explanation:
CONNECT / AS SYSDBA: Connects to the database as a user with SYSDBA privileges. The "/" indicates
that no username or password is provided.
STARTUP: Starts the Oracle instance. By default, it opens the database in read/write mode.
You can specify various startup options when starting the instance, such as starting in restricted mode,
mounting but not opening the database, or starting in upgrade mode.
5 / 18
Oracle DB Architecture.md 2024-02-11
STARTUP RESTRICT;
STARTUP MOUNT;
STARTUP UPGRADE;
After starting the database, you can check its status to ensure it is up and running properly.
If the database is mounted but not yet open, you can open it to allow user connections.
Verify that the database is accessible and functioning as expected by connecting with a regular user account.
CONNECT username/password;
This completes the startup process of an Oracle Database, including starting the listener (if necessary), starting
the instance, specifying startup options, checking database status, opening the database (if required), and
confirming a successful startup.
6 / 18
Oracle DB Architecture.md 2024-02-11
1. Nomount Mode
Example:
STARTUP NOMOUNT;
2. Mount Mode
Example:
STARTUP MOUNT;
3. Open Mode
7 / 18
Oracle DB Architecture.md 2024-02-11
Example:
STARTUP;
4. Restricted Mode
Example:
STARTUP RESTRICT;
5. Upgrade Mode
Example:
STARTUP UPGRADE;
6. Force Mode
8 / 18
Oracle DB Architecture.md 2024-02-11
Example:
STARTUP FORCE;
Understanding the various startup modes in Oracle Database allows you to choose the appropriate mode for
different scenarios, such as database creation, maintenance tasks, recovery operations, or upgrade
procedures. Each mode provides specific functionalities and controls to ensure the instance is started and
managed according to your requirements.
1. Client Request:
The client application sends a connection request to the Oracle Database server.
2. Listener Processing:
Oracle Net Listener routes the connection request to the appropriate database instance.
Server Processes: Upon receiving the connection request, the listener starts necessary server
processes to handle the incoming connection. These processes include Database Writer (DBWn),
Log Writer (LGWR), Process Monitor (PMON), and others, which are essential for database
operation.
3. Authentication:
5. Authorization:
6. Execution:
9 / 18
Oracle DB Architecture.md 2024-02-11
The client application can execute SQL queries or transactions using the established session.
7. Session Termination:
When the user logs out or the session ends, resources are released.
Example
SQL*Plus Login Process
sqlplus username/password@service_name
Understanding this login process, including the role of server processes and background processes, helps in
troubleshooting connection issues and enforcing security policies within the Oracle Database environment.
The "Listener Processing" node includes the Oracle Net Listener's role in routing the connection request
and starting server processes.
The details of individual server processes have been omitted for brevity.
The diagram retains the sequential flow of the login process, from client request to session termination.
10 / 18
Oracle DB Architecture.md 2024-02-11
In Oracle Database, two primary connection modes dictate how client applications connect to the database:
Dedicated and Shared. Each mode offers distinct characteristics and is suited for different scenarios.
Characteristics:
Resource Allocation:
Dedicated resources ensure consistent and reliable performance for each connection.
Guaranteed memory and CPU allocation for individual connections.
User Waiting:
Usage:
Recommended for applications where each user requires consistent and dedicated access to
database resources.
Commonly used in OLTP (Online Transaction Processing) environments with a relatively low
number of concurrent connections.
Characteristics:
Resource Allocation:
Shared resources enable efficient utilization of server resources, accommodating a larger number
of connections.
Resources are allocated dynamically based on demand, optimizing resource usage.
User Waiting:
Increased potential for contention as multiple connections compete for shared resources.
Users may experience longer wait times during peak usage periods.
11 / 18
Oracle DB Architecture.md 2024-02-11
Usage:
Recommended for applications with a large number of concurrent users or fluctuating workloads.
Commonly used in data warehouse environments, web applications, and systems with high user
concurrency.
In this example, a database administrator connects to the Oracle Database in Dedicated mode using
SYSDBA privileges. The dedicated connection ensures exclusive access to system resources for
administrative tasks.
CONNECT username/password@hostname:port/service_name;
CONNECT hannibal/tiger@localhost:1521/orcl;
Here, a regular user named 'hannibal' connects to the Oracle Database in Shared mode. In Shared
mode, multiple users share server resources, allowing efficient resource utilization and scalability.
12 / 18
Oracle DB Architecture.md 2024-02-11
Example:
During startup, the database instance reads initialization parameter files to configure memory
allocation and other settings.
Control files are accessed to determine the database's state and structure.
Redo log files are accessed for instance recovery and applying changes to the database.
Datafiles are verified for integrity and consistency.
Example:
In dedicated connection mode, the user connects to a dedicated server process, providing
exclusive access to database resources.
In shared connection mode, users share server processes, and access to databases depends on
session settings, roles, and permissions.
1. FIFO (First-In-First-Out)
Description: FIFO is a cache replacement policy where the oldest cached data is evicted first when the
cache is full. This means that the data that has been in the cache the longest is replaced when new data
needs to be cached.
Usage: FIFO ensures that data is replaced in the order it was originally cached, regardless of how
frequently or infrequently it has been accessed since then. This policy is suitable for scenarios where
access patterns are relatively stable over time.
Example
Suppose we have a buffer cache in Oracle Database with a capacity of 100 pages. When a new page needs to
be cached and the cache is already full, the FIFO algorithm will evict the page that was cached earliest,
regardless of how often it has been accessed since then.
If pages A, B, C, ..., X, Y, and Z are currently cached in that order (with A being the oldest and Z being the
newest), and a new page W needs to be cached, FIFO will evict page A (the oldest) to make room for page W.
13 / 18
Oracle DB Architecture.md 2024-02-11
Description: LRU is a cache replacement policy where the least recently used data is evicted first when
the cache is full. This means that the data that has been accessed least recently is replaced when new
data needs to be cached.
Usage: LRU ensures that the most recently accessed data remains in the cache, while older or less
frequently accessed data is evicted. This policy is beneficial for systems with dynamic and changing
access patterns.
Example
Consider the same buffer cache scenario with a capacity of 100 pages. If LRU is employed, the page that was
accessed least recently will be evicted when a new page needs to be cached.
Suppose pages A, B, C, ..., X, Y, and Z are currently cached, with A being the least recently accessed and Z
being the most recently accessed. If a new page W needs to be cached, LRU will evict page A (the least
recently accessed) to make room for page W.
FIFO and LRU are essential cache replacement policies used in Oracle Database to manage data access
efficiently. By evicting data based on their age or access frequency, these algorithms optimize memory usage
and improve overall system performance.
Description: Shared memory region containing shared data and control information.
Example: The buffer cache in the SGA stores frequently accessed data blocks to reduce disk I/O.
Usage: SGA size is crucial for database performance. It should be appropriately sized based on the
workload and available system resources.
14 / 18
Oracle DB Architecture.md 2024-02-11
a. Buffer Cache
b. Shared Pool
Description: Stores shared SQL and PL/SQL code, and parsed execution plans.
Example: Shared pool caches the parsed representation of frequently executed SQL statements.
Usage: Adequate sizing of the shared pool reduces parsing overhead and enhances SQL statement
execution.
Description: Temporarily holds redo entries before writing to redo log files.
Example: Redo log buffer stores transaction changes before they're written to the redo log file.
Usage: Sizing the redo log buffer impacts transaction processing and recovery. Proper sizing ensures
efficient redo log write operations.
d. Large Pool
Description: Optional memory component for large allocations and backup operations.
Example: Large pool improves performance for RMAN backup operations.
Usage: Allocating memory to the large pool enhances performance for large data movement
operations and backup processes.
15 / 18
Oracle DB Architecture.md 2024-02-11
Usage: AMM simplifies memory management by automatically adjusting memory allocations based on
workload changes, reducing administrative overhead and optimizing resource utilization.
Effective memory management in Oracle Database is essential for optimizing performance and resource
utilization. By leveraging insights, examples, and usage scenarios, database administrators can make informed
decisions to optimize memory resources and enhance overall system performance under varying workload
conditions.
/u01/app/oracle/oradata/control01.ctl
/u02/app/oracle/oradata/control02.ctl
/u03/app/oracle/oradata/control03.ctl
Redundancy: Provides redundancy and ensures database availability even if one control file becomes
inaccessible or corrupt.
Fault Tolerance: Enhances fault tolerance by safeguarding against single points of failure.
Quick Recovery: Facilitates quick recovery in case of control file corruption or loss.
Increased Storage Overhead: Requires additional storage space to maintain multiple copies of control
files.
Management Complexity: Adds complexity to database administration tasks such as backup and
recovery, as multiple control files need to be managed.
16 / 18
Oracle DB Architecture.md 2024-02-11
example:
Group 1:
- `/u01/app/oracle/oradata/redo01.log`
- `/u01/app/oracle/oradata/redo02.log`
Group 1:
/u02/app/oracle/oradata/redo01.log
/u02/app/oracle/oradata/redo02.log
Group 2:
/u03/app/oracle/oradata/redo03.log
/u03/app/oracle/oradata/redo04.log
Enhanced Data Protection: Improves data protection by ensuring that changes are safely stored in
multiple redo log files.
Improved Recovery: Facilitates faster recovery in the event of a redo log file failure or corruption.
High Availability: Contributes to high availability by reducing the risk of data loss during database
operations.
Increased Storage Overhead: Requires additional storage space to maintain multiple copies of redo
log files.
Performance Impact: May introduce a slight performance overhead due to the need to write changes
to multiple redo log files.
17 / 18
Oracle DB Architecture.md 2024-02-11
Multiplexing in Oracle Database involves duplicating critical components such as control files and redo log
files to enhance data reliability and fault tolerance. By maintaining multiple copies across different disk
locations, Oracle ensures continuous operation and data integrity even in the event of hardware failures or
disk corruption.
18 / 18