Oracle Architecture

Embed Size (px)

DESCRIPTION

oracle database archotectures

Citation preview

  • ORACLE ARCHITECTURE

    Posted by Narashim Reddy .R on August 15, 2009

    4 Votes

    ORACLE ARCHITECTURE

    The Structural and Functional representation of Oracle DataBase

    Server.

    Oracle Server:

    Is a database management system.

    It provides an open, comprehensive integrated approach to

    information management.

    It consists of Oracle Instance and Oracle Database.

    It reliably manage a Large Amount of Data in a MultiUser

    Environment so that many Users can Concurrently Access the Same

    Data.

    Oracle Database:

    The general purpose of a database is to Store and Retrieve Related

    Information.

    Data:Collection of Related Information.

    Base:Is a Place where Data is Stored.

    It consists of Physical Structure And Logical Structure.

    The Physical Struct ure of the Database is the Set of Operating

    System Files(DataBase Files).

    The DataBase Files provide the Actual Physical Storage for DataBase

    Information.

    Important View in Database:

    SQL> select DBID,NAME,LOG_MODE,CHECKPOINT_CHANGE#,

    CONTROLFILE_CREATED,CONTROLFILE_TIME,OPEN_RESETLOGS,VERSIO

    N_TIME,OPEN_MODE

    2 from v$database;

    DBID NAME LOG_MODE CHECKPOINT_CHANGE# CONTROLFI

    CONTROLFI OPEN_RESETL VERSION_T OPEN_MODE

    - -

  • 2356734140 RUBRICS ARCHIVELOG 1400417 19 -NOV-08 14 -DEC-08

    NOT ALLOWED 19 -NOV-08 READ WRITE

    SQL> select PROTECTION_MODE,DATABASE_ROLE,CURRENT_SCN,

    FLASHBACK_ON,DB_UNIQUE_NAME,PLATFORM_ID ,

    FS_FAILOVER_STATUS from v$database;

    PROTECTION_MODE DATABASE_ROLE CURRENT_SCN FLASHBACK_ON

    DB_UNIQUE_NAME PLATFORM_ID FS_FAILOVER_STATUS

    -

    MAXIMUM PERFORMANCE PRIMARY 1401592

    NO RUBRICS 10 DISABLED

    Oracle Instance:

    Is a means to Acc ess an Oracle Database.

    An Instance is Identified by using methods specific to each

    Operating System.

    The Instance can open and use only one Database at a Time.

    An Oracle Instance is the Combination of the Background Process

    and Memory Structure.

    Every time an Instance is Started, a System Global Area(SGA) is

    allocated and Oracle Background Processes are Started.

    Important View in Instance:

    SQL> select INSTANCE_NUMBER,

    INSTANCE_NAME,HOST_NAME,VERSION,STATUS from v$instance;

    INSTANCE_NUMBER INSTANCE _NAME HOST_NAME VERSION STATUS

    - -

    1 tarun4 rubrics 10.2.0.1.0 OPEN

    SQL> select THREAD#, ARCHIVER, DATABASE_STATUS,ACTIVE_STATE

    from v$instance;

    THREAD# ARCHIVE DATABASE_STATUS ACTIVE_ST

    - -

    1 STA RTED ACTIVE NORMAL

    User Process:

    A Database User who needs to request information from the

    Database must first

    make a connection with the Oracle Server.

    The connection is requested using a Database interface tool, such

    as SQL*PLUS, and beginning the User Process.

  • Server Process:

    Once a User has established a connection, a Server Process is

    Started to Handle the User Process request.

    A Server Process can be either Dedicated Server Process or Shared

    Server Process.

    In a Dedicated Server environment, the Server Process Handles the

    request of a Single User Process.

    In a Shared Server environment, the Server Process Handles the

    request of Several User Process.

    Physical Structure

    Database Files: NonDataBase Files:

    DataFiles Password File

    ControlFiles Parameter File

    RedologFiles Archived RedoLogFiles

    DataFiles:

    Containing the Actual Data in the Database.

    The data is Stored in the Oracle Database in the Datafiles in the

    Oracle Propriatory Format.

    The User can Access the Data Through the Application(SQLPLUS or

    Any other front end).

    Min One Datafile is necessary to create the Database i.e. System

    Datafile(Ora cle 9i).

    Min Two Datafiles is necessary to create the Database i.e. System

    Datafile and Sysaux Datafile ( Oracle 10g).

    Extension for datafile is (.dbf).

    The Entire Data can be Stored in the System Datafile but for ease of

    Admin the DBA has to create separa te Datafiles(Non System

    Datafile) to Store the User Data.

    System Data has the information about the Data called Data

    Dictionary or Meta Data.It consists of privileges,objects,location

    ,etc.

    System Datafile is gets created when we create Database.

    Datafile classification based on type of Data stored Permanent and

    Temporary.

    The Data Stored in a Permanent Datafile is available across the

    Startup and Shutdown.

    The Data Stored in a Temporary Datafile is not available across the

    Startup and Shutdown.

  • The Tempora ry files are used whenever Sorting, Joining Operations

    performed by the user on Database objects.

    The Space Management with in the Datafile can be of two types

    Dictionary Managed and Locally Managed

    In a Dictionary Managed for Allocation and Deallocation o f a space

    for a Object the System Datafile is Update.This generates Redo and

    also decreases Performance.

    In a Locally Managed the Allocation and Deallocation of a space for

    a Object is Maintained with in the same Datafile Header in the Form

    of Bit Maps or Bit Map blocks.For example allocation 0 or 1.

    Important Views in Datafiles.

    SQL> select file#,ts#,status,bytes,name from v$datafile where

    file#=10;

    FILE# TS# STATUS BYTES

    - - - -

    NAME

    10 5 ONLINE 10485760

    /home/oracle/tarun4/datafiles/users01.dbf

    SQL> select file_name,file_id,tablespace_name,bytes,status,online_status

    from dba_data_files where tablespace_name=RUBRICS;

    FILE_NAME

    FILE_ID TABLESPACE_NAME BYTES STATUS ONLINE_

    - - -

    /home/oracle/tarun4/datafiles/ bigfile.dbf

    9 RUBRICS 104857600 AVAILABLE ONLINE

    ControlFiles:

    Containing information necessary to Maintain and Verify Database

    integrity.

    It is a Binary file it contains the Structure and Contents of the

    Database i.e. the Physical Location of the file along with the path.

    It also contains the information about the Time and Date the

    Database Creation,

    Database Name,Backup and Recovery informa tion,Online,Offline,Redo

    only etc.

    Min 1 Controlfile is needed for the Database to Startup.

    Max allowed is 8.

  • A controlfile has two control sections Reusable and NonReusable.

    The Reusable section is used by RMAN(Recovery Manager) for

    Backup and Recovery in formation.

    Important View in ControlFiles:

    SQL> select NAME,IS_RECOVERY_DEST_FILE,BLOCK_SIZE

    ,FILE_SIZE_BLKS from v$controlfile;

    /home/oracle/tarun4/control/c1.ctl

    NO 16384 440

    /home/oracle/tarun4/control/c2.ctl

    NO 16384 440

    RedologFiles:

    Containing a Record of changes made to the database(In Memory)

    to enable recovery of the data in case of failures.

    Min of two groups are necessary for the database functioning.

    Max allowed is 255.

    Each group will have 1 to 5 Members.

    Min needed is 1 Member.

    While Recording the changes in redolog groups all the Members in a

    group will have the same contents.

    Oracle Server Brights to all the Members of the groups

    simultaneously.

    Once the group is filled its switches to another group this switching

    is called log switch.

    For every log switch Oracle Server generates a number called log

    sequence no.

    After the completion of all the available group and control is

    transferred to the first group and starts overwriting.

    Important Views in Redologfiles:

    SQL> select * from v$log;

    GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS

    FIRST_CHANGE# FIRST_TIM

    - - - - - - -

    1 1 131 10485760 1 NO CURRENT 1400416 14 -DEC-08

    2 1 130 10485760 2 YES INACTIVE 1377952 14 -DEC-08

    3 1 128 20971520 1 YES INACTIVE 1353960 13 -DEC-08

    4 1 129 20971520 1 YES INACTIVE 1354009 13 -DEC-

    SQL> select GROUP#,STATUS, TYPE,MEMBER,

    IS_RECOVERY_DEST_FILE from v$logfile;

  • 2 STALE ONLINE /home/oracle/tarun4/datafiles/redo02.log

    NO

    1 ONLINE /home/oracle/tarun4/datafiles/redo01.log

    NO

    3 ONLINE /home/oracle/tarun4/datafiles/redo03.log

    NO

    4 STALE ONLINE /home/oracle/tarun4/datafiles/redo04.log

    NO

    2 STALE ONLINE /home/oracle/tarun4/datafiles/redo07.log

    NO

    Password File:

    Authenticates use rs privileged to Startup and Shutdown an Oracle

    instance.

    To make a Normal users in a database as a Super user Password

    file is used.

    It is an Optional file and resides on the Oracle Server machine in

    the default path $ORACLE_HOME/dbs.

    To create passwd fil e Oracle provides a utility $orapwd that should

    be envoked from the OS command prompt.

    Important View in Password File.

    SQL> select * from v$pwfile_users;

    USERNAME SYSDB SYSOP

    SYS TRUE TRUE

    A1 TRUE FALSE

    Creating Passwordfile:

    [oracle@rubrics ~]$ orapwd

    file=$ORACLE_HOME/dbs/orapwtarun4(sid_name)

    password= - entries=5

    Parameter File:

    Defines the Characteristics of an Oracle instance.

    In a database instance functionality is set through parameter file, it

    is used to set the parame ter and the value to the parameters this is

    the first file that is read by Oracle Server while starting the

    database.

    From Oracle 9i parameter file of two types pfile(text file) ans

    spfile(server parameter file) (binary file).

  • If both the parameter files a re present than spfile is given higher

    priority than pfile.

    Once the instance is Started the parameter file not needed until the

    next Start of the instance.

    The advantage of spfile is that the changes made to parameter

    when the database is up it can update for the current instance.

    The default path for parameter file is $ORACLE_HOME/dbs where

    Oracle Home is the home directory for Oracle Software installed

    directory.

    Important View in Parameter File:

    SQL> show parameter pfile;

    NAME TYPE

    VALUE

    spfile string

    /home/oracle/oracle/product/10

    .2.0/db_1/dbs/spfiletarun4.ora

    SQL> select NAME,TYPE,VALUE,HASH from v$parameter ;

    NAME TYPE VALUE HASH

    -

    -

    max_dump_file_size 2 /home/ora cle/tarun4/udump 2332088509

    [oracle@rubrics ~]$ vi

    /home/oracle/oracle/product/10.2.0/db_1/dbs/inittarun4.ora

    *.background_dump_dest=/home/oracle/tarun4/bdump

    *.compatible=10.2.0.1.0

    *.control _files=/home/oracle/tarun4/control/c1.ctl

    *.db_block_size=4096

    *.db_cache_size=62914560

    *.db_name=RUBRICS

    *.log_archive_dest=/home/oracle/tarun4/archive

    *.log_archive_format=arch_%t_%r_%s.arc

    *.remote_login_passwordfile=exclusive

    *.shared_pool_size=232m

    *.undo_management=auto

  • *.user_dump_dest=/home/oracle/tarun4/udump

    Archived RedoLogFiles:

    Are offline copies of the online RedologFiles that may be necessary

    to recover from media failures.

    It is an Optional file which will be cr eated only if the database is in

    Archivelog mode.

    By default it will be No Archivelog mode.

    If Archivelog feature is enabled then every log switch in the

    redologfile generates a Archivelog file and the generated Archivelog

    file will be placed in Archive de stination.

    Each switch in redolog will have one archive file.The switch may be

    either

    Automatic -After filling the group.

    Manual -Applied by DBA SQL>alter system switch logfile;

    What ever the contents present in the redologfile at the time of

    logswitch will be size of Archivelog file.

    Important Views in Archived RedoLogFiles:

    SQL> select NAME,THREAD#,SEQUENCE#,RESETLOGS_CHANGE#,

    BLOCKS,BLOCK_SIZE, STANDBY_DEST,ARCHIVED,APPLIED, STATUS

    ,IS_RECOVERY_DEST_FILE from v$archived_log ;

    /home/oracle/tarun4/archive/arch_1_672425039_01.arc

    1 15 642254 2788 512 NO YES NO A NO

    /home/oracle/tarun4/archive/arch_1_672425039_02.arc

    1 16 642254 24071 512 NO YES NO A NO

    2 rows selected.

    SQL> archive log list;

    Database log mode Archive Mode

    Automati c archival Enabled

    Archive destination /home/oracle/tarun4/archive

    Oldest online log sequence 1

    Next log sequence to archive 2

    Current log sequence 2

    LOGICAL STRUCTURE

    TABLESPACE

    SEGMENT

    EXTENT

    BLOCK

    LOGICAL STRUCTURE:

  • Dictates how the Physical space of a database is used.

    A Logical Structure hierarchy exists as follows:

    A tablespace contains one or more segments.

    An extent is made up of Logical blocks.

    A block is the smallest unit for read and write operations.

    The Orac le Server enables fine -grained control of disk space use

    through tablespace and Logical Storage Structures, including

    segments,extents, and data blocks.

    TABLESPACE:

    An Oracle database can be logically grouped into smaller logical

    areas of space known as ta blespaces.

    A tablespace can belong to only one database at a time.

    The database is split into one or more tablespaces.

    Whenever the database is created one tablespace created by Oracle

    itself that is called as system tablespace.

    The System tablespace conta ins the object related information

    which stores the meta data, objects that are related to the

    database.

    The user data also stores in the system tablespace by default.

    It is highly recommended to create a separate non -system

    tablespace to store userdata.

    To create a tablespace at least one data file is necessary.

    Each tablespace in an Oracle database consists of one or more

    operating system files called datafiles.

    A datafile can belong to only one tablespace.

    Tablespace may logically contain a single type of segment or different

    type of segments.

    Space management in tablespaces can be classified into following

    Dictionary management and Locally management tablespaces.

    Dictionary management tablespaces:Whenever object is created

    or dropped i.e.,whenever space is allocated or de -allocated, Oracle

    uses data dictionary information and updated appropriate table in

    dictionary managed tablespaces.This uses system tablespace to

    store data.

    Locally management tablespaces:Space allocation and de -

    allocation is maintaine d in the form of bit -map blocks present in the

    tablespace itself in Locally managed tablespaces.This type of space

    allocation or de -allocation is faster than that of dictionary managed.

  • Tablespace can be classified into following Permanent,Temporary

    and Un do.

    Permanent Tablespace:It is used to store Permanent data.

    Permanent tablespace can be created as either dictionary managed

    or locally managed.

    Temporary Tablespace:It is used to store only temporary object

    and data, usually used for sorting operations. It can be created as

    either dictionary managed or locally managed.

    Undo Tablespace:It is used to store undo or rollback

    data.Whenever a change is made to database, thi s undo data is

    used to rollback the transaction. Only one undo tablespace can be

    active in database.

    Default Temporary Tablespace:When a user is created a default

    temporary tablespace is assigned as temporary tablespace.This is

    used to store sorted data .

    SEGMENT:

    A Segment is the space allocated for a specific Logical storage

    structure within a Tablespace.

    A tablespace may consists of one or more Segments.

    A Segment cannot span tablespaces; however, a Segment can span

    multiple data

    files that belong to the same tablespace.

    Each Segment is made up of one or more extents.

    EXTENT:

    Space is allocated to a Segment by extents.

    An extent is a set of Contiguous Oracle Blocks.

    An extent cannot span data files and therefore,it must exists in o ne

    datafile.

    One or more extents make up a segment

    -When Segment is Created, it consists of at least one extent.

    -As the Segment grows, extents are added to the Segment.

    -The DBA can manually add extents to a Segment

    BLOCK:

    The Oracle Server manages the storage space in the data files in

    units called Oracle blocks or data blocks.

    Oracle data block are the smallest units of storage that the Oracle

    Server can allocate,read or write.

  • The Standard data block size for an Oracle da tabase is specified by

    the DB_BLOCK_SIZE initialization parameter when the database is

    created.

    The Maximum data block size is dependent on the operating

    system.

    Oracle blocks are made up of multiple block sizes.

    Oracle supports 5 block sizes 2k,4k,8k,16k, 32k.

    The data block size should be a multiple of the operating system

    block size to avoid unnecessary I/O.

    Tablespace associated with one or more datafiles

    Logical Structure Physical Files

    Tablespace(Space or Area Created Data files

    for the Storage of data )

    Segments( Table,Index etc Storage Unit)

    Extents

    Blocks OS Blocks