Copyright 2008
Agenda
Copyright 2008
INSTANCE
User Process
Data Dictionary Cache
Java Pool
Memory structure
Large Pool
DBWR DBWR
LGWR LGWR
CKPT CKPT
Data Files
Control Files
DataBase
Copyright 2008
Oracle DB Architecture
Terminology
Oracle Server:- Its is the database management system, that provides datbase concurrency,
consistency, prevent unauthorised access and provide efficient solution for failure recovery User process:- When a user starts a tool such as SQL*plus or runs an application Developed using a tool such as Oracle Forms, This application or tool is executed as User Process Server Process:- When a user logs on to the oracle server, a process is created on to the computer running the Oracle Server. This Process is called the Server process. The server Process communicates with the Instance on behalf of the User Process that runs on the client Connection:- Connection is communication pathway between user process and Oracle server. Session:-A session is a specific connection of a user to an oracle server. Session starts when user is validated by the Oracle server and ends when user logs out
User Process
Conn. Established
Server Process
Session Created
Oracle Server
Database User
Copyright 2008
Oracle DB Architecture
Interaction with the Database ( Dedicated Server )
This configuration maintains a one-to-one ratio between the number of user processes and server processes Copyright 2008
Oracle DB Architecture
Interaction with the Database ( Shared Server )
In a Shared Server Environment, a server process handles request of several user processes.
3 6 4 2 7 5
Copyright 2008
Parameter file
Used to start an instance Two types : SPFILE and PFILE
Copyright 2008
Example
DB_NAME=mynewdb INSTANCE_NAME=mynewdb CONTROL_FILES=("/vobs/oracle/oradata/mynewdb/control01.ctl", "/vobs/oracle/oradata/mynewdb/control02.ctl", "/vobs/oracle/oradata/mynewdb/control03.ctl") DB_BLOCK_SIZE=4096 DB_CACHE_SIZE=20971520 JAVA_POOL_SIZE=31457280 LARGE_POOL_SIZE=1048576 SHARED_POOL_SIZE= 52428800 UNDO_MANAGEMENT=AUTO UNDO_TABLESPACE=undotbs BACKGROUND_DUMP_DEST=/vobs/oracle/admin/mynewdb/bdump CORE_DUMP_DEST=/vobs/oracle/admin/mynewdb/cdump USER_DUMP_DEST=/vobs/oracle/admin/mynewdb/udump
Copyright 2008
Oracle Architecture
Internal Memory Structures SGA
System or shared Global Area (SGA)
In an Oracle database, the SGA is the part of the RAM used by the Oracle processes. This part of memory is shared by all Oracle processes. All necessary information necessary for the instance operation are present here. SGA Database buffer cache Shared Pool Database Redo Log Redo log buffer Buffer Cache Buffer Library Shared pool Cache Java Pool Java Pool Large Pool Large Pool Data Dictionary Request & response queues Cache Request Response Queue Queue (shared server)
Copyright 2008
Oracle Architecture
Database buffer cache
It holds copies of data blocks read from datafiles Organised in two lists: The write list - contains data Modified but not written to disk LRU list
1) Free buffers - that do not contain any useful data and are
Write List
LRU list
..Free
Oracle Architecture
Least Recently Used (LRU)
LRU and the database buffer cache
Every time a data block is read from disk it is placed in the database buffer cache at the head of the Pinned list If a block is already in the cache and it is read again it is moved to the head of the list Data not used frequently is aged out of the cache while frequently used data remains
Copyright 2008
Oracle Architecture
Redo Log Buffer
A circular buffer that contains Changes made to datafile blocks Redo entries take up contiguous, sequential space in the buffer Primary purpose is recovery i.e to recreate the data prior to change made by INSERT,UPDATE,DELETE, ALTER or DROP Data stored in the redo log buffer is periodically written to the online redo log files
Copyright 2008
Library Cache
- shared
Shared Pool
Library Cache
SQL area -The shared SQL area stores each SQL statement executed in the database. This area allows SQL execution plans to be reused by many users.
- private
SQL area- each user must have a separate copy of the statement private SQL area
- PL/SQL
procedures and package Used to hold parsed and compiled PL/SQL program units, allowing the execution plans to be shared by many users.
Copyright 2008
Dictionary Cache
Oracle Architecture
Least Recently Used (LRU)
Dictionary Cache - Collection of most recently used definitions in database.
- Includes information about database files, tables, indexes, user priviledges and other database objects - During Parse phase, server process looks at data dictionary for information to resolve object names and validate access.
Copyright 2008
Oracle Architecture
Internal Memory Structures PGA
Program or process Global Area (PGA)
Used for a single process Not shareable with other processes Writable only by the server process Allocated when a process is created and deallocated when a process is terminated Contains:
Sort area Used for any sorts required by SQL processing Session information Includes user privileges Stack space Contains session variables
Copyright 2008
Oracle Architecture
Large Pool & JAVA Pool Large Pool
Relieves the burden of Shared Pool used to support parallel query, RMAN backup and recovery operations and Oracle shared server technologies.
JAVA Pool
Service Parsing requirements for JAVA commands
Copyright 2008
Oracle Architecture
Background Processes - DBWR
Writes contents of database buffers to datafiles DBWR writes when
INSTANCE
SGA
Checkpoint occurs Dirty buffers reach threshhold There are no free buffers Tablespace OFFLINE Tablespace READ ONLY Table DROP or TRUNCATE Tablespace BEGIN BACKUP
Data Files
DBWR
DataBase
Copyright 2008
Oracle Architecture
Background Processes - DBWR
DBWR writes to disk when:
A server process cannot find a clean reusable buffer A timeout occurs (3 sec) A checkpoint occurs DBWR cannot write out dirty buffers before they have been written to the online redo log files
Copyright 2008
Oracle Architecture
Background Processes - LGWR
Writes contents of redo log buffers to online redo log files LGWR writes when
INSTANCE
SGA
At commit When one-third full When there is 1 MB of redo Every 3 seconds Before DBWR write to datafiles
DataBase
Copyright 2008
LGWR
Oracle Architecture
Background Processes - SMON
Performs automatic instance recovery Rolls forward changes made in online redo log files but not to datafiles Opens database for user access Reclaims space used by temporary segments no longer in use SMON wakes up regularly to check whether it is needed or it may be called directly For example, if Oracle crashed hard with a power failure, the SMON process is attached at startup time, and detects any uncompleted work, using the rollback segments to recover the transactions
Copyright 2008
Oracle Architecture
Background Processes - PMON
Performs automatic process recovery
Cleans up abnormally terminated connections Rolls back non committed transactions Releases resources held by abnormally terminated transactions
Restarts failed shared server and dispatcher processes PMON wakes up regularly to check whether it is needed or it may be called directly Mandatory process
Copyright 2008
Oracle Architecture
Background Processes - PMON
Detects both user and server aborted database processes Automatically resolves aborted processes
PMON rolls back the current transaction of the aborted process Releases resources used by the process If the process is a background process the instance most likely cannot continue and will be shut down
Oracle Architecture
Background Processes - CKPT
Purpose is to ensure that all the buffers in database buffer cache that were modified prior to a point in time has been written to data files
Occurs whether or not the data has been committed CKPT does not actually write out buffer data Updates datafile headers with checkpoint information Updates control files with checkpoint
Copyright 2008
Oracle Architecture
Background Processes - ARCH
Automatically copies online redo log files to designated storage once they have become full
Copyright 2008
Oracle Architecture
Data File
The datafiles contain all the database data The data of logical database structures, such as tables and indexes, is physically stored in the datafiles allocated for a database. A datafile can be associated with only one database. Datafiles can have certain characteristics set to let them automatically extend when the database runs out of space.
Tablespace
Datafile Segment Segment Datafile Segment
CopyrightBlocks 2008
Oracle Architecture
Redo File
Oracle database has a set of two or more redo log files. A log switch is the point at which the database stops writing to one redo log file and begins writing to another Oracle Database assigns each redo log file a new log sequence number every time a log switch occurs.
Log Switch Log Switch
File Group 1
File Group 2
File Group 3
Member
Member
Member
Disk 1
Member
Member
Member Disk 2
Copyright 2008
Oracle Architecture
Redo File
Filled redo log files are available to LGWR for reuse depending on whether archiving is enabled.
If archiving is disabled (the database is in NOARCHIVELOG mode), a filled redo log file is available after the changes recorded in it have been written to the datafiles. If archiving is enabled (the database is in ARCHIVELOG mode), a filled redo log file is available to LGWR after the changes recorded in it have been written to the datafiles and the file has been archived.
Copyright 2008
Oracle Architecture
Control File
A control file is a small binary file that is part of an Oracle database. The control file is used to keep track of the database's status and physical structure. Contents
The control file contains information like: Database name Timestamp of database creation Names and locations of Data Files Names and locations of Redo Log files The current log sequence number Checkpoint information Recent RMAN backups taken Etc
Copyright 2008
Oracle Architecture
Transaction Example - Update
Copyright 2008
Oracle Architecture
Transaction Example - Update
Copyright 2008
Oracle Architecture
Transaction Example - Update
Copyright 2008
Oracle Architecture
Transaction Example - Update
Copyright 2008
Oracle Architecture
Transaction Example - Update
Copyright 2008
Oracle Architecture
Transaction Example - Update
Copyright 2008
Oracle Architecture
Transaction Example - Update
1 ROW UPDATED
Copyright 2008
Oracle Architecture
Transaction Example - Update
COMMIT
Copyright 2008
Oracle Architecture
Transaction Example - Update
COMMIT SUCCESSFU L
Copyright 2008
Oracle Architecture
Transaction Example - Update
Copyright 2008
Thanks
Copyright 2008