What is Oracle Database Architecture?


 Oracle Database Architecture

Basically, there are two main components of Oracle database –– instance and database itself.

An instance consists of some memory structures and the background processes, whereas a database refers to the disk resources.



​Process Architecture

  1. Physical Structure.

  2. Memory Structure and background processes.

  3. Logical Structure.

​Memory Structures

The two memory structures of Oracle are

  • SGA – System Global Area

  • PGA – Program Global Area

​SGA (Shared Global Area):

  1. Once the Instance is started it allocated memory to SGA.

  2. It is a basic component of oracle instance its size depends on RAM.

  3. Each database instance has its own SGA. Oracle Database automatically allocates memory for an SGA at instance startup and reclaims the memory at instance shutdown.

The SGA consists of

  • Database Buffer cache

  • The shared pool

  • The redo log buffer

  • The Large Pool

  • The Java Pool

​Database Buffer cache

  1. The database buffer cache is the portion of the SGA that holds copies of data blocks read from data files.

  2. LRU data writes into data files and MRU kept into memory.

  3. Its size can be manipulated via DB_CACHE_SIZE parameter.

​Shared Pool

Shared pool is broken into two small part memories –– Library Cache and Dictionary Cache. The library cache is used to stores information about the commonly used SQL and PL/SQL statements; and is managed by a Least Recently Used (LRU) algorithm. It is also enables the sharing those statements among users. In the other hand, dictionary cache is used to stores information about object definitions in the database, such as columns, tables, indexes, users, privileges, etc.

​Redo Log Buffer

Each DML statement (select, insert, update, and delete) executed by users will generates the redo entry. What is a redo entry? It is an information about all data changes made by users. That redo entry is stored in redo log buffer before it is written into the redo log files. To manipulate the size of redo log buffer, you can use the LOG_BUFFER parameter in init.ora initialization parameter file.

​Large Pool

Large pool is an optional area of memory in the SGA. It is used to relieves the burden place on the shared pool. It is also used for I/O processes. The large pool size can be set by LARGE_POOL_SIZE parameter in init.ora initialization parameter file.

​Java Pool

As its name, Java pool is used to services parsing of the Java commands. Its size can be set by JAVA_POOL_SIZE parameter in init.ora initialization parameter file.

​Program global area (PGA)

A PGA is a memory region that contains data and control information for a server process. It is non shared memory created by Oracle Database when a server process is started.

​Background Processes

Major Oracle Database’s background processes

  • Database writer DBWR

  • Log writer LGWR

  • System monitor SMON

  • Process monitor PMON

  • Checkpoint CKPT

The following are the major background processes of an Oracle instance:

​PMON:

PMON is the process monitor that regulates all other processes. PMON cleans up abnormally connected database connections and automatically registers a database instance with the listener process. PMON is a process that must be alive in an Oracle database.

PMON continuously monitor all user processes. If any of the user processes get terminated without releasing locks PMON releases the locks by rollback the transaction.

In case of shared server architecture, PMON restarts dead dispatchers.

​SMON:

SMON is the system monitor process that performs system-level clean-up operation. It has two primary responsibilities including automatically instance recovery in the event of a failed instance, e.g., power failure and cleaning up of temporary files.

In the event of instance failure or crash, SMON performs instance recovery. Instance recovery includes role forward or rollback.

Rollback means removing uncommitted data from respective data files.

Roll forward means writing completed transaction data from redo log files to respective data files.

In order to perform instance recovery, SMON is going to scan the redo and undo.

SMON also de-allocates the temporary segments.

​DBWR:

DBWR is the database writer. Oracle performs every operation in memory instead of the disk because processing in memory is faster and more efficient than on disk. The DBWn process reads data from disk and writes it back to the disk. An Oracle instance has many database writers DBW0, DBW1, DBW2, and so on.

  • The Database Writer writes modified blocks from the database buffer cache to the datafiles.
  • One database writer process (DBW0) is sufficient for most systems.
  • A DBA can configure up to 20 DBWn processes (DBW0 through DBW9 and DBWa through DBWj) in order to improve write performance for a system that modifies data heavily.
  • The initialization parameter DB_WRITER_PROCESSES specifies the number of DBWn processes.
