Wednesday 6 March 2013

Oracle 10g Architecture

Before going to explain about the oracle 10g it's better if we know some of the common terms that will mostly used in the database explanation.

Introduction to Oracle Database:

Data :
Data is a collection of information

Database:
Database is regarded as a repository of data stored in an organised manner.

Database Management System (DBMS):

It's a software which provide a basic layer for storing,managing and accessing the database. Stored data must be usable. Storing/retrieving data, deletion of data, modification of existing data are the basic database operations. A software tool or programme that handles these operations is called Database Management System.

 

RDBMS

RDBMS= DBMS + Referential Integrity (enforces the concepts of foreign key and primary concepts)
The database system in which the relationships among different tables are maintained is called Relational Database Management System. Both RDBMS and DBMS are used to store information in physical database.
RDBMS solution is required when large amounts of data are to be stored as well as maintained. A relational data model consists of indexes, keys, foreign keys, tables and their relationships with other tables. Relational DBMS enforces the rules even though foreign keys are support by both RDBMS and DBMS.

Difference between the DBMS and the RDBMS?

Simple in DBMS .there was no concepts of the relation between the data and table which is supproted in the RDBMS. The Codd rule is mainly supported to RDBMS not to DBMS.

DBMS vs. RDBMS
• Relationship among tables is maintained in a RDBMS whereas this not the case DBMS as it is used to manage the database.
• DBMS accepts the ‘flat file’ data that means there is no relation among different data whereas RDBMS does not accepts this type of design.
• DBMS is used for simpler business applications whereas RDBMS is used for more complex applications.
• Although the foreign key concept is supported by both DBMS and RDBMS but its only RDBMS that enforces the rules.
• RDBMS solution is required by large sets of data whereas small sets of data can be managed by DBMS.

How to interacting with the Oracle?
  • SQL------- The standard query language which is used to communicate with the database.
  • PL/SQL-----Need to be understand if you are DBA.
  • SQLPlus
  • iSQLPlus
  • DBCA
  • Enterprise Manager
  • Java and other Oracle Call Interfaces.(via concepts of JDBC and ODBC).
What is 'g' in Oracle 10g?

 'g' stands for Grid Computing in Oracle 10g .

Grid Computing is a concept in which the resources are
allocated to the networked users according to their needs.

Whenever a user is connected to the Oracle Database, it
computes the statistics and use of database by the user and
then provide the resources according to the usage by
independent user in the networked environment. In this
scenario the database become more scalable, available, high
in performance and more cost effective.

It makes the oracle database a automated Business application system.
 
Oracle 10g(Oracle sever)is the combination of
(Resources allocation + Information sharing + High availability)
 
The purpose of the database server is just to support the multiuser envinoment access to the 
data base and provide the data to them.It is also prevents unauthorized access and provides 
efficient solutions for failure recovery. 
 
Note:  grid computing provide

       resource sharing and automatic load balancing 

eg: if database server is full it will create another. 


The Oracle Architecture

A database is a centralized repository of organizational data. The Oracle 10g Database Server allows you to create, store, manage and retrieve the data in the database. A database administrator who is responsible for administering a database should have acomplete and thorough understanding of the architecture of the database.

The Oracle RDBMS stores data logically in the form of tablespaces and physically in the form of data files ("datafiles").Tablespaces can contain various types of memory segments, such as Data Segments, Index Segments, etc. Segments in turn comprise one or more extents. Extents comprise groups of contiguous data blocks. Data blocks form the basic units of data storage.

TableSpace: It is a pert of the database. Each databse is divided into many logical parts known as tablespace.Tablespace is nothing but the collection of the datafiles.

Every DATA BASE has a physical and a logical Structure.
The PHYSICAL STRUCTURE of the database mainly the actually data that are stored in the data base.As above mentioned it is the collection of the datafiles. About datafile you will get to know shortly( have faith).

The LOGICAL STRUCTURE of the database defines    
> One or more tablespaces.
> The database's schema objects (e.g., tables, views, indexes, clusters, sequences, stored procedures,triggers, packages etc.) 

