Less04 Instance TB3

download Less04 Instance TB3

of 36

Transcript of Less04 Instance TB3

  • 8/14/2019 Less04 Instance TB3

    1/36

    4Copyright 2005, Oracle. All rights reserved.

    Managing the Oracle Instance

  • 8/14/2019 Less04 Instance TB3

    2/36

    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)

    Access a database with SQL*Plus and iSQL*Plus

    Modify database initialization parameters

    Describe the stages of database startup Describe the database shutdown options

    View the alert log

    Access dynamic performance views

  • 8/14/2019 Less04 Instance TB3

    3/36

    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

    SQL*Plus

    Init Params

    DB Startup

    DB Shutdown

    Alert Log

    Perf Views

  • 8/14/2019 Less04 Instance TB3

    4/36

    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.1.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.1.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 TB3

    5/36

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

    Oracle Enterprise Manager

  • 8/14/2019 Less04 Instance TB3

    6/36

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

    Accessing Oracle Enterprise Manager

  • 8/14/2019 Less04 Instance TB3

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

    Database Home Page

    Property pages

  • 8/14/2019 Less04 Instance TB3

    8/364-8 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

    > SQL*Plus

    Init Params

    DB Startup

    DB ShutdownAlert Log

    Perf Views

  • 8/14/2019 Less04 Instance TB3

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

    Using iSQL*Plus

    1

    2

    3

  • 8/14/2019 Less04 Instance TB3

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

    Setting Up iSQL*Plus

    forSYSDBAand SYSOPERAccess

    For a user to login to iSQL*Plus as SYSDBAorSYSOPERyou must set up the user in the OC4Juser manager byperforming the following steps:

    1. Create a user2. Grant the webDba role to the user

    $ cd $ORACLE_HOME/oc4j/j2ee/isqlplus/\> application-deployments/isqlplus$JAVA_HOME/bin/java \> -Djava.security.properties=\> $ORACLE_HOME/oc4j/j2ee/home/config/jazn.security.props \> -jar $ORACLE_HOME/oc4j/j2ee/home/jazn.jar \> -user "iSQL*Plus DBA/admin" -password welcome -shellJAZN> adduser "iSQL*Plus DBA" username passwordJAZN> grantrole webDba "iSQL*Plus DBA" username

  • 8/14/2019 Less04 Instance TB3

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

    Using iSQL*Plus

    Full Notes Page

  • 8/14/2019 Less04 Instance TB3

    12/364-12 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 options

    SQL> select last_name from employees;LAST_NAME-------------------------AbelAndeAtkinson

  • 8/14/2019 Less04 Instance TB3

    13/364-13 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 TB3

    14/364-14 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 1400Disconnected 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 TB3

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

    spfileorcl.ora

    Initialization Parameter Files ComponentsSQL*Plus

    > Init Params

    DB Startup

    DB ShutdownAlert Log

    Perf Views

  • 8/14/2019 Less04 Instance TB3

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

    Simplified Initialization Parameters

    DB_CACHE_SIZEDB_FILE_MULTIBLOCK

    _READ_COUNTSHARED_POOL_SIZE

    Advanced

    CONTROL_FILESDB_BLOCK_SIZEPROCESSESUNDO_MANAGEMENT

    Basic

  • 8/14/2019 Less04 Instance TB3

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

    Initialization Parameter Examples

    Full Notes Page

  • 8/14/2019 Less04 Instance TB3

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

    Viewing and Modifying

    Initialization Parameters

  • 8/14/2019 Less04 Instance TB3

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

    Database Startup and

    Shutdown

    or

    Components

    SQL*Plus

    Init Params

    > DB Startup

    DB ShutdownAlert Log

    Perf Views

  • 8/14/2019 Less04 Instance TB3

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

    Starting Up an Oracle Database Instance

  • 8/14/2019 Less04 Instance TB3

    21/364-21 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 TB3

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

    Starting Up an Oracle Database Instance:

    MOUNT

    OPEN

    MOUNT

    NOMOUNT

    SHUTDOWN

    Control file

    opened for this

    instance

    Instance

    started

    STARTUP

  • 8/14/2019 Less04 Instance TB3

    23/364-23 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 TB3

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

    Shutting Down an Oracle

    Database Instance

    Components

    SQL*Plus

    Init Params

    DB Startup

    > DB ShutdownAlert Log

    Perf Views

  • 8/14/2019 Less04 Instance TB3

    25/36

    4-25 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 TB3

    26/36

    4-26 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

    Database buffer

    cache written to

    data files

    Resources

    released

    On the way up: No instance

    recovery

  • 8/14/2019 Less04 Instance TB3

    27/36

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

    Full Notes Page

  • 8/14/2019 Less04 Instance TB3

    28/36

    4-28 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 TB3

    29/36

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

    Using SQL*Plus to Start Up

    and Shut Down

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

    ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 285212672 bytesFixed Size 1218472 bytes Variable Size 250177624 bytes

    Database Buffers 33554432 bytesRedo Buffers 262144 bytesDatabase mounted.Database opened.SQL>

  • 8/14/2019 Less04 Instance TB3

    30/36

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

    Viewing the Alert Log

    Database Home page > Related Links region >

    Alert Log Content

    Components

    SQL*Plus

    Init Params

    DB Startup

    DB Shutdown> Alert Log

    Perf Views

  • 8/14/2019 Less04 Instance TB3

    31/36

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

    Viewing the Alert History

  • 8/14/2019 Less04 Instance TB3

    32/36

    4-32 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

    Components

    SQL*Plus

    Init Params

    DB Startup

    DB ShutdownAlert Log

    > Perf Views

  • 8/14/2019 Less04 Instance TB3

    33/36

    4-33 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 TB3

    34/36

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

    Dynamic Performance Views:

    Considerations

    These views are owned by the SYS user.

    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-dollar

    views.

    Read consistency is not guaranteed on these

    views because the data is dynamic.

  • 8/14/2019 Less04 Instance TB3

    35/36

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

    Summary

    In this lesson, you should have learned how to:

    Start and stop the Oracle database and

    components

    Use Enterprise Manager and describe its high-level functionality

    Access a database with SQL*Plus and iSQL*Plus

    Modify database initialization parameters

    Describe the stages of database startup

    Describe the database shutdown options

    View the alert log

    Access dynamic performance views

  • 8/14/2019 Less04 Instance TB3

    36/36

    Practice Overview:

    Managing the Oracle Instance

    This practice covers the following topics:

    Navigating in Enterprise Manager

    Viewing and modifying initialization parameters

    Stopping and starting the database instance Viewing the alert log

    Connecting to the database by using SQL*Plus

    and iSQL*Plus