the oracle databae archietecture

Upload: sultan-mirza

Post on 07-Aug-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/20/2019 The Oracle Databae Archietecture

    1/34

    Welcome to the world of Oracle ______________________________________________________________________________________________________ 

    The Oracle Database Architecture

    Oracle Database Administration

    Prepared / Owner: Syed Imtiyaz

    Date: 16/!/"!

     ___________________________________________________________________________________ 

  • 8/20/2019 The Oracle Databae Archietecture

    2/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    #ontents

    1$ O%A#&' S'%('%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$)

    "$ #O**'#TI*+ TO A* O%A#&' I*STA*#' , #%'ATI*+ A S'SSIO* -

    )$ P.SI#A& ST%0#T0%' , DATAAS' 2I&'S$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$6

    3$ 4'4O% ST%0#T0%'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$5

    -$ A0TO4ATI# S.A%'D 4'4O% 4A*A+'4'*T$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

    6$ S.A%'D POO&$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$1

    5$ 022'% #A#.'S$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$1"

    !$ %'DO &O+ 022'%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$13

    $ &A%+' POO&$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$13

    1$ 7A(A POO&$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$1-

    11$ ST%'A4S POO&$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$1-

    1"$ P%O+%A4 +&OA& A%'A$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$1-

    1)$ P%O#'SS'S$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$15

    13$ A#8+%O0*D P%O#'SS'S$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$1!

    1-$ &O+I#A& ST%0#T0%'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"-

     ___________________________________________________________________________________ 

    Page 2 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    3/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    Objectives

    These notes introduce the Oracle server architecture. The architectureincludes physical components, memory components, processes, and logical

    structures.

    The fgure shown below details the Oracle architecture.

    1$ Oracle ser9er 

     An Oracle server includes an Oracle Instance and an Oracle database.

    •  You'll notice that the database includes several dierent types o flesdatafles, control fles, redo log fles and archive redo log fles. The

    Oracle server also access parameter fles and password fles.• This set o fles has several purposes.

    o One is to enable system users to process !"# statements.o  Another is to improve system perormance.o !till another is to ensure the database can be recovered i there

    is a sotware$hardware ailure.

    • The database server must manage large amounts o data in a multi%user environment.

    • The server must manage concurrent access to the same data.

    • The server must deliver high perormance. This generally means astresponse times.

    Oracle instance:  An Oracle &nstance consists o two dierent sets ocomponents

    • The frst component set is the set o background processes ()O*,!)O*, +-O, /01, #20+, -3(T, 111 and others4.

    o These will be covered later in detail, but basically eachbac5ground process is a computer program.

    o These processes perorm input$output and monitor other Oracleprocesses to provide good perormance and database reliability.

    • The second component set includes the memory structures thatcomprise the Oracle instance.

    o 0hen an instance starts up, a memory structure called the

    !ystem 2lobal Area SGA 4 is allocated.o  At this point the bac5ground processes also start.

    • The Oracle &nstance provides access to an Oracle database. AnOracle &nstance opens one and only one database.

     ___________________________________________________________________________________ 

    Page 3 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    4/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    Primary Architecture Components

    Oracle database An Oracle database consists o fles.• !ometimes these are reerred to as operating system fles, but they

    are actually database les that store the database inormation that afrm or organi6ation needs in order to operate.

    • The redo log les are used to recover the database in the event oapplication program ailures, instance ailures and other minorailures.

    • The archived redo log les are used to recover the database i adis5 ails.

     ___________________________________________________________________________________ 

    Page 4 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    5/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    • Other fles not shown in the fgure includeo The re7uired parameter le that is used to speciy parameters

    or confguring an Oracle instance when it starts up.o The optional password le authenticates special users o the

    database 8 these are termed privileged users and includedatabase administrators.

    o  Alert and !race "og #iles 8 these fles store inormation abouterrors and actions ta5en that aect the confguration o thedatabase.

    $ser and server processes:  The processes shown in the fgure are calleduser  and server  processes. These processes are used to manage thee9ecution o !"# statements.

    •  A !hared !erver (rocess can share memory and variable processingor multiple user processes.

    •  A edicates !erver (rocess manages memory and variables or asingle user process.

    "$ #onnectin to an Oracle Instance , #reatin a Session

    !ystem users can connect to an Oracle database through !"#(lus orthrough an application program li5e the &nternet eveloper !uite theprogram becomes the system user4. This connection enables users toe9ecute !"# statements.

    The act o connecting creates a communication pathway between a userprocess and an Oracle !erver. As is shown in the fgure above, the :ser(rocess communicates with the Oracle !erver through a !erver (rocess.The :ser (rocess e9ecutes on the client computer. The !erver (rocess

     ___________________________________________________________________________________ 

    Page of 34

  • 8/20/2019 The Oracle Databae Archietecture

    6/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    e9ecutes on the server computer, and actually e9ecutes !"# statementssubmitted by the system user.

    The fgure shows a one%to%one correspondence between the :ser and !erver(rocesses. This is called a %edicated Server  connection. An alternativeconfguration is to use a Shared Server  where more than one :ser (rocess

    shares a !erver (rocess.

    !essions 0hen a user connects to an Oracle server, this is termed asession. The session starts when the Oracle server validates the user orconnection. The session ends when the user logs out disconnects4 or i theconnection terminates abnormally networ5 ailure or client computerailure4.

     A user can typically have more than one concurrent session, e.g., the usermay connect using !"#(lus and also connect using &nternet eveloper !uitetools at the same time. The limit o concurrent session connections iscontrolled by the %&A .

    & a system users attempts to connect and the Oracle !erver is not running,the system user receives the Oracle *ot Available error message.

    )$ Physical Structure , Database 2iles

     As was noted above, an Oracle database consists o physical fles. Thedatabase itsel has

    • %atales 8 these contain the organi6ation's actual data.

    • 'edo log les 8 these contain a record o changes made to thedatabase, and enable recovery when ailures occur.

    • Control les 8 these are used to synchroni6e all database activitiesand are covered in more detail in a later module.

     ___________________________________________________________________________________ 

    Page ! of 34

  • 8/20/2019 The Oracle Databae Archietecture

    7/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    Other 5ey fles as noted above include

    • Parameter le 8 there are two types o parameter fles.o The init(ora fle also called the P#I")4 is a static parameter

    fle. &t contains parameters that speciy how the databaseinstance is to start up. ;or e9ample, some parameters willspeciy how to allocate memory to the various parts o the

    system global area.o The sple(ora is a dynamic parameter fle. &t also storesparameters to speciy how to startup a database< however, itsparameters can be modifed while the database is running.

    • Password le 8 specifes which =special= users are authenticated tostartup$shut down an Oracle &nstance.

    •  Archived redo log les 8 these are copies o the redo log fles andare necessary or recovery in an online, transaction%processingenvironment in the event o a dis5 ailure.

    3$ 4emory Structure

    The memory structures include two areas o memory• !ystem 2lobal Area SGA 4 8 this is allocated when an Oracle &nstance

    starts up.

    • (rogram 2lobal Area (2A4 8 this is allocated when a !erver (rocessstarts up.

     ___________________________________________________________________________________ 

    Page " of 34

  • 8/20/2019 The Oracle Databae Archietecture

    8/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    System Global Area

    The SGA  is an area in memory that stores inormation shared by alldatabase processes and by all users o the database sometimes it is calledthe Shared Global Area4.

    o This inormation includes both organi6ational data and controlinormation used by the Oracle !erver.

    o The SGA  is allocated in memory and virtual memory.o The si6e o the SGA  is established by the parameter SGA*+A,*SI-) 

    in the parameter fle.

    The SGA  is allocated when an Oracle instance database4 is started up basedon values specifed in the initiali6ation parameter fle either (; or!(;4.

    The SGA  has the ollowing mandatory memory structures

    !hared (ool 8 includes two componentso #ibrary -acheo ata ictionary -ache

    • atabase /uer -ache

    • +edo #og /uer

    • Other structures or e9ample, loc5 and latch management, statisticaldata4

     Additional optional memory structures in the SGA  include

    • #arge (ool

    •  >ava (ool

    • !treams (ool

    The ollowing !"# command will show you the SGA  memory allocations.This is a recent clip o the SGA  or the Oracle database at !&:.S.O/ SGA 

    Oracle ?i and earlier versions o the Oracle !erver used a Static SGA . Thismeant that i modifcations to memory management were re7uired, thedatabase had to be shutdown, modifcations were made to the init(ora parameter fle, and then the database had to be restarted.

    Oracle @i and 1g use a %ynamic SGA . )emory confgurations or thesystem global area can be made without shutting down the database

     ___________________________________________________________________________________ 

    Page 8 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    9/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    instance. The advantage is obvious. This allows the %&A  to resi6e theatabase /uer -ache and !hared (ool dynamically.

    !everal initiali6ation parameters are set that aect the amount o randomaccess memory dedicated to the SGA  o an Oracle &nstance. These are

    • SGA*+A,*SI-) This sets a limit on the amount o virtual memoryallocated to the SGA  8 a typical setting might be 2/< however, i the

     value or SGA B)ACB!&D in the initiali6ation parameter fle or serverparameter fle is less than the sum the memory allocated or allcomponents, either e9plicitly in the parameter fle or by deault, at thetime the instance is initiali6ed, then the database ignores the settingor SGA B)ACB!&D.

    • %&*CAC.)*SI-) This is the si6e o the atabase /uer -ache instandard database bloc5s. /loc5 si6es vary among operating systems.0e use ?3/ bloc5 si6es. The total bloc5s in the cache deaults to E?)/ on #&*:C$:*&C and FG )/ on 0indows operating systems.

    "OG*&$##)'  This is the number o bytes allocated or the +edo#og /uer.• S.A')%*POO"*SI-) This is the number o bytes o memory

    allocated to shared !"# and (#$!"#. The deault is H )/. & theoperating system is based on a HE bit confguration, then the deaultsi6e is HE )/.

    • "A'G)*POO"*SI-) !ince this is an optional memory obIect, thesi6e o the #arge (ool deaults to 6ero. & the init.ora parameterPA'A"")"*A$!O+A!IC*!$0I0G  is set to !'$), then the deaultsi6e is automatically calculated.

    •  1A2A*POO"*SI-) This is another optional memory obIect. Thedeault is GE )/ o memory.

    The si6e o the SGA  cannot e9ceed the parameter SGA*+A,*SI-) minusthe combination o the si6e o the additional parameters, %&*CAC.)*SI-),"OG*&$##)' , S.A')%*POO"*SI-), "A'G)*POO"*SI-), and 1A2A*POO"*SI-).

    )emory is allocated to the SGA  as contiguous virtual memory in unitstermed granules. 2ranule si6e depends on the estimated total si6e o theSGA , which as was noted above, depends on the SGA B)ACB!&D parameter.2ranules are si6ed as ollows

    • & the SGA  is less than G?)/ in total, each granule is E)/.

    • & the SGA  is greater than G?)/ in total, each granule is H)/.

    2ranules are assigned to the atabase /uer -ache and !hared (ool, andthese two memory components can dynamically grow and shrin5. :singcontiguous memory improves system perormance. The actual number ogranules assigned to one o these memory components can be determinedby 7uerying the database view named 23&$##)'*POO".

     ___________________________________________________________________________________ 

    Page # of 34

  • 8/20/2019 The Oracle Databae Archietecture

    10/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    2ranules are allocated when the Oracle server starts a database instance inorder to provide memory addressing space to meet the SGA B)ACB!&Dparameter. The minimum is J granules one each or the f9ed SGA ,atabase /uer -ache, and !hared (ool. &n practice, you'll fnd the SGA  isallocated much more memory than this. The !#-T statement shownbelow shows a currentBsi6e o E? granules.

    select name4 block*si5e4 current*si5e4 prev*si5e4 prev*bu6ers7rom v3bu6er*pool8

    0A+) &"OC9*SI-) C$'')0!*SI-) P')2*SI-) P')2*&$##)'S %)#A$"! ;

  • 8/20/2019 The Oracle Databae Archietecture

    11/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    • *onstandard bloc5 si6e buer caches i specifed4• The !treams (ool

    & SGA*!A'G)! is set to a value greater than SGA*+A,*SI-) at startup,then the latter is bumped up to accommodate SGA BTA+2T. Ater startup,SGA BTA+2T can be decreased or increased dynamically. Kowever, it can

    not e9ceed the value o SGA B)ACB!&D that was computed at startup.0hen you set a value or SGA*!A'G)!, Oracle atabase 1g automaticallysi6es the most commonly confgured components, including

    • The shared pool or !"# and (#$!"# e9ecution4• The >ava pool or >ava e9ecution state4• The large pool or large allocations such as +)A* bac5up buers4• The buer cache

    There are a ew SGA  components whose si6es are not automaticallyadIusted. The %&A  must speciy the si6es o these components e9plicitly, ithey needed by the application. !uch components are

    • 3eep$+ecycle buer caches controlled by /B3(B-A-KB!&Dand /B+-Y-#B-A-KB!&D4

    •  Additional buer caches or non%standard bloc5 si6es controlled by/Bn3B-A-KB!&D, n N G, E, ?, H, JGP4

    • !treams (ool controlled by the new parameter!T+A)!B(OO#B!&D4

    6$ Shared Pool

    The Shared Pool is a memory structure that is shared by all system users.&t consists o both f9ed and variable structures. The variable componentgrows and shrin5s depending on the demands placed on memory si6e bysystem users and application programs.

    )emory is allocated to the !hared (ool by the parameterS.A')%*POO"*SI-) in the parameter fle. You can alter the si6e o theshared pool dynamically with the A"!)' SDS!)+ S)! command. Ane9ample command is shown in the fgure below. You must 5eep in mind thatthe total memory allocated to the SGA  is set by the SGA*+A,*SI-) parameter and since the !hared (ool is part o the SGA , you cannot e9ceedthe ma9imum si6e o the SGA .

    The !hared (ool stores the most recently e9ecuted !"# statements and useddata defnitions. This is because some system users and applicationprograms will tend to e9ecute the same !"# statements oten. !aving thisinormation in memory can improve system perormance.

     ___________________________________________________________________________________ 

    Page $$ of 34

  • 8/20/2019 The Oracle Databae Archietecture

    12/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    The !hared (ool includes the "ibrary Cache and %ata %ictionary Cache.

    "ibrary Cache

    )emory is allocated to the "ibrary Cache whenever an !"# statement is

    parsed or a program unit is called. This enables storage o the most recentlyused !"# and (#$!"# statements.

    & the #ibrary -ache is too small, the #ibrary -ache must purge statementdefnitions in order to have space to load new !"# and (#$!"# statements.

     Actual management o this memory structure is through a "east'ecently$sed E"'$F algorithm. This means that the !"# and (#$!"# statementsthat are oldest and least recently used are purged when more storage spaceis needed.

    The #ibrary -ache is composed o two memory subcomponents• Shared S" This stores$shares the e9ecution plan and parse tree

    or !"# statements. & a system user e9ecutes an identical statement,then the statement does not have to be parsed again in order toe9ecute the statement.

    • Shared P"HS" Procedures and Packages This stores$shares themost recently used (#$!"# statements such as unctions, pac5ages,and triggers.

    %ata %ictionary Cache

     ___________________________________________________________________________________ 

    Page $2 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    13/34

  • 8/20/2019 The Oracle Databae Archietecture

    14/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    data and are available or use. Pinned bu6ers are currently beingaccessed.

    0hen an Oracle process accesses a buer, the process moves the buer tothe most recently used E+'$F end o the #+: list 8 this causes dirtybuers to age toward the #+: end o the #+: list.

    0hen an Oracle user process needs a data row, it searches or the data inthe database buer cache because memory can be searched more 7uic5lythan hard dis5 can be accessed. & the data row is already in the cache acache hit4, the process reads the data rom memory< otherwise a cachemiss occurs and data must be read rom hard dis5 into the database buercache.

    /eore reading a data bloc5 into the cache, the process must frst fnd a reebuer. The process searches the #+: list, starting at the #+: end o the list.The search continues until a ree buer is ound or until the search reachesthe threshold limit o buers.

    ach time the user process fnds a dirty buer as it searches the #+:, thatbuer is moved to the write list and the search or a ree buer continues.

    0hen the process fnds a ree buer, it reads the data bloc5 rom dis5 intothe buer and moves the buer to the )+: end o the #+: list.

    & an Oracle user process searches the threshold limit o buers withoutfnding a ree buer, the process stops searching the #+: list and signalsthe /01 bac5ground process to write some o the dirty buers to dis5.This rees up some buers.

    The bloc5 si6e or a database is set when a database is created and isdetermined by the init.ora parameter fle parameter named%&*&"OC9*SI-). Typical bloc5 si6es are G3, E3, ?3, H3, and JG3. Thesi6e o bloc5s in the atabase /uer -ache matches the bloc5 si6e or thedatabase.

    /ecause tablespaces that store oracle tables can use dierent non%standard4 bloc5 si6es, there can be more than one atabase /uer -acheallocated to match bloc5 si6es in the cache with the bloc5 si6es in the non%standard tablespaces.

    The si6e o the atabase /uer -aches can be controlled by the parameters%&*CAC.)*SI-) and %&*n9*CAC.)*SI-) to dynamically change thememory allocated to the caches without restarting the Oracle instance.

     You can dynamically change the si6e o the atabase /uer -ache with the A#T+ !Y!T) command li5e the one shown here

     A"!)' SDS!)+ S)! %&*CAC.)*SI-) =?+8

     ___________________________________________________________________________________ 

    Page $4 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    15/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

     You can have the Oracle !erver gather statistics about the atabase /uer-ache to help you si6e it to achieve an optimal wor5load or the memoryallocation. This inormation is displayed rom the 23%&*CAC.)*A%2IC) 

     view. &n order or statistics to be gathered, you can dynamically alter thesystem by using the A"!)' SDS!)+ S)! %&*CAC.)*A%2IC) EO##4 O04')A%DF command. Kowever, gathering statistics on system perormance

    always incurs some overhead that will slow down system perormance.

    9))P &u6er Pool

    This pool retains bloc5s in memory data rom tables4 that are li5ely to bereused throughout daily processing. An e9ample might be a table containinguser names and passwords or a validation table o some type.

    The %&*9))P*CAC.)*SI-) parameter si6es the 3( /uer (ool.

    ')CDC") &u6er Pool

    This pool is used to store table data that is unli5ely to be reused throughoutdaily processing 8 thus the data is 7uic5ly recycled.

    The %&*')CDC")*CAC.)*SI-) parameter si6es the +-Y-# /uer(ool.

     ___________________________________________________________________________________ 

    Page $ of 34

  • 8/20/2019 The Oracle Databae Archietecture

    16/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    !$ %edo &o u;;er 

    The 'edo "og &u6er  memory obIect stores images o all changes made to

    database bloc5s. As you 5now, database bloc5s typically store several tablerows o organi6ational data. This means that i a single column value romone row in a bloc5 is changed, the image is stored. -hanges include&*!+T, :(AT, #T, -+AT, A#T+, or +O(.

    Thin5 o the +edo #og /uer as a circular buer that is reused over andover. As the buer flls up, copies o the images are stored to the 'edo "og#iles that are covered in more detail in a later module.

    $ &are Pool

    The "arge Pool is an optional memory structure that primarily relieves thememory burden placed on the !hared (ool. The #arge (ool is used or theollowing tas5s i it is allocated

    •  Allocating space or session memory re7uirements rom the :ser2lobal Area part o the !erver (rocess4 where a !hared !erver is inuse.

     ___________________________________________________________________________________ 

    Page $! of 34

  • 8/20/2019 The Oracle Databae Archietecture

    17/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    • Transactions that interact with more than one database.

    • /ac5up and restore operations by the +ecovery )anager +)A*4process.

    o +)A* uses this only i the &AC9$P*%IS9*IO n and&AC9$P*!AP)*IO*S"A2) !'$) parameters are set.

    o

    & the #arge (ool is too small, memory allocation or bac5up willail and memory will be allocated rom the !hared (ool.

    • (arallel e9ecution message buers or parallel server operations. ThePA'A"")"*A$!O+A!IC*!$0I0G !'$) parameter must be set.

    The #arge (ool si6e is set with the "A'G)*POO"*SI-) parameter 8 this isnot a dynamic parameter. &t does not use an #+: list to manage memory.

    1$ 7a9a Pool

    The >ava (ool is an optional memory obIect, but is re7uired i the databasehas Oracle >ava installed and in use or Oracle >L) >ava Lirtual )achine4.The si6e is set with the 1A2A*POO"*SI-) parameter that deaults to GE)/.

    The >ava (ool is used or memory allocation to parse >ava commands.

    !toring >ava code and data in the >ava (ool is analogous to !"# and (#$!"#code cached in the !hared (ool.

    11$ Streams Pool

    This cache is new to Oracle 1g. &t is si6ed with the parameterS!')A+S*POO"*SI-).

    This pool stores data and control structures to support the Oracle !treamseature o Oracle nterprise dition. Oracle !teams manages sharing odata and events in a distributed environment.

    & S!)A+S*POO"*SI-) is not set or is 6ero, memory or Oracle !treamsoperations is allocated rom up to 1Q o the !hared (ool memory.

    1"$ Proram +lobal Area

    The Program Global Area is also termed the Process Global Area EPGA 4and is a part o memory allocated that is outside o the Oracle Instance.The (2A stores data and control inormation or a single Server Process ora single &ackground Process. &t is allocated when a process is createdand the memory is scavenged by the operating system when the process

     ___________________________________________________________________________________ 

    Page $" of 34

  • 8/20/2019 The Oracle Databae Archietecture

    18/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    terminates. This is 0O! a shared part o memory 8 one (2A to each processonly.

    The content o the (2A varies, but generally includes the ollowing

    • Private S" Area ata or binding variables and runtime memory

    allocations. A user session issuing !"# statements has a (rivate !"# Area that may be associated with a !hared !"# Area i the same !"#statement is being e9ecuted by more than one system user. This otenhappens in O#T( environments where many users are e9ecuting andusing the same application program.

    o %edicated Server environment 8 the (rivate !"# Area is locatedin the (rogram 2lobal Area.

    o Shared Server environment 8 the (rivate !"# Area is located inthe !ystem 2lobal Area.

    • Session +emory  )emory that holds session variables and other

    session inormation.

    • S" /ork Area )emory allocated or sort, hash%Ioin, bitmap merge,and bitmap create types o operations.

    o Oracle @i enables automatic si6ing o the !"# 0or5 Areas bysetting the /O'9A')A*SI-)*PO"ICD A$!O parameter thisis the deaultR4 and PGA*AGG')GA!)*!A'G)! n where n issome amount o memory established by the %&A 4. Kowever, the%&A  can let Oracle 1g determine the appropriate amount omemory.

    o Oracle ?i and earlier re7uired the %&A  to set the ollowingparameters to control !"# 0or5 Area memory allocations

    !O+TBA+AB!&D. KA!KBA+AB!&D.

    /&T)A(B)+2BA+AB!&D. -+ATB/&T)A(BA+AB!&D.

     ___________________________________________________________________________________ 

    Page $8 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    19/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    So7tware Code Area

    !otware code areas store Oracle e9ecutable fles running as part o theOracle instance.

    These code areas are static in nature and are located in privileged memorythat is separate rom other user programs.

    The code can be installed sharable when multiple Oracle instances e9ecuteon the same server with the same sotware release level.

    1)$ Processes

     You need to understand three dierent types o (rocesses• $ser Process !tarts when a database user re7uests to connect to an

    Oracle !erver.

    Server Process stablishes the -onnection to an Oracle &nstancewhen a :ser (rocess re7uests connection 8 ma5es the connection orthe :ser (rocess.

    • &ackground Processes These start when an Oracle &nstance isstarted up.

    $ser Process

     ___________________________________________________________________________________ 

    Page $# of 34

  • 8/20/2019 The Oracle Databae Archietecture

    20/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    &n order to use Oracle, you must obviously connect to the database. Thismust occur whether you're using !"#(lus, an Oracle tool such as esigneror ;orms, or an application program.

    This generates a :ser (rocess a memory obIect4 that generatesprogrammatic calls through your user interace !"#(lus, &ntegrated

    eveloper !uite, or application program4 that creates a session and causesthe generation o a !erver (rocess that is either dedicated or shared.

     ___________________________________________________________________________________ 

    Page 20 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    21/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    Server Process

     As you have seen, the !erver (rocess is the go%between or a :ser (rocessand the Oracle &nstance. &n a edicated !erver environment, there is asingle !erver (rocess to serve each :ser (rocess. &n a !hared !erverenvironment, a !erver (rocess can serve several :ser (rocesses, although

    with some perormance reduction. Allocation o server process in adedicated environment versus a shared environment is covered in urtherdetail in the Oracle10g Database Performance Tuning course oered byOracle ducation.

    13$ ac

  • 8/20/2019 The Oracle Databae Archietecture

    22/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

     Iobs The >nnn processes e9ecute Iob re7uests created by the /)!B>O/!pac5age.

    • %nnn ispatcher number nnn, or e9ample, 111 would be the frstdispatcher process 8 ispatchers are optional bac5ground processes,present only when the shared server confguration is used. !hared serveris discussed in your readings on the topic -onfguring Oracle or the!hared !erver.

    • ')CO +ecoverer 8 The +ecoverer process is used to resolve distributedtransactions that are pending due to a networ5 or system ailure in adistributed database. At timed intervals, the local +-O attempts toconnect to remote databases and automatically complete the commit orrollbac5 o the local portion o any pending distributed transactions. ;orinormation about this process and how to start it, see your readings onthe topic )anaging istributed Transactions. 

    O these, the ones you'll use most oten are A+-n archiver4 when youautomatically archive redo log fle inormation covered in a later module4,

    and +-O or recovery where the database is distributed on two or moreseparate physical Oracle servers, perhaps a :*&C machine and an *Tmachine.

    %&/n Ealso called %&/' in earlier Oracle 2ersionsF

     ___________________________________________________________________________________ 

    Page 22 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    23/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    The %atabase /riter  writes modifed bloc5s rom the database buercache to the datafles. Although one database writer process /014 issuicient or most systems, you can confgure up to G1 /0n processes/01 through /0@ and /0a through /0I4 in order to improve writeperormance or a system that modifes data heavily.

    The initiali6ation parameter %&*/'I!)'*P'OC)SS)S specifes thenumber o /0n processes.

    The purpose o %&/n is to improve system perormance by caching writeso database bloc5s rom the %atabase &u6er Cache bac5 to datafles./loc5s that have been modifed and that need to be written bac5 to dis5 aretermed dirty blocks. The /0n also ensures that there are enough reebuers in the atabase /uer -ache to service !erver (rocesses that maybe reading data rom datafles into the atabase /uer -ache. (erormanceimproves because by delaying writing changed database bloc5s bac5 to dis5,a !erver (rocess may fnd the data that is needed to meet a :ser (rocessre7uest already residing in memoryR

    /0n writes to datafles when one o these events occurs that is illustratedin the fgure below.

    "G/' 

    The "og /riter E"G/'F writes contents rom the +edo #og /uer to the+edo #og ;ile that is in use. These are se7uential writes since the +edo #og;iles record database modifcations based on the actual time that the

     ___________________________________________________________________________________ 

    Page 23 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    24/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    modifcation ta5es place. #20+ actually writes beore the /0n writes andonly confrms that a -O))&T operation has succeeded when the +edo #og/uer contents are successully written to dis5. #20+ can also call the/0n to write contents o the atabase /uer -ache to dis5. The #20+writes according to the events illustrated in the fgure shown below.

     ___________________________________________________________________________________ 

    Page 24 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    25/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    P+O0

    The Process +onitor EP+O0F is a cleanup type o process that cleans upater ailed processes such as the dropping o a user connection due to anetwor5 ailure or the abend o a user application program. &t does the

    tas5s shown in the fgure below.

     ___________________________________________________________________________________ 

    Page 2 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    26/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    S+O0

    The System +onitor ES+O0F is responsible or instance recovery byapplying entries in the online redo log fles to the datafles. &t also perormsother activities as outlined in the fgure shown below.

     ___________________________________________________________________________________ 

    Page 2! of 34

  • 8/20/2019 The Oracle Databae Archietecture

    27/34

  • 8/20/2019 The Oracle Databae Archietecture

    28/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    prior to the chec5point, thus those record will not re7uire recovery. Thisdoes the ollowing

    • nsures modifed data bloc5s in memory are regularly written to dis58 -3(T can call the /0n process in order to ensure this and does sowhen writing a chec5point record.

    • +educes &nstance +ecovery time by minimi6ing the amount o wor5needed or recovery since only +edo #og ;ile entries processed sincethe last chec5point re7uire recovery.

    • -auses all committed data to be written to datafles during databaseshutdown.

    & a +edo #og ;ile flls up and a switch is made to a new +edo #og ;ile thisis covered in more detail in a later module4, the -3(T process also writeschec5point inormation into the headers o the datafles.

    -hec5point inormation written to control fles includes the system changenumber the !-* is a number stored in the control fle and in the headers o 

    the database fles that are used to ensure that all fles in the system aresynchroni6ed4, location o which +edo #og ;ile is to be used or recovery,and other inormation.

    -3(T does not write data bloc5s or redo bloc5s to dis5 8 it calls /0n and#20+ as necessary.

     A'Cn

    0e cover the Archiver EA'CnF optional bac5ground process in more detailbecause it is almost always used or production systems storing mission

    critical inormation. The A+-n process must be used to recover rom loss o a physical dis5 drive or systems that are busy with lots o transactionsbeing completed.

     ___________________________________________________________________________________ 

    Page 28 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    29/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    0hen a +edo #og ;ile flls up, Oracle switches to the ne9t +edo #og ;ile.The %&A  creates several o these and the details o creating them arecovered in a later module. & all +edo #og ;iles fll up, then Oracle switchesbac5 to the frst one and use them in a round%robin ashion by overwritingones that have already been used 8 it should be obvious that the inormationstored on the fles, once overwritten, is lost orever.

    & A+-n is in what is termed A'C.I2)"OG mode, then as the +edo #og;iles fll up, they are individually written to Archived +edo #og ;iles and#20+ does not overwrite a +edo #og ;ile until archiving has completed.Thus, committed data is not lost orever and can be recovered in the event o 

    a dis5 ailure. Only the contents o the SGA  will be lost i an &nstance ails.

    &n 0OA'C.I2)"OG mode, the +edo #og ;iles are overwritten and not archived. +ecovery can only be made to the last ull bac5up o the databasefles. All committed transactions ater the last ull bac5up are lost, and youcan see that this could cost the frm a lot o SSS.

    0hen running in A+-K&L#O2 mode, the %&A  is responsible to ensure thatthe Archived +edo #og ;iles do not consume all available dis5 spaceR:sually ater two complete bac5ups are made, any Archived +edo #og ;ilesor prior bac5ups are deleted.

     ___________________________________________________________________________________ 

    Page 2# of 34

  • 8/20/2019 The Oracle Databae Archietecture

    30/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    1-$ &oical Structure

    &t is helpul to understand how an Oracle database is organi6ed in terms o a

    logical structure that is used to organi6e physical obIects.

    !ablespace An Oracle 1g database must always consist o at least twotablespaces SDS!)+ and SDSA$,4, although a typical Oracle databasewill multiple tablespaces tablespaces.

    •  A tablespace is a logical storage acility a logical container4 orstoring obIects such as tables, inde9es, se7uences, clusters, and otherdatabase obIects.

    • ach tablespace has at least one physical datafle that actually storesthe tablespace at the operating system level. A large tablespace mayhave more than one datafle allocated or storing obIects assigned tothat tablespace.

    •  A tablespace belongs to only one database.• Tablespaces can be brought online and ta5en oUine or purposes o

    bac5up and management, e9cept or the SDS!)+ tablespace thatmust always be online.

    • Tablespaces can be in either read%only or read%write status.

    %atale Tablespaces are stored in datafles which are physical dis5obIects.

     ___________________________________________________________________________________ 

    Page 30 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    31/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    •  A datafle can only store obIects or a single tablespace, but atablespace may have more than one datafle 8 this happens when adis5 drive device flls up and a tablespace needs to be e9panded, thenit is e9panded to a new dis5 drive.

    • The %&A  can change the si6e o a datafle to ma5e it smaller or later.The fle can also grow in si6e dynamically as the tablespace grows.

    Segment 0hen logical storage obIects are created within a tablespace, ore9ample, an employee table, a segment is allocated to the obIect.

    • Obviously a tablespace typically has many segments.

    •  A segment cannot span tablespaces but can span datafles that belongto a single tablespace.

    )Ktent ach obIect has one segment which is a physical collection oeKtents.

    • )Ktents are simply collections o contiguous disk storage blocks. A logical storage obIect such as a table or inde9 always consists o at

    least one e9tent 8 ideally the initial e9tent allocated to an obIect willbe large enough to store all data that is initially loaded.

    •  As a table or inde9 grows, additional e9tents are added to thesegment.

    •  A %&A  can add e9tents to segments in order to tune perormance othe system.

    •  An e9tent cannot span a datafle.

    &lock  The Oracle !erver manages data at the smallest unit in what istermed a block  or data block . ata are actually stored in bloc5s.

     ___________________________________________________________________________________ 

    Page 3$ of 34

  • 8/20/2019 The Oracle Databae Archietecture

    32/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

     A physical block  is the smallest addressable location on a dis5 drive orread$write operations.

     An Oracle data bloc5 consists o one or more physical bloc5s operatingsystem bloc5s4 so the data bloc5, i larger than an operating system bloc5,should be an even multiple o the operating system bloc5 si6e, e.g., i the:*&C operating system bloc5 si6e is G3 or E3, then the Oracle data bloc5should be G3, E3, ?3, G3, H3, etc in si6e. This optimi6es &$O.

    The data bloc5 si6e is set at the time the database is created and cannot bechanged. &t is set with the %&*&"OC9*SI-) parameter. The ma9imumdata bloc5 si6e depends on the operating system.

    Thus, the Oracle database architecture includes both logical and physicalstructures as ollows

    • (hysical -ontrol fles< +edo #og ;iles< atafles< Operating !ystem/loc5s.

    • #ogical Tablespaces< !egments< 9tents< ata /loc5s.

    S" Statement Processing

     ___________________________________________________________________________________ 

    Page 32 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    33/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    !"# !tatements are processed dierently depending on whether thestatement is a 7uery, data manipulation language %+"4 to update, insert,or delete a row, or data defnition language %%"4 to write inormation tothe data dictionary.

    Processing a Luery:• (arse

    o !earch or identical statement in the !hared !"# Area.o -hec5 synta9, obIect names, and privileges.o #oc5 obIects used during parse.

    o -reate and store e9ecution plan.• /ind Obtains values or variables.

    • 9ecute (rocess statement.

    • ;etch +eturn rows to user process.

    Processing a %+" statement:

    • (arse !ame as the parse phase used or processing a 7uery.

    • /ind !ame as the bind phase used or processing a 7uery.

    • 9ecuteo & the data and undo bloc5s are not already in the atabase

    /uer -ache, the server process reads them rom the datafles

    into the atabase /uer -ache.o The server process places loc5s on the rows that are to be

    modifed. The undo bloc5 is used to store the beore image othe data, so that the )# statements can be rolled bac5 inecessary.

    o The data bloc5s record the new values o the data.o The server process records the beore image to the undo bloc5

    and updates the data bloc5. /oth o these changes are made inthe atabase /uer -ache. Any changed bloc5s in the

     ___________________________________________________________________________________ 

    Page 33 of 34

  • 8/20/2019 The Oracle Databae Archietecture

    34/34

    The Oracle Database Architecture __  ___________________________________________________________________________________ 

    atabase /uer -ache are mar5ed as dirty buers. That is,buers that are not the same as the corresponding bloc5s onthe dis5.

    o The processing o a #T or &*!+T command uses similarsteps. The beore image or a #T contains the column

     values in the deleted row, and the beore image o an &*!+T

    contains the row location inormation.

    Processing a %%" statement:• The e9ecution o # ata efnition #anguage4 statements diers

    rom the e9ecution o )# ata )anipulation #anguage4 statementsand 7ueries, because the success o a # statement re7uires writeaccess to the data dictionary.

    • ;or these statements, parsing actually includes parsing, datadictionary loo5up, and e9ecution. Transaction management, sessionmanagement, and system management !"# statements are processedusing the parse and e9ecute stages. To re%e9ecute them, simply

    perorm another e9ecute.

    * O; *OT!