You are on page 1of 42

4

Managing the Oracle Instance

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 memory
management
• Access a database with SQL*Plus and iSQL*Plus
• Access the data dictionary

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


Management Framework > Components
Starting DB
Stopping DB
Init Params
Memory
Alert Log
The three components of the Oracle SQL*Plus
Database 10g management framework are: Dictionary

• Database instance
• Listener
• Management interface
– Database Control
– Management agent (when using Grid Control)

Management -or-
agent
Database Listener
Control
Management interface

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


Starting and Stopping Database Control

$ emctl start dbconsole


TZ set to US/Pacific
Oracle Enterprise Manager 10g Database Control Release 10.2.0.0
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
http://edrsr9p1.us.oracle.com:1158/em/console/aboutApplication
Starting 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/sy
sman/log

$ emctl stop dbconsole


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

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


Oracle Enterprise Manager

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


Accessing Oracle Enterprise Manager

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


Database Home Page

Property pages

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


Starting and Stopping the Listener

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


Database Startup and Components
> Starting DB
Shutdown Stopping DB
Init Params
Memory
Alert Log
SQL*Plus
Dictionary

or

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


Starting Up an Oracle Database Instance

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


Starting Up an Oracle Database Instance:
NOMOUNT
OPEN
STARTUP

MOUNT

NOMOUNT

Instance
started
SHUTDOWN

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


Starting Up an Oracle Database Instance:
MOUNT
OPEN
STARTUP

MOUNT

Control file
opened for this
NOMOUNT instance

Instance
started
SHUTDOWN

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


Starting Up an Oracle Database Instance:
OPEN
OPEN
STARTUP All files opened as
described by the control
MOUNT file for this instance

Control file
opened for this
NOMOUNT instance

Instance
started
SHUTDOWN

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


Starting Up an Oracle DB Instance:
OPEN
OPEN
STARTUP All files opened as
described by the control
MOUNT file for this instance

Control file
opened for this
NOMOUNT instance

Instance
started
SHUTDOWN

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


Shutting Down an Oracle Components
Starting DB
Database Instance > Stopping DB
Init Params
Memory
Alert Log
SQL*Plus
Dictionary

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


Shutdown Modes

Shutdown Mode A I T N

Allows new connections No No No No

Waits until current sessions end No No No Yes

Waits until current transactions end No No Yes Yes

Forces a checkpoint and closes files No Yes Yes Yes

Shutdown mode:
• A = ABORT
• I = IMMEDIATE
• T = TRANSACTIONAL
• N = NORMAL

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


SHUTDOWN Options

On the way down: During


On the way up:
• Uncommitted • No instance
changes rolled SHUTDOWN recovery
NORMAL
back, for
or
IMMEDIATE and SHUTDOWN
TRANSACTIONAL TRANSACTIONAL
• Database buffer or
SHUTDOWN
cache written to IMMEDIATE
data files
• Resources
released

Consistent database
(clean database)

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


Full Notes Page

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


SHUTDOWN Options

On the way down: During


On the way up:
• Modified buffers • Online redo
not written to SHUTDOWN ABORT log files used
or
data files to reapply
Instance Failure
• Uncommitted or changes
changes not STARTUP FORCE • Undo
rolled back segments
used to roll
back
uncommitted
changes
• Resources
Inconsistent database released
(dirty database)

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


Using SQL*Plus to Start Up
and Shut Down

[oracle@EDRSR9P1 oracle]$ sqlplus dba1/oracle as sysdba

SQL> shutdown immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 285212672 bytes


Fixed Size 1218472 bytes
Variable Size 250177624 bytes
Database Buffers 33554432 bytes
Redo Buffers 262144 bytes
Database mounted.
Database opened.
SQL>

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


Initialization Parameter Files Components
Starting DB
Stopping DB
> Init Params
Memory
Alert Log
SQL*Plus
Dictionary

spfileorcl.ora

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


Viewing and Modifying
Initialization Parameters

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


