ORACLE SERVER ARCHITECTURE
What is Oracle Sever ?
Oracle Server is a combination of Instance and database .
What is an Oracle instance ?
Instance is a gateway in-order to access the database.
Without instance we can’t access database and its objects .
Every database has its own instance.
An Oracle Instance consists of two different sets of components
- Background Processes
- Memory Structure
Instance is a combination of SGA(Memory components) and Background process.
what is SGA ?
SGA stands for Shared Global Area or System global Area.
System Global Area is also known as Memory Area.
With in a single db ,we will have single instance.
with in a single instance, we will have one SGA.
In one database we can create n no.of users but all the user will connect to one memory structure ,Thats why we can call it as Shared Global Area.
Whenever we system started ,some portion of RAM will be allocated to Kernel,when the Instance started some portion of RAM will be allocated to SGA.
SGA takes memory from RAM.
.An SGA comprises of Buffer cache, Redolog buffers and Shared pool area.
Automatic Shared Memory Management(ASSM) :
DBA can simply specify the total amount of SGA memory available to an instance using the SGA_TARGET initialization parameter.
The Oracle DB will automatically distribute this memory among various sub components to ensure most effective memory utilization.
When automatic SGA memory management is enabled, the sizes of the different SGA components are flexible and can adapt to the needs of a workload without requiring any additional configuration.
The DB automatically distributes available memory among various components as required, allowing system to maximize use of all available SGA memory.
SGA contains two types components
The Mandatory Components of SGA is
1.Database buffer cache
Database buffer cache
DBBC contains recently used blocks.
DBBC have three types buffers
1.Free buffers : it contains empty blocks
2.Pinned Buffer : It contains currently having latest transactions
3.Dirty Buffers : It contains all modified blocks but still available DBBC is known as Dirty Buffers
Shared Pool :
These are divided into two types
1.Library Cache(LC) : LC contains all the SQL ID’s ,Hash Value and Execution plans.
2.Data Dictionary Cache(DDC) : DDC contains all the metadata information.
Redo log Buffers :
RLB contains all the latest transaction information.
The Optional Components of SGA is
4.Result Cache etc..,
What is a process ?
A program under execution is known as Processs
What is Background process ?
A process which is running at the background is know as Background process.
Background processes are PMON, SMON, RECO, DBW0, LGWR, CKPT, D000 and others.
These processes perform input/output and monitor other Oracle processes to provide good performance and database reliability.
Theses background process are divided into types They are :
1.Mandatory Background Process
2.Optional Background Process
Mandatory Background Process
The Mandatory Background Process are
Process Name: SMON
Max Processes: 1
The system monitor performs recovery when a failed instance starts up again. In a Real Application Clusters database, the SMON process of one instance can perform instance recovery for other instances that have failed.
SMON also cleans up temporary segments that are no longer in use.
These transactions are eventually recovered by SMON when the tablespace or file is brought back online.
It also coalesces contiguous free extents in dictionary-managed tablespaces that have PCTINCREASE set to a non-zero value.
SMON checks the SCN in all datafile headers when the database is started.
Everything is OK if these entire SCNs match the SCN found in the controlfile. If the SCNs don’t match, the database is in an inconsistent state.
Process Name: PMON
Max Processes: 1
This process monitor performs process recovery when a user process fails. It will rollback uncommitted transactions.
PMON is also responsible for cleaning up the database buffer cache and freeing resources that were allocated to a process.
PMON also registers information about the instance and dispatcher processes with network listener.
PMON also checks on the dispatcher processes and server processes and restarts them if they have failed.
Process Name: LGWR
Max Processes: 1
The log writer process writes data from the redo log buffers to the redo log files on disk. The writer is activated under the following conditions:
When a transaction is committed, a System Change Number (SCN) is generated and tagged to it. Log writer puts a commit record in the redo log buffer and writes it to disk immediately along with the transactions redo entries.
Changes to actual data blocks are deferred until a convenient time (Fast-Commit Mechanism).
Logwriter will invoke in three states.
1.Every 3 seconds.
2.When the redo log buffer is 1/3 full.
When DBWn signals the writing of redo records to disk. All redo records associated with changes in the block buffers must be written to disk first (The write-ahead protocol).
While writing dirty buffers, if the DBWn process finds that some redo information has not been written, it signals the LGWR to write the information and waits until the control is returned.
Log writer will write synchronously to the redo log groups in a circular fashion. If any damage is identified with a redo log file, the log writer will log an error in the LGWR trace file and the system Alert Log. Sometimes, when additional redo log buffer space is required, the LGWR will even write uncommitted redo log entries to release the held buffers. LGWR can also use group commits (multiple committed transaction’s redo entries taken together) to write to redo logs when a database is undergoing heavy write operations.
Process Name: DBWR
Max Processes: 100
The database writer process (DBW) writes the contents of database buffers to data files.
DBW processes write modified buffers in the database buffer cache to disk.
Although one database writer process (DBW0) is adequate for most systems, you can configure additional processes—DBW1 through DBW9, DBWa through DBWz, and BW36 through BW99— to improve write performance if your system modifies data heavily. These additional DBW processes are not useful on uniprocessor systems.
The DBW process writes dirty buffers to disk under the following conditions:
When a server process cannot find a clean reusable buffer after scanning a threshold number of buffers, it signals DBW to write.
DBW writes dirty buffers to disk asynchronously if possible while performing other processing.
DBW periodically writes buffers to advance the checkpoint, which is the position in the redo thread from which instance recovery begins.
The log position of the checkpoint is determined by the oldest dirty buffer in the buffer cache.
In many cases the blocks that DBW writes are scattered throughout the disk. Thus, the writes tend to be slower than the sequential writes performed by LGWR. DBW performs multiblock writes when possible to improve efficiency.
The number of blocks written in a multiblock write varies by operating system.
When a checkpoint is issued. Please see checkpoint process below.
When a server process cannot find a clean reusable buffer after scanning a threshold number of buffers.
1.Every 3 seconds time-out.
2.When a log switch occurs
3.When Dirty-Blocks are becoming LRU Blocks
4.When Dirty-Blocks reaches to threshold value.
5.When Database shuts down.
Process Name: CKPT
Max processes: 1
Checkpoint process signals the synchronization of all database files with the checkpoint information. It ensures data consistency and faster database recovery in case of a crash. CKPT ensures that all database changes present in the buffer cache at that point are written to the data files, the actual writing is done by the Database Writer process.
The datafile headers and the control files are updated with the latest SCN (when the checkpoint occurred) this is done by the log writer process. The CKPT process is invoked under the following conditions:
When a log switch is done.
When the time specified by the initialization parameter LOG_CHECKPOINT_TIMEOUT exists between the incremental checkpoint and the tail of the log; this is in seconds.
When the number of blocks specified by the initialization parameter LOG_CHECKPOINT_INTERVAL exists between the incremental checkpoint and the tail of the log; these are OS blocks.
The number of buffers specified by the initialization parameter FAST_START_IO_TARGET required to perform roll-forward is reached.
Oracle 9i onwards, the time specified by the initialization parameter FAST_START_MTTR_TARGET is reached; this is in seconds and specifies the time required for
a crash recovery. The parameter FAST_START_MTTR_TARGET replaces LOG_CHECKPOINT_INTERVAL and FAST_START_IO_TARGET, but these parameters can still be used.
When the ALTER SYSTEM SWITCH LOGFILE command is issued.
When the ALTER SYSTEM CHECKPOINT command is issued.
Incremental Checkpoints initiate the writing of recovery information to datafile headers and control files. Database writer is not signaled to perform buffer cache flushing activity here.
Process Name: RECO
Max processes: 1
The Recoverer process is used to resolve distributed transactions that are pending due to a network or system failure in a distributed database. At timed intervals, the local RECO attempts to connect to remote databases and automatically complete the commit or rollback of the local portion of any pending distributed transactions.
Listener Registration Process
Process Name: LREG
The Listener Registration Process (LREG) registers information about the database instance and dispatcher processes with the Oracle Net Listener. When an instance starts, LREG polls the listener to determine whether it is running. If the listener is running, then LREG passes it relevant parameters. If it is not running, then LREG periodically attempts to contact it.
NOTE: In releases before Oracle Database 12c, PMON performed the listener registration.
Optional Background Process
The third article will continue with optional background processors