The Oracle 10gDatabase product is made up three main components and they are as follows:


1.The Oracle Server – This is the Oracle database management system that is able to store, manage and manipulate data. It consists of all the files, structures, processes that form Oracle Database 10g. The 
Note: Oracle server is made up of an Oracle instance and an Oracle database.

 
2.The Oracle Instance –Consists of the memory(structures) components of Oracle and various  background processes.

 
3. The Oracle database – This is the centralized repository where the data is stored. It has a physical structure that is visible to the Operating system made up of operating system files and a logical structure that is recognized only the Oracle Server.It is the physical operating system files.
Oracle Database:
The number of files that are mainly resided in the database is: 
                                                                   1. Data File
                                                                   2. Control File
                                                                   3. Redo Log File

Data File: Oracle database data acutually stores in datafile .Whatever the data we are going to stored in the database those are automatic resided in the Data files.

Control File: It is used to control all other files in the database.  Control file contain the data about the database (meta data),Control files records the status of the physical structure of database 
Note:   (physical structure nothing but all database files)

> All necessary database files and log files are identified in the control file.
> The name of the database is stored in the control file.
> A control file is required to mount, open, and access the database.
Mounting  takes place before a computer can use any kind of storage device (such as a hard drive, CD-ROM, or network share).In some usages, it means to make a device physically accessible.

Redo log file:  The changes done in the database i.e all the transactions made in the db is stored in this files.A log file is a recording of everything that goes in and out of a particular server.
Important work of Redo log file is the recovery of the database when it gets failure due to software and hardware failure.  
 The minimum size of redo log file is four (4)-MB in 10g.
Example: It's like a Black-box Testing concept of Software Engineer(focus on the inner architecture).
Funny:  It is a concept much like the black box of an airplane that records everything going on with the plane in the event of a problem.

Some supported Files which are optional for the Oracle Database:
 1.  Parameter File- This file is used to define how the instance will be configured. Simply     we can say this file represent characteristic of instance. Whenever the database starts it is always check the parameter files for configure.(init.ora) is a parameter file .It defines an initial model condition.

