Instance Equals Processes and Memory Structures : A Back-to-Basics Guide

Instance Equals Processes and Memory Structures : A Back-to-Basics Guide

The definition of an instance is simple and basic: it is a set of memory structures that manage the database files. When the instance starts, background processes such as LGWR, PMON, etc., also start.

It’s important to know that at least one active or running database must have an associated instance. Similarly, since the instance exists in memory and the database exists on disk, an instance can exist without a database, and a database can exist without an instance. If you don’t believe this, try starting the instance in nomount mode, and you’ll see that without the datafiles, control files, and redo logs, you can start the instance:

TESTDB >startup nomount

ORACLE instance started.
Total System Global Area 1369989120 bytes
Fixed Size 2158184 bytes
Variable Size 268439960 bytes
Database Buffers 1090519040 bytes
Redo Buffers 8871936 bytes

oracle@localhost [TESTDB] /mount/dba01/oracle/TESTDB/admin
oracle $ ps -eaf | grep TESTDB

oracle 27411 1 0 01:21:35 ? 0:00 ora_pmon_TESTDB
oracle 27448 1 0 01:21:37 ? 0:00 ora_ckpt_TESTDB
oracle 27435 1 0 01:21:37 ? 0:00 ora_dia0_TESTDB
oracle 27439 1 0 01:21:37 ? 0:00 ora_dbw0_TESTDB
oracle 27454 1 0 01:21:37 ? 0:00 ora_mmon_TESTDB
oracle 27415 1 0 01:21:35 ? 0:00 ora_psp0_TESTDB
oracle 27444 1 0 01:21:37 ? 0:00 ora_dbw1_TESTDB
oracle 27431 1 0 01:21:37 ? 0:00 ora_diag_TESTDB
oracle 27446 1 0 01:21:37 ? 0:00 ora_lgwr_TESTDB
oracle 27452 1 0 01:21:37 ? 0:00 ora_reco_TESTDB
oracle 27450 1 0 01:21:37 ? 0:00 ora_smon_TESTDB

Below is a small diagram of how an instance is formed:

Due to what we discussed above, this allows for the configuration for RAC (Real Application Cluster). It’s also important to know that an instance can only have one database associated at a time, meaning you cannot mount two databases in one instance.

Memory

The SGA (System Global Area) has three basic structures:

  • Database Buffer Cache: This is the memory area that stores copies of data blocks read from the data files. It’s also known simply as Buffer Cache. This section of memory has three states:

    • Unused: The buffer is available because it has never been used or is currently unused.
    • Clean: This buffer was previously used and now contains a consistent version of the data block at a point in time. The block contains data but is considered clean since it doesn’t need a checkpoint.
    • Dirty: The buffer contains data that hasn’t been written to disk; Oracle needs to checkpoint the data block before reusing it.

    To manage these states, Oracle has an algorithm called LRU (Least Recently Used), which evicts the least-used data blocks that have already been checkpointed to make room for new data in the Buffer Cache, avoiding the removal of frequently used data.

  • Shared Pool: This memory area stores parsed SQL, system parameters, and the data dictionary (Data Dictionary Cache and Library Cache).

  • Redo Log Buffer: This memory structure in the SGA stores redo records, which contain the information necessary to reconstruct changes made by DDLs or DMLs to the database.

Processes

There are several mandatory processes, such as those mentioned below. Similarly, there are many processes that start once you add some functionality, like ARCn, which is when the database is in archivelog mode.

  • PMON: The function of this process is to monitor that the other processes of the instance are running. It is also responsible for cleaning the Database Buffer Cache and resources that the client has used.

  • SMON: The main task of this process is system-level cleaning. One of its main tasks is to perform recovery when starting the instance after it previously terminated abruptly, such as a shutdown abort or server crash.

  • CKPT: Its function is to update the headers of the control files and data files with checkpoint information (SCN, checkpoint position, etc.). It also informs DBWn to write the Buffer Cache blocks to disk. It’s important to know that CKPT does not write data to the Redo Log or data files.

  • DBWn: This process writes the dirty contents of the Buffer Cache. It’s known as a lazy process because it doesn’t write to disk on its own; it only writes to disk when there are no clean data blocks in the Buffer Cache or when CKPT informs it to do so.

  • LGWR: This process writes the Redo Log Buffers to disk (Online Redo Log). It uses a method known as Fast Commit. When a user executes a commit, the transaction is assigned an SCN (System Change Number). LGWR marks the commit in the Buffer Cache and immediately writes to disk. When this data has been written to the Online Redo Log, the process updates the Buffer Cache, indicating that it has been written to disk.

Conclusion

I hope this brief explanation helps you understand the difference between an instance and what is known in Oracle as a database. Similarly, the basic processes and memory of the instance are mentioned here. There are more processes and memory structures than those mentioned here, but these are the minimum necessary in an Oracle configuration.

Rene Antunez
[email protected]
No Comments

Leave a Reply