DBWn writes the data to the respective data files under the following conditions.
  • when there are no free buffers.
  • when the no. of dirty buffers reaches a threshold value
  • when a timeout occurs
  • when we drop a table
  • when we truncate a table.
  • when we make the tablespace offline.
  • when we keep the tablespace in begin backup mode.
  • whenever log switch occurs.

​LGWR (log writer)

LGWR writes the data from redo buffer to redo log file.

Log writer writes the data into online redo log files under the following circumstances.

  • If one-third of the redo buffer cache is filled

  • If the data reaches 1 MB

  • If user commits

  • For every 3 secs

  • Before the DB writer writes the data to the respective data files.

​CKPT:

CKPT is the checkpoint process. In Oracle, data that is on disk is called block and the data which in memory is called buffer. When a block is written to the buffer and changed, the buffer becomes dirty, and it needs to be written down to the disk. The CKPT process updates the control and data file headers with checkpoint information and signals writing of dirty buffers to disk. Note that Oracle 12c allows both full and incremental checkpoints.

  • Whenever log switch occurs checkpoint occurs, which will be caused by the CKPT process.

  • During a checkpoint, CKPT signals DBWR to write the dirty buffers to the respective data files.

  • During a checkpoint, CKPT updates the checkpoint change number to the control file as well as the datafile headers.

​Physical Structures:

​Data files:

Data files contain real data, e.g., sales order and customer data. The data of logical database structures such as tables and indexes are physically stored in the data files.

​Control files:

Every database has a control file that contains metadata. The metadata describes the physical structure of the database including the database name and the locations of data files.

​Online redo log files:

Every database has an online redo log that consists of two or more online redo log files. An online redo log is made up of redo entries that record all changes made to the data.

​Logical Structures:

Oracle Database uses a logical storage structure for fine-grained control of disk space usage. The following are logical storage structures in an Oracle Database:

​Data blocks:

A data block corresponds to a number of bytes on the disk. Oracle stores data in data blocks. Data blocks are also referred to as logical blocks, Oracle blocks or pages.

​Extents:

An extent is a specific number of logically contiguous data blocks used to store the particular type of information.

​Segments:

A segment is a set of extents allocated for storing database objects, e.g., a table or an index.

​Tablespaces:

A database is divided into logical storage units called tablespaces. A tablespace is a logical container for a segment. Each tablespace consists of at least one data file.

​​Physical Files:

The physical files consists of datafiles, redo log files, and control files.

​Datafiles

A datafile is a file that correspondents with a tablespace. One datafile can be used by one tablespace, but one tablespace can has more than one datafiles. An Oracle database include of a number of physical files called datafile.

​Redo Log Files

A Redo Log is a file that is part of an Oracle Database. When a transaction is committed the transaction’s details in the redo log buffer is written in a redo log file. These files contain information that helps in recovery in the event of system failure.

​Control Files

Control files are used to store information about physical structure of database. The control file is absolutely crucial to database operations. It contains the following types of information:

  • Database Information

  • Archive log history

  • Tablespace and datafile records

  • Redo threads

  • Database’s creation data

  • Database name

  • Current Archive information

  • Log records

​Logical Storage Structures

Oracle Database allocates logical space for all data in the database. The logical units of database space allocation are data blocks, extents, segments, and tablespaces.

​Tablespace

A Tablespace is a grouping logical database objects. A database must have one or more tablespaces. Tablespace is composed by one or more datafiles.

​Segment

A Tablespace is further broken into segments. A segment is used to stores same type of objects. That is, every table in the database will store into a specific segment (named Data Segment) and every index in the database will also store in its own segment (named Index Segment). The other segment types are Temporary Segment and Rollback Segment.

A segment is a container for objects (such as tables, views, packages... indexes). A segment consists of Extends.

​Data Block

A data block is the smallest unit of storage in the Oracle database. The data block size is a specific number of bytes within tablespace and it has the same number of bytes.

​Extent

A segment is further broken into extents. An extent consists of one or more data block. When the database object is enlarged, an extent will be allocated. Unlike a tablespace or a segment, an extent cannot be named. Space for a data on a hard disk is allocated in extends.


Comments

Popular posts from this blog

How To Check Alert Log File in Oracle?

How To Enable/Disable Archive Log Mode In Oracle Database?