A parameter file is a file that contains a list of initialization parameters and a value for each parameter. You specify initialization parameters in a parameter file that reflect your particular installation. Oracle supports the following two types of parameter files:
  • Server Parameter Files (spfile)
  • Initialization Parameter Files (pfile)

    Server Parameter Files

    A server parameter file is a binary file that acts as a repository for initialization parameters. The server parameter file can reside on the machine where the Oracle database server executes. Initialization parameters stored in a server parameter file are persistent, in that any changes made to the parameters while an instance is running can persist across instance shutdown and startup.Oracle Server parameters allow you to modify many aspects of the Oracle server.

    Initialization Parameter Files

    An initialization parameter file is a text file that contains a list of initialization parameters. The file should be written in the client's default character set.
    The following are sample entries in an initialization parameter file:
    PROCESSES = 100
    OPEN_LINKS = 12
    GLOBAL_NAMES = true
     
    To read more about Parameter files examples follow the below link:
     
    http://ss64.com/ora/syntax-parameters.html 

    https://confluence.sakaiproject.org/pages/viewpage.action?pageId=37290261

     http://docs.oracle.com/cd/B19306_01/server.102/b14237/initparams003.htm#i1124392

    2. Password Files: Oracle password file is used to allow some people to connect to the database with sysdba privileges.when someone wants to connect to the oracle database from a different client machine(remotely) then there should definetly be a oracle password file and the remote_login_passwordfile  parameter should be set to ‘exclusive’ in the init.ora file.

    To know more about password files go to the below link:
    http://www.oracleskill.com/oracle-world-wide-article/create-password-file-for-remote-login-as-sysdba.html

    3.Archived redo log files: An archived redo log file is a copy of one of the filled members of a redo log group. It includes the redo entries and the unique log sequence number of the identical member of the redo log group

    for more information on the this topic we can visit the following link:

    http://docs.oracle.com/cd/E11882_01/server.112/e25494/archredo001.htm

    The Oracle Instance:

    It is the combination of some of the background process and memory structure. 
    An instance is created in the memory every time the database is started.
    An oracle instance is the software which is mainly used for the executing and manage the data in the database. Same definition as of the DBMS.

    Memory Structure in oracle server: 


    It is divided into two parts : 1. Shared Memory(SGN=System Global Area)
                                                     2. Non-shared memory(ex. parameter files)

    It's better to you if you know about the dedicated server and shared server because it will help you to understand the concepts of the memory structure of the oracle server.

    Dedicated Server: The server which services only single user.
    Shared Server: the server which services to multiple user.

    SGN(System / Shared global Area) :

    <memory structures in the SGA are shared by every user in the database that's why the word shared used >

    Each Oracle instance uses a System Global Area or SGA—a shared-memory area—to store its data and control-information.
    Each Oracle instance allocates itself an SGA when it starts and de-allocates it at shut-down time
    The System Global Area (SGA) is a group of shared memory areas that are dedicated to an Oracle “instance” (an instance is your database programs and RAM).
    All Oracle processes use the SGA to hold information. The SGA is used to store incoming data (the data buffers as defined by the db_cache_size parameter), and internal control information that is needed by the database. You control the amount of memory to be allocated to the SGA by setting some of the Oracle “initialization parameters”.  These might include db_cache_size, shared_pool_size and log_buffer.
    In Oracle Database 10g you only need to define two parameters (sga_target and sga_max_size) to configure your SGA. If these parameters are configured, Oracle will calculate how much memory to allocate to the different areas of the SGA using a feature called Automatic Memory Management (AMM). As you gain experience you may want to manually allocate memory to each individual area of the SGA with the initialization parameters.

    Reference:  See the above figure you will get the idea what are the extra thing that the SGA contains.

    The SGA contains the following data structures:
    • the database buffer cache (db_cache_size)
    • the redo log buffer (log_buffer)
    • the shared pool
    • the large pool (optional)
    • the data dictionary cache
    • other miscellaneous information 

    Part of the SGA contains general information about the state of the database and the instance, which the background processes need to access; this is called the fixed SGA. No user data is stored here. The SGA also includes information communicated between processes, such as locking information. 


    a) The Database Buffer Cache:

    Buffer: It's nothing but the storage area.

    The Buffer Cache (also called the database buffer cache) is where Oracle stores data blocks.  With a few exceptions, any data coming in or going out of the database will pass through the buffer cache.It acts interface between the database and application.

    The total space in the Database Buffer Cache is sub-divided by Oracle into units of storage called “blocks”. Blocks are the smallest unit of storage in Oracle .

    For example, many Oracle professionals place indexes in a 32k block size and leave the data files in a 16k block size.

    The default size for the buffer pool (64k) is too small.

    Note:    The SGA's size and function are controlled by initialization (INIT.ORA or SPFILE) parameters. 

    Purpose of database buffer cache:

    No need to filter the database again & again for searching of a data. It minimize the  physical io. When a block is read by Oracle, it places this block into the buffer cache, because there is a chance that this block is needed again.
     

    Note: Reading a block from the buffer cache is less costly (in terms of time) than reading it from the disk.

    b) Redo log buffer(log_buffer) :

    The redo log buffer is the part of the System Global Area (SGA) that holds information about changes made to the database. Each of these changes generates a ‘redo entry’. Redo entries are needed to reconstruct these changes during the recovery process.

    The redo log buffer is a RAM area (defined by the initialization parameter log_buffer) that works to save changes to data, in case something fails and Oracle has to put it back into its original state (a “rollback”).  When Oracle SQL updates a table (a process called Data Manipulation Language, or DML), redo images are created and stored in the redo log buffer. Since RAM is faster than disk, this makes the storage of redo very fast.

    The Oracle redo log buffer provides the following functions within the Oracle SGA:
    • Serves for assistance with database recovery tasks
    • Records all changes made to database blocks
    • Places changes recorded to redo entries for redo logs. 

    c)Shared Pool

    It's like shared server concept . sharing the parsed sql statements with many number of users.

    The shared pool is a key component in SGA. The shared pool is like a buffer for SQL statements. It is to store the SQL statements so that the identical SQL statements do not have to be parsed each time they're executed.


    Again the shared divided into three parts as you she in the above figure.

    Library cache: It contains the recently executed sql, plsql code and the executed sql and plsql code.  For eg:- 

    If the user parses Sql statement, the library cache hold it,if the other user parses same sql statment it will give here.

    Data Dictionary cache:  

    Data dictionary contain information about database structures, contents, attributes and contain the defination and discription of the database object (tables,indexs,view etc).Oracle frequently refers to the data dictionary for its internal operations and updates it when your used creat,alter,drop objects. Just remeber the definition of the DDL (data definition language)

     

    Program Global Area:

     Note: Oracle server code: Each user has some Oracle server code executing on his or her behalf, which interprets and processes the application's SQL statements.

     

    The following table lists the different areas stored in the shared pool and their purpose:

     
    Background processes in oracle:

    To maximize performance and accommodate many users, a multiprocess Oracle Database system uses background processes. Because the basic concepts of the oracle is the (High availability, resources allocation and information sharing) and to support this mechanism oracle has run some of the back ground processes to handle the failures and crashes if any.

    Some of the background process that Oracle runs when an application starts are:

    1.SMON
    The System Monitor carries out a crash recovery when a crashed insance is started up again. It also cleans temporary segments. 

     2.PMON
    The Process Monitor checks if a user process fails and if so, does all cleaning up of resources that the user process has acquired. It mainly helps to free the resources ,so that other processes will use the resources freely.

    3. DBWR
    Database Writer or Dirty Buffer Writer process is responsible for writing dirty buffers from the database block cache to the database data files. Generally, DBWR only writes blocks back to the data files on commit, or when the cache is full and space has to be made for more blocks. The possible multiple DBWR processes in RAC must be coordinated through the locking and global cache processes to ensure efficient processing is accomplished.

    Writes the modified data to the files(i.e data files) on hard disk.

    4. LGWR -

     Log Writer process is responsible for writing the log buffers out to the redo logs. On regular intervals LGWR will move the redo from the redo log buffer to files on disk designed to store the redo called online redo log files.

    The simple define of the LGWR are: The Log Writer writes the redo log buffer from the SGA to the online redo log file.

     5.CKPT (checkpoint) :

      It tells the database writer is that boss now here the database gets changed.

    The checkpoint process is responsible for updating file headers in the database datafiles. A checkpoint occurs when Oracle moves new or updated blocks (called dirty blocks) from the RAM buffer cache to the database datafiles. A checkpoint keeps the database buffer cache and the database datafiles synchronized. This synchronization is part of the mechanism that Oracle uses to ensure that your database can always be recovered.

    6.Archiver (ARCn)

    One or more archiver processes copy the redo log files to archival storage when they are full or a log switch occurs.

    and remaining  are as follows:

    Recoverer (RECO) The recoverer process is used to resolve distributed transactions that are pending because of 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. For information about this process and how to start it, see Chapter 33, "Managing Distributed Transactions".
    Dispatcher (Dnnn) Dispatchers are optional background processes, present only when the shared server configuration is used. Shared server was discussed previously in "Configuring Oracle Database for Shared Server".
    Global Cache Service (LMS) In an Oracle Real Application Clusters environment, this process manages resources and provides inter-instance resource control.

      Program Global Area:

    It hold the session information and contains the private sql area

      DATA DICTIONARY :

    When you create a database ,you also create a data dictionary. Similarly when the status of the database gets changed according to that the data dictionary also gets updated.

    Oracle enterprise manager uses the data dictionary to get information about the database object in the database.

    For more information regarding the architecture of Oracle 10g you can visit the below 

    link: http://www.dba-oracle.com/concepts/

     

    http://careerride.com/oracle-db-architecture.aspx


     http://naveenkrishnadba.blogspot.in/2010/01/database-oracle-database-has-logical.html










     

 






 

 


No comments:

Post a Comment