Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 - Oracle Server Architecture Overview

Similar presentations


Presentation on theme: "1 - Oracle Server Architecture Overview"— Presentation transcript:

1 1 - Oracle Server Architecture Overview
Oracle Database Data files, Control files, Redo log files Other Files Parameter file, Password file, Archive logs Oracle Instance SGA (Shared Global Area) Buffer Cache Shared Pool Library Cache Data Dictionary Cache Redo Log Buffer Large Pool Java Pool Background Processes DBWR, LGWR, SMON, PMON, CKPT, ARCH Other Processes User processes Server processes PGA Query Processing Rollback Segments The Oracle Server is comprised of the Oracle Instance and the Oracle Database. The Oracle Instance is the combination of background processes and memory structures (SGA - Shared Global Area). The SGA is a shared area of memory used by Oracle. Background processes perform a variety of tasks. Many are required for the server to run. Some are optional. Other Processes - User Processes and Server Processes Database files - Data files, Redo Log Files, Control Files Oracle Software - Located in $ORACLE_HOME, contains the binaries to operate and manage the server.

2 1 - Oracle Server Architecture Overview
Oracle Instance Server Process SGA (System Global Area) PGA Database Buffer Cache Shared Pool Redo Log Buffer Java Pool (optional) User Process Large Pool (optional) DBWR LGWR SMON PMON CKPT RECO Other Files... Parameter, Password, Archive Logs The Oracle Server is comprised of the Oracle Instance and the Oracle Database. The Oracle Instance is the combination of background processes and memory structures (SGA - Shared Global Area). The SGA is a shared area of memory used by Oracle. Background processes perform a variety of tasks. Many are required for the server to run. Some are optional. Other Processes - User Processes and Server Processes Database files - Data files, Redo Log Files, Control Files Oracle Software - Located in $ORACLE_HOME, contains the binaries to operate and manage the server. ARCH LCKn Pnnn Dnnn SNPn Oracle Database Data files Redo Log Files Control Files

3 Database Files Data files Redo log files Control files Store the data
Can only be associated with 1 database Form logical units called a tablespace Redo log files Record all of the changes in the database Must have at least 2 groups Oracle recommends each group have 2 members on separate devices Control files Database name Time stamp of database creation Name and locations of all data files and redo log files Data files - Are the actual files on disk that contain the Oracle database. A database must have at least one data file. Here is what you need to know. 1. A data file can only be associated with one database. 2. Data files can be configured to grow automatically. 3. One or more data files form a logical unit of data storage called a tablespace. A data file can only belong to a single tablespace but a tablespace can have many data files. Redo logs - Contain a record of the changes made in the database. Think of them as a recorder. Every time something changes in the database it is recorded in the Redo Logs. Your database must have at least 2 redo log groups. Control Files - The control files contain information about the database. For the time being think of the control file as the file that keeps everything in sync. The control file can tell if all of the files are consistent to a point in time. You will never, ever, never want to lose your control files! How do you avoid this? You multiplex them. Another way of saying copy them off to another secure location.

4 Other Files Parameter files Password file Archive redo log files
Store hundreds of parameters for the Oracle Instance Password file Authenticates which users are allowed to start and stop the database Archive redo log files Copies of the redo log files that are saved so the database can be recovered to a single point in time Parameter File - Contains numerous parameters that are read when the database is started. In fact you will need to know at what stage of startup that the parameter file is actually read in (MOUNT). Password File - Used to authenticate users from the operating system. Obviously database passwords don't work if the database is not running so you need this file to authenticate users who are able to start and stop the database. Created by the ORAPWD utility that comes installed with the database software. Archived Log Files - You already know that the Redo Log files act like a recorder. Well what happens when the recorder is full? If your database is archiving then it is copied to another location for storage and then used again. This allows you to recover your database to any single point in time. Other Files... Parameter, Password, Archive Logs

5 The Oracle Instance Oracle Instance is comprised of the background processes and memory structures (SGA - Shared Global Area) Oracle Instance SGA (System Global Area) Database Buffer Cache Shared Pool Redo Log Buffer Java Pool To get you started you need to know that when someone refers to the Oracle Instance they should be referring to the combination of the background processes & the SGA. An instance can only open one database at a time. The SGA can be broken in to a large number of smaller components but for now you really only need to know about 3 of them. As the other two are optional. 1. Buffer Cache - Stores the most recent data that has been used by the system. Obviously the more data you squeeze into memory the faster the database will be. This is usually the largest part of the SGA. 2. Shared Pool - Since almost all interaction with the database involves SQL it makes us to store that in memory also. SQL is stored in the shared pool. There are actual 2 components of the shared pool that will be important to distinguish. The library cache and the data dictionary cache. Lib Cache: The library cache stores the most recently used SQL in memory. It stores the actual text of the SQL. D.D Cache: Stores the object definitions, users and privileges in memory 3. Redo Log Buffer - We talked about the Redo Log files already and mentioned that they act as a recorder. Well before the changes in the database are recorded they have to be passed through an area of memory called the Redo Log Buffer. It is usually the smallest area of the SGA. A 1 MB Redo Log Buffer is considered pretty big. 4. Java Pool - Used to store Java code. 5. Large Pool - The large pool is an optional area in the SGA that provides large memory allocations for Oracle backup and restore operations, I/O server processes, and session memory for the multi-threaded server and Oracle XA. Oracle XA is Oracle's implementation of the X/Open Distributed Transaction Processing (DTP) XA interface Large Pool DBWR LGWR SMON PMON CKPT RECO ARCH LCKn Pnnn Dnnn SNPn

