Less04 Instance Tb

  • Upload
    yairr

  • View
    216

  • Download
    0

Embed Size (px)

Citation preview

  • 8/14/2019 Less04 Instance Tb

    1/42

    4Copyright 2005, Oracle. All rights reserved.

    Managing the Oracle Instance

  • 8/14/2019 Less04 Instance Tb

    2/42

    4-2 Copyright 2005, Oracle. All rights reserved.

    Objectives

    After completing this lesson, you should be able to do

    the following:

    Start and stop the Oracle database and

    components Use Enterprise Manager (EM)

    Understand the stages of database startup

    Modify database initialization parameters

    Compare manual and automatic shared memorymanagement

    Access a database with SQL*Plus and iSQL*Plus

    Access the data dictionary

  • 8/14/2019 Less04 Instance Tb

    3/42

    4-3 Copyright 2005, Oracle. All rights reserved.

    Management Framework

    The three components of the Oracle

    Database 10gmanagement framework are: Database instance Listener Management interface

    Database Control Management agent (when using Grid Control)

    ListenerDatabase

    Control

    Managementagent

    Management interface

    -or-

    > Components

    Starting DB

    Stopping DB

    Init Params

    Memory

    Alert Log

    SQL*Plus

    Dictionary

  • 8/14/2019 Less04 Instance Tb

    4/42

    4-4 Copyright 2005, Oracle. All rights reserved.

    Starting and Stopping Database Control

    $ emctl start dbconsoleTZ set to US/PacificOracle Enterprise Manager 10g Database Control Release 10.2.0.0Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.http://edrsr9p1.us.oracle.com:1158/em/console/aboutApplicationStarting Oracle Enterprise Manager 10g Database Control................ started.

    ------------------------------------------------------------------Logs are generated in directory/u01/app/oracle/product/10.2.0/db_1/edrsr9p1.us.oracle.com_orcl/sysman/log

    $ emctl stop dbconsole

    TZ set to US/PacificOracle Enterprise Manager 10g Database Control Release 10.2.0.0Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.http://edrsr9p1.us.oracle.com:1158/em/console/aboutApplicationStopping Oracle Enterprise Manager 10g Database Control ...... Stopped.

  • 8/14/2019 Less04 Instance Tb

    5/42

    4-5 Copyright 2005, Oracle. All rights reserved.

    Oracle Enterprise Manager

  • 8/14/2019 Less04 Instance Tb

    6/42

    4-6 Copyright 2005, Oracle. All rights reserved.

    Accessing Oracle Enterprise Manager

  • 8/14/2019 Less04 Instance Tb

    7/424-7 Copyright 2005, Oracle. All rights reserved.

    Database Home Page

    Property pages

  • 8/14/2019 Less04 Instance Tb

    8/424-8 Copyright 2005, Oracle. All rights reserved.

    Starting and Stopping the Listener

  • 8/14/2019 Less04 Instance Tb

    9/424-9 Copyright 2005, Oracle. All rights reserved.

    Database Startup and

    Shutdown

    or

    Components

    > Starting DB

    Stopping DB

    Init Params

    MemoryAlert Log

    SQL*Plus

    Dictionary

  • 8/14/2019 Less04 Instance Tb

    10/424-10 Copyright 2005, Oracle. All rights reserved.

    Starting Up an Oracle Database Instance

  • 8/14/2019 Less04 Instance Tb

    11/424-11 Copyright 2005, Oracle. All rights reserved.

    Starting Up an Oracle Database Instance:

    NOMOUNT

    OPEN

    MOUNT

    NOMOUNT

    SHUTDOWN

    Instance

    started

    STARTUP

  • 8/14/2019 Less04 Instance Tb

    12/42

  • 8/14/2019 Less04 Instance Tb

    13/424-13 Copyright 2005, Oracle. All rights reserved.

    Starting Up an Oracle Database Instance:

    OPEN

    OPEN

    MOUNT

    NOMOUNT

    SHUTDOWN

    All files opened as

    described by the control

    file for this instance

    Control file

    opened for this

    instance

    Instance

    started

    STARTUP

  • 8/14/2019 Less04 Instance Tb

    14/424-14 Copyright 2005, Oracle. All rights reserved.

    Starting Up an Oracle DB Instance:

    OPEN

    OPEN

    MOUNT

    NOMOUNT

    SHUTDOWN

    All files opened as

    described by the control

    file for this instance

    Control file

    opened for this

    instance

    Instance

    started

    STARTUP

  • 8/14/2019 Less04 Instance Tb

    15/424-15 Copyright 2005, Oracle. All rights reserved.

    Shutting Down an Oracle

    Database Instance

    Components

    Starting DB

    > Stopping DB

    Init Params

    MemoryAlert Log

    SQL*Plus

    Dictionary

  • 8/14/2019 Less04 Instance Tb

    16/424-16 Copyright 2005, Oracle. All rights reserved.

    Shutdown Modes

    A

    No

    No

    No

    No

    T

    No

    No

    Yes

    Yes

    I

    No

    No

    No

    Yes

    Shutdown Mode

    Allows new connections

    Waits until current sessions end

    Waits until current transactions end

    Forces a checkpoint and closes files

    N

    No

    Yes

    Yes

    Yes

    Shutdown mode:

    A = ABORT I = IMMEDIATE

    T = TRANSACTIONAL

    N = NORMAL

  • 8/14/2019 Less04 Instance Tb

    17/424-17 Copyright 2005, Oracle. All rights reserved.

    SHUTDOWN Options

    During

    SHUTDOWNNORMAL

    or

    SHUTDOWNTRANSACTIONAL

    or

    SHUTDOWNIMMEDIATE

    Consistent database

    (clean database)

    On the way down: Uncommitted

    changes rolled

    back, for

    IMMEDIATE and

    TRANSACTIONAL

    Database buffer

    cache written to

    data files

    Resourcesreleased

    On the way up: No instance

    recovery

  • 8/14/2019 Less04 Instance Tb

    18/424-18 Copyright 2005, Oracle. All rights reserved.

    Full Notes Page

  • 8/14/2019 Less04 Instance Tb

    19/424-19 Copyright 2005, Oracle. All rights reserved.

    SHUTDOWN Options

    During

    SHUTDOWN ABORTor

    Instance Failure

    or

    STARTUP FORCE

    Inconsistent database

    (dirty database)

    On the way down: Modified buffers

    not written to

    data files

    Uncommitted

    changes not

    rolled back

    On the way up: Online redo

    log files used

    to reapply

    changes

    Undo

    segments

    used to roll

    back

    uncommittedchanges

    Resources

    released

  • 8/14/2019 Less04 Instance Tb

    20/424-20 Copyright 2005, Oracle. All rights reserved.

    Using SQL*Plus to Start Up

    and Shut Down

    [oracle@EDRSR9P1 oracle]$ sqlplus dba1/oracle as sysdbaSQL> shutdown immediate;Database closed.Database dismounted.

    ORACLE instance shut down.SQL> startup;ORACLE instance started.Total System Global Area 285212672 bytesFixed Size 1218472 bytes Variable Size 250177624 bytesDatabase Buffers 33554432 bytesRedo Buffers 262144 bytesDatabase mounted.Database opened.SQL>

  • 8/14/2019 Less04 Instance Tb

    21/424-21 Copyright 2005, Oracle. All rights reserved.

    spfileorcl.ora

    Initialization Parameter Files ComponentsStarting DB

    Stopping DB

    > Init Params

    MemoryAlert Log

    SQL*Plus

    Dictionary

  • 8/14/2019 Less04 Instance Tb

    22/424-22 Copyright 2005, Oracle. All rights reserved.

    Viewing and Modifying

    Initialization Parameters

  • 8/14/2019 Less04 Instance Tb

    23/424-23 Copyright 2005, Oracle. All rights reserved.

    Managing Memory

    Components

    Automatic Shared Memory Management:

    Is recommendedto simplify management

    Enables you to specify the total SGA memory

    through one initialization parameter

    Enables the Oracle server to manage the amount of

    memory allocated to the shared pool, Java pool,

    buffer cache, and the large pool

    Manually setting shared memory management

    Sizes the components through multiple individualinitialization parameters

    Uses the Memory Advisor to make

    recommendations

    Components

    Starting DB

    Stopping DB

    Init Params

    > MemoryAlert Log

    SQL*Plus

    Dictionary

  • 8/14/2019 Less04 Instance Tb

    24/424-24 Copyright 2005, Oracle. All rights reserved.

    Enabling Automatic Shared

    Memory Management (ASMM)

    Click Enable to enableAutomatic Shared

    Memory Management.

  • 8/14/2019 Less04 Instance Tb

    25/424-25 Copyright 2005, Oracle. All rights reserved.

    Enabling Automatic Shared

    Memory Management (ASMM)

    (Notes Only Slide)

  • 8/14/2019 Less04 Instance Tb

    26/42

    4-26 Copyright 2005, Oracle. All rights reserved.

    Manually Setting Shared

    Memory Management

  • 8/14/2019 Less04 Instance Tb

    27/42

    4-27 Copyright 2005, Oracle. All rights reserved.

    Viewing the Alert Log

    Database Home page > Related Links region >

    Alert Log Content

    Components

    Starting DB

    Stopping DB

    Init Params

    Memory> Alert Log

    SQL*Plus

    Dictionary

  • 8/14/2019 Less04 Instance Tb

    28/42

    4-28 Copyright 2005, Oracle. All rights reserved.

    Viewing the Alert History

  • 8/14/2019 Less04 Instance Tb

    29/42

    4-29 Copyright 2005, Oracle. All rights reserved.

    Using SQL*Plus and iSQL*Plus

    to Access Your Database

    SQL*Plus and iSQL*Plus provide additional

    interfaces to your database to:

    Perform database management operations

    Execute SQL commands to query, insert, update,

    and delete data in your database

    Components

    Starting DB

    Stopping DB

    Init Params

    MemoryAlert Log

    > SQL*Plus

    Dictionary

  • 8/14/2019 Less04 Instance Tb

    30/42

    4-30 Copyright 2005, Oracle. All rights reserved.

    Using iSQL*Plus

    1

    2

    3

  • 8/14/2019 Less04 Instance Tb

    31/42

    4-31 Copyright 2005, Oracle. All rights reserved.

    Using iSQL*Plus

    (Notes Only Page)

  • 8/14/2019 Less04 Instance Tb

    32/42

    4-32 Copyright 2005, Oracle. All rights reserved.

    Using SQL*Plus

    SQL*Plus is:

    A command-line tool

    Used interactively or in batch mode$ sqlplus hr/hr

    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jul 25 12:37:21 2005Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsSQL> select last_name from employees;LAST_NAME-------------------------AbelAndeAtkinson

  • 8/14/2019 Less04 Instance Tb

    33/42

    4-33 Copyright 2005, Oracle. All rights reserved.

    Calling SQL*Plus from a Shell Script

    $ ./batch_sqlplus.shSQL*Plus: Release 10.2.0.1.0 - Production on Mon Jul 25 12:47:44 2005Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

    With the Partitioning, OLAP and Data Mining optionsSQL>COUNT(*)

    ----------107

    SQL>107 rows updated.

    SQL>Commit complete.SQL> Disconnected from Oracle Database 10g Enterprise Edition Release10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining options[oracle@EDRSR9P1 oracle]$

    # Name of this file: batch_sqlplus.sh# Count employees and give raise.sqlplus hr/hr

  • 8/14/2019 Less04 Instance Tb

    34/42

    4-34 Copyright 2005, Oracle. All rights reserved.

    Calling a SQL Script from SQL*Plus

    $ sqlplus hr/hr @script.sql

    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jul 25 12:57:02 2005Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsDEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID

    ------------- ------------------------------ ---------- -----------60 IT 103 1400

    Disconnected from Oracle Database 10g Enterprise Edition Release10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining options$

    select * from departments where location_id = 1400;quit

    script.sql

    Output

  • 8/14/2019 Less04 Instance Tb

    35/42

    4-35 Copyright 2005, Oracle. All rights reserved.

    Data Dictionary: Overview

    SELECT * FROM dictionary;

    Components

    Starting DB

    Stopping DB

    Init Params

    MemoryAlert Log

    SQL*Plus

    > DictionaryTables

    Indexes

    Views

    UsersSchemas

    Procedures

    and so on

  • 8/14/2019 Less04 Instance Tb

    36/42

    4-36 Copyright 2005, Oracle. All rights reserved.

    Data Dictionary Views

    ALL_

    views

    DBA_

    views

    N/A

    Subset

    of

    Usually same as ALL_

    except for missing OWNER

    column. Some views have

    abbreviated names as

    PUBLIC synonyms.

    Everything

    that the user

    owns

    EveryoneUSER_

    Includes users own objectsEverything

    that the user

    has privileges

    to see

    EveryoneALL_

    May have additional

    columns meant for DBA

    use only

    EverythingDBADBA_

    NotesContentsWho Can

    Query

  • 8/14/2019 Less04 Instance Tb

    37/42

    4-37 Copyright 2005, Oracle. All rights reserved.

    Data Dictionary: Usage Examples

    SELECT USERNAME, ACCOUNT_STATUS FROM

    dba_users WHERE ACCOUNT_STATUS = 'OPEN';

    SELECT table_name, tablespace_name FROMuser_tables;

    SELECT sequence_name, min_value, max_value,increment_by FROM all_sequences WHEREsequence_owner IN ('MDSYS','XDB');

    a

    b

    c

    DESCRIBE dba_indexes;d

  • 8/14/2019 Less04 Instance Tb

    38/42

    4-38 Copyright 2005, Oracle. All rights reserved.

    Dynamic Performance Views

    Dynamic performance viewsprovide access to

    information about changing

    states and conditions in the

    database.

    Session data

    Wait events

    Memory allocations

    Running SQL

    UNDO usage

    Open cursors

    Redo log usage

    And so on

    Oracle instance

  • 8/14/2019 Less04 Instance Tb

    39/42

    4-39 Copyright 2005, Oracle. All rights reserved.

    Dynamic Performance Views:

    Usage Examples

    SQL> SELECT sql_text, executions FROM v$sqlWHERE cpu_time > 200000;

    SQL> SELECT * FROM v$session WHERE machine ='EDRSR9P1' and logon_time > SYSDATE - 1;

    SQL> SELECT sid, ctime FROM v$lock WHEREblock > 0;

    a

    b

    c

  • 8/14/2019 Less04 Instance Tb

    40/42

    4-40 Copyright 2005, Oracle. All rights reserved.

    Dynamic Performance Views:

    Considerations

    These views are owned by SYS.

    Different views are available at different times:

    The instance has been started.

    The database is mounted.

    The database is open.

    You can queryV$FIXED_TABLE to see all the viewnames.

    These views are often referred to as v-dollarviews.

    Read consistency is not guaranteed on these

    views because the data is dynamic.

  • 8/14/2019 Less04 Instance Tb

    41/42

    4-41 Copyright 2005, Oracle. All rights reserved.

    Summary

    In this lesson, you should have learned how to:

    Start and stop the Oracle database, listener, and

    Database Control

    Use Enterprise Manager and describe its high-level functionality

    Understand the stages of database startup

    Modify database initialization parameters

    Configure automatic memory management of the

    Shared Global Area (SGA)

    Access a database with SQL*Plus and iSQL*Plus

    Access the static data dictionary

    Access dynamic performance views

  • 8/14/2019 Less04 Instance Tb

    42/42

    Practice Overview:

    Managing the Oracle Instance

    This practice covers the following topics:

    Navigating in Enterprise Manager

    Stopping and starting the Oracle listener

    Viewing and modifying initialization parameters Stopping and starting the database instance

    Viewing the alert log

    Connecting to the database by using SQL*Plus

    andiSQL*Plus

    Using the data dictionary