oracle instance

Upload: pillinagaraju

Post on 07-Jul-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/18/2019 Oracle Instance

    1/11

    Every running Oracle database is associated with an Oracleinstance. When a database is started on a database server(regardless of the type of computer), Oracle allocates a memoryarea called the System Global rea (SG) and starts one or moreOracle processes. !his combination of the SG and the Oracleprocesses is called an Oracle instance. !he memory and processesof an instance manage the associated database"s data e#cientlyand serve the one or multiple users of the database.

    fter starting an instance, Oracle associates the instance with thespeci$ed database. !his is called mounting the database. !hedatabase is then ready to be opened, which ma%es it accessible toauthori&ed users.

    How can I tell if an Oracle database is mounted andactivated? 

    1 - Is the database mounted (as in, has someone done "alter database mount standby

    database")

    2 - How can I tell if the database is activated (as in, "alter database activate standby

    database")?

    S' SEE*! +S!*E-E, /!0SE-S!!1S, +S!*E-2OE from v3instance4

    +S!*E-E /!0SE-S!!1S +S!*E-2OE 5555555555555555 55555555555555555 555555555555555555 2G267 *!+8E 92+2:-+S!*E

    When the instance is started, the init;.ora $le is read by the system and SG is allocated asper the initiali&ation parameters. o database is associated with this instance.

    Once you Mount the database, it is asoociated with the instance. !he contol $le of the /0 is

    read and db $les, redo log $les and rollbac% segments, all are associated with the instance.

    (these $les are not yet "open") !hat is why this state is used for moving around the db $les.

    http://serverfault.com/questions/38488/how-can-i-tell-if-an-oracle-database-is-mounted-and-activatedhttp://serverfault.com/questions/38488/how-can-i-tell-if-an-oracle-database-is-mounted-and-activatedhttp://serverfault.com/questions/38488/how-can-i-tell-if-an-oracle-database-is-mounted-and-activatedhttp://serverfault.com/questions/38488/how-can-i-tell-if-an-oracle-database-is-mounted-and-activated

  • 8/18/2019 Oracle Instance

    2/11

    When the database is started or opened, all these $les are open and available for use to

    the users

    Startup omount < 5

    2ead the parameter $le and start the instance.

    +nstance name identi$ed by O2*E-S+/ env parameter.

     !he parameter $le controls such things as SG si&e, database name that can connect to this

    instance.

    /atabase not associated with instance yet.

    s an e=ample, you may need to do this if you will mount a standby database.

    ount < 5

    ssociates database with the instance.

    Open and read control $lesEstablish physical $les associated with database. i.e location, si&e, amount of redo log $les.

    9hysical database $le names and locations.

    /0 may need to be in mount state for all %inds of /0 activity.

    e=amples <

    rename>move system data$le.

    put database in archivelog mode.

    /atabase not yet available for user connections.

    Opened>started

    Ensure physical $les e=ist.

    ma%e available for normal operations.

    open online data$les, redo logs.

    ac?uire rollbac% segments.

     !hese states are useful in many situations to a /0, main areas where these are useful are 4

    rchitecture>dmin

    0ac%up>2ecovery.

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    Starting Up a Database Using SQL*Plus

    ou can start a !#$%lus session, connect to Oracle &atabase with administrator 'rivilees, and

    then issue the STARTUP command *sin !#$%lus in this way is the only method described in

    detail in this boo+

  • 8/18/2019 Oracle Instance

    3/11

    Starting Up an Instanceou use the !#$%lus STARTUP command to start u' an Oracle &atabase instance ou can start an

    instance in various modes

    • Start the instance without mounting a database. !his does not allow access to

    the database and usually would be done only for database creation or the re5

    creation of control $les.

    • Start the instance and mount the database, but leave it closed. !his state allows

    for certain /0 activities, but does not allow general access to the database.

    • Start the instance, and mount and open the database. !his can be done in

    unrestricted mode, allowing access to all users, or in restricted mode, allowing

    access for database administrators only.

    • @orce the instance to start after a startup or shutdown problem, or start the

    instance and have complete media recovery begin immediately.

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    In this example from a Windows XP server, we set the ORACLE_SI to the name of

    the data!ase and we lo" into S#L$Pl%s %sin" the &s's as s'sd!a& lo"in( )his "ives %s

    the privile"es we need to !e a!le to start%p the data!ase( *inall', after we enter o%r password, we iss%e the start%p +ommand to start%p the data!ase( Ora+le displa's its

     pro"ress as it opens the data!ase, and then ret%rns %s to the S#L$Pl%s prompt on+e

    the start%p has !een +ompleted(

    When Ora+le is tr'in" to open 'o%r data!ase, it "oes thro%"h three distin+t sta"es, and

    ea+h of these is listed in the start%p o%tp%t listed previo%sl'( )hese sta"es are

    $ Start%p -nomo%nt.

    $ /o%nt

    $ Open

    Let&s loo0 at these sta"es in a !it more detail(

  • 8/18/2019 Oracle Instance

    4/11

    The Startup (nomount) Stage

    When 'o% iss%e the start%p +ommand, the first thin" the data!ase will do is enter the

    nomo%nt sta"e( %rin" the nomo%nt sta"e, Ora+le first opens and reads the

    initiali1ation parameter file -init(ora. to see how the data!ase is +onfi"%red( *or

    example, the si1es of all of the memor' areas in Ora+le are defined within the parameter file(

    After the parameter file is a++essed, the memor' areas asso+iated with the data!ase

    instan+e are allo+ated( Also, d%rin" the nomo%nt sta"e, the Ora+le !a+0"ro%nd

     pro+esses are started( )o"ether, we +all these pro+esses and the asso+iated allo+ated

    memor' the Ora+le instan+e( On+e the instan+e has started s%++essf%ll', the data!ase

    is +onsidered to !e in the nomo%nt sta"e( If 'o% iss%e the start%p +ommand, then

    Ora+le will a%tomati+all' move onto the next sta"e of the start%p, the mo%nt sta"e(

    Starting the Oracle Instance (Nomount Stage))here are some t'pes of Ora+le re+over' operations that re2%ire the data!ase to !e innomo%nt sta"e( When this is the +ase, 'o% need to iss%e a spe+ial start%p +ommand

    start%p nomo%nt, as seen in this example

    S#L3 start%p nomo%nt

    The Mount Stage

    When the start%p +ommand enters the mo%nt sta"e, it opens and reads the +ontrol file(

    )he +ontrol file is a !inar' file that tra+0s important data!ase information, s%+h as the

    lo+ation of the data!ase datafiles(

    In the mo%nt sta"e, Ora+le determines the lo+ation of the datafiles, !%t does not 'et

    open them( On+e the datafile lo+ations have !een identified, the data!ase is read' to

     !e opened(

    Mounting the Database

    Some forms of re+over' re2%ire that the data!ase !e opened in mo%nt sta"e( )o p%t

    the data!ase in mo%nt sta"e, %se the start%p mo%nt +ommand as seen here

    S#L3 start%p mo%nt

    If 'o% have alread' started the data!ase instan+e with the start%p nomo%nt +ommand,

    'o% mi"ht +han"e it from the nomo%nt to mo%nt start%p sta"e %sin" the alter data!ase

    +ommand

    S#L3 alter data!ase mo%nt4

  • 8/18/2019 Oracle Instance

    5/11

    The Open Oracle startup Stage

    )he last start%p step for an Ora+le data!ase is the open sta"e( When Ora+le opens the

    data!ase, it a++esses all of the datafiles asso+iated with the data!ase( On+e it has

    a++essed the data!ase datafiles, Ora+le ma0es s%re that all of the data!ase datafiles are

    +onsistent(

    Opening the Oracle Database

    )o open the data!ase, 'o% +an 5%st %se the start%p +ommand as seen in this example

    S#L3 start%p

    If the data!ase is mo%nted, 'o% +an open it with the alter data!ase open +ommand as

    seen in this example

    S#L3 alter data!ase open4

    Opening the Database in Restricted Mode

    6o% +an also start the data!ase in restri+ted mode( Restri+ted mode will onl' allow

    %sers with spe+ial privile"es -we will dis+%ss %ser privile"es in a later +hapter. to

    a++ess the data!ase -t'pi+all' 7A&s., even tho%"h the data!ase is te+hni+all' open(

    We %se the start%p restri+t +ommand to open the data!ase in restri+ted mode as seen in

    this example(

    S#L3 start%p restri+t

    6o% +an ta0e the data!ase in and o%t of restri+ted mode with the alter data!ase

    +ommand as seen in this example

    88 P%t the data!ase in restri+ted session mode(

    S#L3 alter s'stem ena!le restri+ted session4

    88 )a0e the data!ase o%t of restri+ted session mode(

    S#L3 alter s'stem disa!le restri+ted session4

     9ote An' %sers +onne+ted to the Ora+le instan+e when "oin" into restri+ted mode

    will remain +onne+ted4 the' m%st !e man%all' dis+onne+ted from the data!ase !'

    exitin" "ra+ef%ll' or !' the 7A with the &alter s'stem 0ill session& +ommand(

  • 8/18/2019 Oracle Instance

    6/11

    Problems during Oracle Startup

    )he t'pi+al 7A life is li0e that of an airline pilot, &Lon" moments of !oredom

    followed !' small moments of sheer terror&, and one pla+e for sheer terror is an error

    d%rin" a data!ase start%p(

    )he most t'pi+al reason for a data!ase not startin" %p is a prior data!ase +rash, a data

    +orr%ption, dis0 fail%re or some other +atastrophi+ event from whi+h the data!ase

    +annot re+over( In these +ases, 'o% have to "o into data!ase re+over' mode to start

    'o%r instan+e( )here is a +hapter on re+over' later in this !oo0 and we will dis+%ss

    what to do when Ora+le will not start%p

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ORACLE: NOMOUNT, MOUNT And OPEN MODES in Oracle

    Lets take a look at the different OPEN_MODES in Oracle and Analyse what happens at

    every step.

    SQL> SHUTDOWN IMMEDIATE

    Database closed.

    Database diso!nted.

    O"A#LE instance sh!t down.

    SQL> STARTUP NOMOUNT

    PFILE=C:\oracle\prodc!\"#$%$#\ad&'(\HARR)\p*'le\'('!$ora$+",%#"""++-+.

    O"A#LE instance started.

    $otal Syste %lobal Area &'()'*+*, bytes

    -ied Si/e (0'('(* bytes

    1ariable Si/e (*222,&+3 bytes

    Database 4!ffers ,(&0)*3'* bytes

    "edo 4!ffers 23',020 bytes

    I( NOMOUNT MODE /e crea!e "$ D012 a(d %$ CONTROLFILES$

    SQL> DESC 34INSTANCE

     Nae N!ll5 $ype

     66666666666666666666666666666666666666666666666666666 66666666666666666666666666666666666666666666

     7NS$AN#E_N8M4E" N8M4E"

     7NS$AN#E_NAME 1A"#9A"0:(*;

     9OS$_NAME 1A"#9A"0:*,;

     1E"S7ON 1A"#9A"0:(2;

     S$A"$8P_$7ME DA$E

     S$A$8S 1A"#9A"0:(0;

  • 8/18/2019 Oracle Instance

    7/11

     PA"ALLEL 1A"#9A"0:);

     $9"EAD< N8M4E"

     A"#971E" 1A"#9A"0:2;

     LO%_S=7$#9_=A7$ 1A"#9A"0:(&;

     LO%7NS 1A"#9A"0:(3;

     S98$DO=N_PEND7N% 1A"#9A"0:); DA$A4ASE_S$A$8S 1A"#9A"0:(2;

     7NS$AN#E_"OLE 1A"#9A"0:(+;

     A#$71E_S$A$E 1A"#9A"0:';

     4LO#>ED 1A"#9A"0:);

    SQL> SELECT HOST5NAME6INSTANCE5NAME63ERSION FROM 34INSTANCE7

    9OS$_NAME 7NS$AN#E_NAME

    1E"S7ON

    6666666666666666666666666666666666666666666666666666666666666666 6666666666666666

    66666666666666666

    $ES$6P# harry

    (3.0.3.).3

    SQL> DESC 34CONTROLFILE7

     Nae N!ll5 $ype

     66666666666666666666666666666666666666666666666666666 66666666

    666666666666666666666666666666666666

     S$A$8S 1A"#9A"0:2;

     NAME 1A"#9A"0:&();

     7S_"E#O1E"?_DES$_-7LE 1A"#9A"0:);

     4LO#>_S7@E N8M4E"

     -7LE_S7@E_4L>S N8M4E"

    SQL> DESC 34da!a8a2e

     Nae N!ll5 $ype

     66666666666666666666666666666666666666666666666666666 66666666

    666666666666666666666666666666666666

     D47D N8M4E"

     NAME 1A"#9A"0:';

     #"EA$ED DA$E

     "ESE$LO%S_#9AN%E< N8M4E"

     "ESE$LO%S_$7ME DA$E

     P"7O"_"ESE$LO%S_#9AN%E< N8M4E"

     P"7O"_"ESE$LO%S_$7ME DA$E LO%_MODE 1A"#9A"0:(0;

     #9E#>PO7N$_#9AN%E< N8M4E"

     A"#971E_#9AN%E< N8M4E"

     #ON$"OL-7LE_$?PE 1A"#9A"0:2;

     #ON$"OL-7LE_#"EA$ED DA$E

     #ON$"OL-7LE_SE8EN#E< N8M4E"

     #ON$"OL-7LE_#9AN%E< N8M4E"

  • 8/18/2019 Oracle Instance

    8/11

     #ON$"OL-7LE_$7ME DA$E

     OPEN_"ESE$LO%S 1A"#9A"0:((;

     1E"S7ON_$7ME DA$E

     OPEN_MODE 1A"#9A"0:(3;

     P"O$E#$7ON_MODE 1A"#9A"0:03;

     P"O$E#$7ON_LE1EL 1A"#9A"0:03; "EMO$E_A"#971E 1A"#9A"0:+;

     A#$71A$7ON< N8M4E"

     S=7$#9O1E"< N8M4E"

     DA$A4ASE_"OLE 1A"#9A"0:(*;

     A"#971ELO%_#9AN%E< N8M4E"

     A"#971ELO%_#OMP"ESS7ON 1A"#9A"0:+;

     S=7$#9O1E"_S$A$8S 1A"#9A"0:03;

     DA$A%8A"D_4"O>E" 1A"#9A"0:+;

     %8A"D_S$A$8S 1A"#9A"0:2;

     S8PPLEMEN$AL_LO%_DA$A_M7N 1A"#9A"0:+;

     S8PPLEMEN$AL_LO%_DA$A_P> 1A"#9A"0:);

     S8PPLEMEN$AL_LO%_DA$A_87 1A"#9A"0:);

     -O"#E_LO%%7N% 1A"#9A"0:);

     PLA$-O"M_7D N8M4E"

     PLA$-O"M_NAME 1A"#9A"0:(3(;

     "E#O1E"?_$A"%E$_7N#A"NA$7ON< N8M4E"

     LAS$_OPEN_7N#A"NA$7ON< N8M4E"

     #8""EN$_S#N N8M4E"

     -LAS94A#>_ON 1A"#9A"0:(+;

     S8PPLEMEN$AL_LO%_DA$A_-> 1A"#9A"0:);

     S8PPLEMEN$AL_LO%_DA$A_ALL 1A"#9A"0:);

     D4_8N78E_NAME 1A"#9A"0:)3;

     S$AND4?_4E#AME_P"7MA"?_S#N N8M4E"

     -S_-A7LO1E"_S$A$8S 1A"#9A"0:0(;

     -S_-A7LO1E"_#8""EN$_$A"%E$ 1A"#9A"0:)3;

     -S_-A7LO1E"_$9"ES9OLD N8M4E"

     -S_-A7LO1E"_O4SE"1E"_P"ESEN$ 1A"#9A"0:2;

     -S_-A7LO1E"_O4SE"1E"_9OS$ 1A"#9A"0:&(0;

    SQL> SELECT 9 FROM 34CONTROLFILE7

    no rows selected

    SQL> SELECT 9 FROM 34DATA0ASE7

    SELE#$ B -"OM 1CDA$A4ASE

      BE""O" at line (

    O"A63(&32 database not o!nted

    So, now in nomount mode, the databae S!A and "ac#$round %roce ha&e been initiali'ed onl() Onl(

    the *ntance i created, howe&er, the databae can not be +ueried a it i not initiali'ed, a well a,

    the CONTROL *LES -A.E /ET NOT "EEN READ, althou$h the( are %reent in the *N*T)ORA 0ile) The(

    will be read in the Ne1t Mode)

  • 8/18/2019 Oracle Instance

    9/11

    SQL> ALTER DATA0ASE MOUNT7

    Database altered.

    SQL> SELECT NAME6 OPEN5MODE6 LO5MODE FROM 34DATA0ASE7

    NAME OPEN_MODE LO%_MODE

    66666666666666666666 6666666666 666666666666

    9A""? MO8N$ED A"#971ELO%

    SQL> SELECT 9 FROM 34CONTROLFILE7

    S$A$8S NAME 7S_ 4LO#>_S7@E -7LE_S7@E_4L>S

    6666666 66666666666666666666 666 6666666666 66666666666666

      #9A""?9A""?#ON$" NO (*)+, ,)3

      OL3(.#$L

      #9A""?9A""?#ON$" NO (*)+, ,)3

      OL30.#$L

      #9A""?9A""?#ON$" NO (*)+, ,)3

      OL3).#$L

    Now that the Databae i MOUNTED, Oracle can read the Control 0ile and #now where all the

    data0ile are %reent)

    Control 0ile ha %ointer that %ro&ide connection b2w Data0ile, Redo Lo$, Archi&ed Lo$, Memor( and

    Lat U%dated SCN)

    SQL> 2elec! 9 *ro& ;4lo 2elec! 9 *ro& ;4lo

  • 8/18/2019 Oracle Instance

    10/11

    SQL> arc';e lo< l'2!

    Database loG ode Archive Mode

    A!toatic archival Enabled

    Archive destination 8SE_D4_"E#O1E"?_-7LE_DES$

    Oldest online loG seH!ence 0)Net loG seH!ence to archive 0&

    #!rrent loG seH!ence 0&

    So fro hereI we can see that the Database in Mo!nt Mode has all the reH!ired

    paraeters initiali/edI

    however the database itself is still not open to !sers.

     MOUNT MODE IS WHERE MAINTENANCE WOR IS DONE$

    SQL> ALTER DATA0ASE OPEN7

    Database altered.

    SQL> 2elec! '(2!a(ce5(a&e6 2!a!2 *ro& ;4'(2!a(ce7

    7NS$AN#E_NAME S$A$8S

    6666666666666666 666666666666

    harry OPEN

    SQL> SELECT NAME6 OPEN5MODE FROM 34DATA0ASE7

    NAME OPEN_MODE

    66666666666666666666 6666666666

    9A""? "EAD ="7$E

    Now the database is open for !se.

    IN A NUTSHELL:

    SLJ start!p noo!nt

    O"A#LE instance started.

    $otal Syste %lobal Area &'()'*+*, bytes

    -ied Si/e (0'('(* bytes

    1ariable Si/e 0+',3')'* bytes

    Database 4!ffers 0')*3(0+3 bytes

    "edo 4!ffers 23',020 bytes

    SQL> 2elec! '(2!a(ce5(a&e6 2!a!2 *ro& ;4'(2!a(ce7

    7NS$AN#E_NAME S$A$8S

    6666666666666666 666666666666

    harry S$A"$ED

    SQL> al!er da!a8a2e &o(!

     % 7

  • 8/18/2019 Oracle Instance

    11/11

    Database altered.

    SQL> 2elec! '(2!a(ce5(a&e6 2!a!2 *ro& ;4'(2!a(ce7

    7NS$AN#E_NAME S$A$8S6666666666666666 666666666666

    harry MO8N$ED

    SQL> al!er da!a8a2e ope(7

    Database altered.

    SQL> 2elec! '(2!a(ce5(a&e6 2!a!2 *ro& ;4'(2!a(ce7

    7NS$AN#E_NAME S$A$8S

    6666666666666666 666666666666

    harry OPEN