6 Shared Pool Shared Pool Library Cache
Stores the most recently used SQL statements Data Dictionary Cache (Row Cache) Stores definitions of objects contained in the database Used to validate object names and privileges Size is set by the SHARED_POOL_SIZE parameter in the initialization file (parameter file). SGA (System Global Area) We discussed earlier that one component of the SGA is the shared pool. You should know that the shared pool can also be broken down into the library cache and data dictionary cache. For performance reasons it is beneficial to store as much of the database in memory as possible. What is stored in memory needs to be segregated however because some things are more important than others. The buffer cache stores data. However the library cache and data dictionary cache store something entirely different. The library cache stores the most recently used SQL in memory. It stores the actual text of the SQL, the parse tree (a compiled version of the statement) and the execution plan. The data dictionary cache stores the object definitions, users and privileges in memory so they can also be accessed quickly when needed. You size the shared pool as a whole and can not control the individual size of the library cache or data dictionary cache. It is sized by changing the SHARED_POOL_SIZE parameter in the parameter file and restarting the database. Database Buffer Cache Shared Pool Redo Log Buffer Java Pool Large Pool

7 Buffer Cache Area of memory used to store the most recently used data. Oracle knows which data is most likely to be used again by maintaining a list of recently used blocks called the LRU. Operation A request for data is made Oracle checks the buffer cache to see if it exists If not it grabs the block from disk (physical read) The database buffer cache is usually the largest portion of memory set aside for Oracle. It stores the most recently used data and is shared by all users. Data that is used a lot or data that has been used recently had the highest chance of being used again. That is why it is a good idea to store this data in memory where is can be accessed quickly. You should know what the LRU is. It stands for Least Recently Used. This is the algorithm that Oracle uses to determine which pieces of data to store in the buffer cache. In most cases all of the data in the database can not be stored here so Oracle has to decide what stays and what goes. Oracle used the LRU list to determine what data will soon be overwritten with new data requests from disk. One other thing that is a bit more advanced but important to know is that when a full table scan is performed on a table the data is moved to the least recently used end of the LRU list because it is unlikely you wanted to keep all this data in memory. A full table scan occurs when Oracle has to check every single record in a table for some data you requested. SGA (System Global Area) Database Buffer Cache Shared Pool Redo Log Buffer Java Pool Large Pool

8 Sizing the Buffer Cache
DB_BLOCK_SIZE = 8192 8K 8K 8K DB_BLOCK_BUFFERS = 5 Sizing the database buffer cache is pretty easy. All you need to do is change the number of DB_BLOCK_BUFFERS in the parameter file and restart the instance to increase or decrease the amount of memory in the buffer cache. You can not change the block size once the database has been created. In this example you can see my block size is 8K. I have 5 blocks in my buffer cache (note this is very small just for the example). If you multiply 8K * 5 blocks you get a total size of 40K. Oracle 9i has brought us dynamic memory allocation so we will not need to restart the server to enact memory changes. 8K 8192 * 5 = Bytes (40K) 8K

9 Redo Log Buffer Circular buffer that records all of the changes occurring in the database Size Defined by LOG_BUFFER parameter Should be a multiple of DB_BLOCK_SIZE Usually small compared with total SGA size, small increase can significantly enhance throughput As of Oracle 8 a 1 MB upper limit has been set on the background write threshold which limits the negative impact of a very large redo log buffer Data is written from the redo log buffer to the redo log files by the log writer process

10 Large Pool and Java Pool
Optional areas of memory LARGE_POOL_SIZE Oracle Instance SGA (System Global Area) Database Buffer Cache Shared Pool Redo Log Buffer Java Pool Large Pool You should also know about 2 optional areas of the SGA. 1. Java Pool - Used to store Java code. 2. Large Pool - When a large pool has been configured it will be used for session memory instead of the shared pool when running in MTS. It is also used to speed up backup and restore operations because the large pool is better suited than the buffer pool for the types of requests these operations incur. DBWR LGWR SMON PMON CKPT RECO ARCH LCKn Pnnn Dnnn SNPn