Managing Memory Components
Starting DB
Components Stopping DB
Init Params
> Memory
Alert Log
• Automatic Shared Memory Management: SQL*Plus
Dictionary
– Is recommended to 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 individual
initialization parameters
– Uses the Memory Advisor to make
recommendations

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


Enabling Automatic Shared
Memory Management (ASMM)

Click Enable to enable


Automatic Shared
Memory Management.

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


Enabling Automatic Shared
Memory Management (ASMM)
(Notes Only Slide)

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


Manually Setting Shared
Memory Management

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


Viewing the Alert Log Components
Starting DB
Stopping DB
Init Params
Memory
> Alert Log
Database Home page > Related Links region > SQL*Plus
Alert Log Content Dictionary

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


Viewing the Alert History

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


Using SQL*Plus and iSQL*Plus Components
Starting DB
to Access Your Database Stopping DB
Init Params
Memory
Alert Log
> SQL*Plus
Dictionary

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

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


Using iSQL*Plus

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


Using iSQL*Plus
(Notes Only Page)

4-31 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 2005


Copyright (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 options

SQL> select last_name from employees;

LAST_NAME
-------------------------
Abel
Ande
Atkinson

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


Calling SQL*Plus from a Shell Script

$ ./batch_sqlplus.sh

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jul 25 12:47:44 2005


Copyright (c) 1982, 2005, Oracle. All rights reserved.
Output
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
# Name of this file: batch_sqlplus.sh
SQL> # Count employees and give raise.
COUNT(*) sqlplus hr/hr <<EOF
---------- select count(*) from employees;
107 update employees set salary =
SQL> salary*1.10;
107 rows updated. commit;
SQL> quit
Commit complete. EOF
SQL> Disconnected from Oracle Database
exit 10g Enterprise Edition Release
10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@EDRSR9P1 oracle]$

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


Calling a SQL Script from SQL*Plus

script.sql select * from departments where location_id = 1400;


quit

Output
$ sqlplus hr/hr @script.sql

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jul 25 12:57:02 2005


Copyright (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 options

DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID


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

Disconnected from Oracle Database 10g Enterprise Edition Release


10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
$

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


Data Dictionary: Overview Components
Starting DB
Stopping DB
Init Params
Memory
Alert Log
Tables SQL*Plus
> Dictionary
Indexes
Views
Users
Schemas
Procedures
and so on

SELECT * FROM dictionary;

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


Data Dictionary Views

Who Can Contents Subset Notes


Query of
DBA_ DBA Everything N/A May have additional
columns meant for DBA
use only
ALL_ Everyone Everything DBA_ Includes user’s own objects
that the user views
has privileges
to see

USER_ Everyone Everything ALL_ Usually same as ALL_


that the user views except for missing OWNER
owns column. Some views have
abbreviated names as
PUBLIC synonyms.

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


Data Dictionary: Usage Examples

a
SELECT table_name, tablespace_name FROM
user_tables;

SELECT sequence_name, min_value, max_value,


b increment_by FROM all_sequences WHERE
sequence_owner IN ('MDSYS','XDB');

c SELECT USERNAME, ACCOUNT_STATUS FROM


dba_users WHERE ACCOUNT_STATUS = 'OPEN';

d DESCRIBE dba_indexes;

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


Dynamic Performance Views

Dynamic performance views


provide access to
information about changing Session data
states and conditions in the Wait events
database. Memory allocations
Running SQL
UNDO usage
Open cursors
Redo log usage
And so on

Oracle instance

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


Dynamic Performance Views:
Usage Examples

a
SQL> SELECT sql_text, executions FROM v$sql
WHERE cpu_time > 200000;

SQL> SELECT * FROM v$session WHERE machine =


b
'EDRSR9P1' and logon_time > SYSDATE - 1;

SQL> SELECT sid, ctime FROM v$lock WHERE


c
block > 0;

4-39 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 query V$FIXED_TABLE to see all the view
names.
• These views are often referred to as “v-dollar
views.”
• Read consistency is not guaranteed on these
views because the data is dynamic.

4-40 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
4-41 Copyright © 2005, Oracle. All rights reserved.
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
and iSQL*Plus
• Using the data dictionary

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

You might also like