11 Background Processes 5 background processes are mandatory
Database Writer (DBWR) Log Writer (LGWR) System Monitor (SMON) Process Monitor (PMON) Checkpoint (CKPT) Required as of Oracle 8i DBWR LGWR SMON PMON CKPT RECO DBWR (Database Writer) - Writes modified (dirty) buffers from the buffer cache to disk. Operates in batch mode for greater efficiency. LGWR (Log Writer) - Writes the data from the Redo Log Buffer to the Redo Log Files. SMON (System Monitor) - Coalesces contiguous free space, cleans up temporary segments and performs instance recovery if required when the database is restarted. PMON (Process Monitor) - Performs process recovery when a user process fails and makes any used resources available again. CKPT (Checkpoint) - Updates the status of the database in the control files and the data files signaling that the modified data in the buffer cache has been successfully written to disk. Besides know what each of these processes does you should know when and what causes them to actually perform their jobs. There are actually a lot more background processes you should know about but these are the required processes. If any of these 5 are not running the database will crash. Don't worry they start automatically when you start the database. ARCH LCKn Pnnn Dnnn SNPn

12 Database Writer (DBWR)
Writes modified (dirty) blocks in the buffer cache to the data files Operates in batch mode When There are too many dirty blocks DB_BLOCK_MAX_DIRTY_TARGET A process scans a specified number of buffers in the LRU list without finding a free buffer A time-out occurs (every 3 seconds) A checkpoint occurs You can configure additional DBWR processes by setting the DB_WRITER_PROCESSES parameter in the parameter file A Checkpoint is a means of synchronizing the database buffer cache with the data files.

13 Log Writer (LGWR) Writes information in the redo log buffer to the redo logs Writes When: Every time a commit is issued When redo log buffer is 1/3 full When there is more than 1 MB of changes Before DBWR (DB Writer) completes cleaning modified buffer blocks in the buffer cache by writing them to the data files When a timeout occurs (every 3 seconds)

14 System Monitor (SMON) Automatically recovers the instance during instance failure Rolls forward transactions in the redo logs that have not been written to disk Opens the database and makes locked data available Rolls back uncommitted transactions Space Maintenance Functions: Coalesces free space De-allocates temporary segments If a instance shuts down, if for example the O/S fails.. SMON will perform instance recovery by : Rolling forward to recover data recorded in the online redo logs. In this case the data has not been written to disk But the changes have been recorded in the redo logs. So SMON reads the redo log files and applies changes to the data blocks.

15 Process Monitor (PMON)
Cleans up failed processes by handling existing transactions and recovering memory Rolls back existing transactions Releases any locks held by the process Releases other resources held by the process Checks server and dispatcher processes and restarts them when necessary

16 Checkpoint (CKPT) Used to synchronize data files, mandatory in Oracle 8i In Oracle 8 takes it handles the task of updating the data file headers instead of log writer Frequent checkpoints increase the speed of database recovery during instance failure but may hinder performance CHECKPOINT_PROCESS = True (Before 8i)

17 Connecting to the Database
A user process always connects to the database via a server process Oracle Instance Server Process SGA (System Global Area) PGA Database Buffer Cache Shared Pool Redo Log Buffer Java Pool User Process You should know how a user actually gets a connection to an Oracle database. What you need to know is that the user process is created by running some sort of tool like SQL*Plus. The user process then communicates to the server process and the server process brokers all of the requests from the user process. In a dedicated server configuration each user process gets it's own server process. This can consume a lot of memory if you have thousands of users connecting to the database. This is why we have something called multithreaded server mode. When you are running your database in multithreaded server mode you force the server to share server processes between user processes. Large Pool DBWR LGWR SMON PMON CKPT RECO ARCH LCKn Pnnn Dnnn SNPn

18 PGA (Program Global Area)
Used by only one process and is not shared Gets Created when Server Process Starts. Contents Stack space Session information Cursor state Sort area Server Process A PGA is created for each server process and may only be written to by code acting on behalf of the server process. The size of the PGA is fixed and operating system specific. PGA's are created and destroyed with its associated process. Stack Space - Memory allocated to hold a sessions variables and arrays. Session Information - Information about the session is stored in the PGA when running in dedicated server mode. If you are running in multithreaded server configuration the session information is in the SGA. Specifically it is in the large pool if you have one configured Cursor State - State of SQL being processed by this session. Sort area - Space used for sorts. PGA User Process

19 Query Processing Parse Execute Fetch Oracle Instance Server Process
SGA (System Global Area) PGA Database Buffer Cache Shared Pool Redo Log Buffer Java Pool User Process Query processing takes place in 3 basic steps. Large Pool DBWR LGWR SMON PMON CKPT RECO ARCH LCKn Pnnn Dnnn SNPn

20 Query Processing Parse Execute…continued
SQL statement is passed from user process to server process Server process looks in shared pool to see if SQL already exists Validates SQL by checking the syntax Checks the data dictionary to ensure all of the objects and columns actually exist Locks on objects are obtained so the definition does not change Checks the users privileges Determines the execution plan Loads the SQL and the plan into the shared SQL area Execute…continued

21 Query Processing Parse Execute Fetch
Identifies the rows that are selected Fetch Returns the rows to the user process and ordered if necessary

22 Rollback Segments Record the “before” image before data is actually changed in the database Purpose Allows user to roll back a transaction Allows other users to see the original image until the changes have been committed Allows the database to be recovered if the instance fails


Download ppt "1 - Oracle Server Architecture Overview"

Similar presentations


Ads by Google