less01 db architecture

34
1 Copyright © 2005, Oracle. All rights reserved. Introduction

Upload: shaiknaime

Post on 08-Dec-2015

222 views

Category:

Documents


0 download

DESCRIPTION

Oracle Database 10g Workshop 1

TRANSCRIPT

1Copyright © 2005, Oracle. All rights reserved.

Introduction

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

Objectives

• After completing this course, you should be able to do the following:– Install, create, and administer Oracle Database 10g

Enterprise Edition– Configure the database for an application– Implement a backup and recovery strategy– Employ basic monitoring procedures

• After completing this lesson, you should be able to do the following:– Describe course objectives– Explain the Oracle Database 10g

architecture

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

Oracle Products

• Oracle databases

• Oracle Application Server

• Oracle Applications

• Oracle Collaboration Suite

• Oracle Developer Suite

• Oracle services

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

Oracle Database 10g:“g” Stands for Grid

• Low cost

• High quality of service

• Easy to manage

Storagegrid

Databasegrid

Applicationgrid

Gridcontrol

AutomaticStorage

Management

RealApplication

Clusters

OracleStreams

EnterpriseManager

Grid Control

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

Oracle Database Architecture

An Oracle server:

• Is a database management system that provides an open, comprehensive, integrated approach to information management

• Consists of an Oracle instance and an Oracle database

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

Database Structures

Storage structures

Memory structures

Process structures

Instance

System Global Area (SGA)

Background processes

Database files

DB structures- Memory- Process- Storage

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

Oracle Memory Structures

Java poolDatabase

buffer cacheRedo log

buffer

Shared pool Large pool

SGA

Streams pool

Serverprocess

1PGA

Serverprocess

2PGA

Backgroundprocess

PGA

DB structures- Memory <<- Process- Storage

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

Process Structures

• User process: Started at the time a database user requests a connection to the Oracle server

• Server process: Connects to the Oracle instance and is started when a user establishes a session

• Background processes: Started when an Oracle instance is started

Instance

SGA

Background

processes

Serverprocess

PGA

User process

DB structures- Memory- Process <<- Storage

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

Oracle Processes

SystemMonitor(SMON)

DatabaseWriter

(DBWn)

Check-point

(CKPT)

LogWriter(LGWR)

ProcessMonitor(PMON)

Archiver(ARCn)

Serverprocess

Serverprocess

Serverprocess

Serverprocess

System Global Area(SGA)

Background processes

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

Server Process and Database Buffer Cache

Buffers:

• Pinned

• Clean

• Free or unused

• Dirty

DBWn

Serverprocess

SGA

Databasebuffer cache

Data files

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

Physical Database Structure

Online redo log files

Password file

Parameter file Archive log files

Control files Data files

Alert and trace log files

Backup files

DB structures- Memory- Process- Storage <<

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

Tablespaces and Data Files

• Tablespaces consist of one or more data files.

• Data files belong to only one tablespace.

USERS tablespace

Data file 1 Data file 2

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

SYSTEM and SYSAUX Tablespaces

• The SYSTEM and SYSAUX tablespaces are mandatory tablespaces.

• They are created at the time of database creation.

• They must be online.

• SYSTEM: For core functionality (for example, data dictionary tables)

• SYSAUX: Is auxiliary, for additional database components (such as the Enterprise Manager Repository)

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

Segments, Extents, and Blocks

• Segments exist within a tablespace.

• Segments are made up of a collection of extents.

• Extents are a collection of data blocks.

• Data blocks are mapped to disk blocks.

Segment Extents Data blocks

Disk blocks

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

Logical and Physical Database Structures

Database

Logical Physical

Tablespace Data file

OS block

Segment

Extent

Oracle datablock

Schema

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

Enlarging the Database

You can enlarge the database in the following ways:

• Creating a new tablespace

• Adding a data file to an existing tablespace

• Increasing the size of a data file

• Providing for the dynamic growth of a data file

SYSTEM tablespace

INVENTORY tablespace

Database

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

Exploring the Storage Structure

Click the links to view detailed information.

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

The HR Sample Schema

JOB_HISTORYEMPLOYEE_ID (PK,FK)

START_DATE (PK)

END_DATE

JOB_ID (FK)

DEPARTMENT_ID (FK)

EMPLOYEESEMPLOYEE_ID (PK)

FIRST_NAME

LAST_NAME

EMAIL

PHONE_NUMBER

HIRE_DATE

JOB_ID (FK)

SALARY

COMMISION_PCT

MANAGER_ID (FK)

DEPARTMENT_ID (FK)

DEPARTMENTSDEPARTMENT_ID (PK)

DEPARTMENT_NAME

MANAGER_ID

LOCATION_ID (FK)

JOBSJOB_ID (PK)

JOB_TITLE

MIN_SALARY

MAX_SALARY

REGIONSREGION_ID (PK)

REGION_NAME

COUNTRIESCOUNTRY_ID (PK)

COUNTRY_NAME

REGION_ID (FK)

LOCATIONSLOCATION_ID (PK)

STREET_ADDRESS

POSTAL_CODE

CITY

STATE_PROVINCE

COUNTRY_ID (FK)

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

Database Architecture:Summary of Structural Components

• Memory structures:– System Global Area (SGA): Database buffer cache,

redo buffer, and various pools– Program Global Area (PGA)

• Process structures:– User process and Server process– Background processes: SMON, PMON, DBWn,

CKPT, LGWR, ARCn, and others

• Storage structures:– Logical: Database, schema, tablespace, segment,

extent, and Oracle block– Physical: Files for data, parameters, redo, and OS

block

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

Database Architecture and Activities

The following topics are covered in the remaining part of this lesson:

• Control files

• Oracle instance management

• Data files and Database Writer (DBWn)

• Checkpoints (CKPT)

• Redo log files and LogWriter (LGWR)

• Archiver (ARCn)

• System Monitor (SMON)

• Process Monitor (PMON)

• Example: How the Oracle database works

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

Control Files

• Contain physical database structure information

• Are read at mount stage

• Should be multiplexed to protect against loss

• Are required to access the database

spfileorcl.ora

CONNECT / AS SYSDBASTARTUP

InstanceExample

Database filesSGA

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

Oracle Instance Management

SystemMonitor(SMON)

DatabaseWriter

(DBWn)

LogWriter(LGWR)

ProcessMonitor(PMON)

Archiver(ARCn)

SGA

Java pool

Shared pool Large poolStreams pool

Databasebuffer cache

Redo log buffer

Checkpoint(CKPT)

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

Data Files

• Contain all database data

• Can be associated with only one database

• Form the logical unit of database storage called “tablespace”

• Are read into memory (in blocks) on request

• Should be secured by following a backup strategy

SGA

Databasebuffer cache

Data files

DatabaseWriter

(DBWn)

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

Database Writer (DBWn)

DBWn writes when one of the following events occurs:

• Checkpoint

• Dirty buffers’ threshold

• No free buffers

• Timeout

• RAC ping request

• Tablespace OFFLINE• Tablespace READ ONLY• Table DROP or TRUNCATE• Tablespace BEGIN BACKUP

SGA

Databasebuffer cache

Data files

DatabaseWriter

(DBWn)

Background Information

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

Checkpoint (CKPT)

Responsible for:

• Signaling DBWn at checkpoints

• Updating data file headers withcheckpoint information

• Updating control files withcheckpoint information

DatabaseWriter

(DBWn)

Checkpoint(CKPT)

SGA

Databasebuffer cache

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

Redo Log Files and LogWriter

Redo log files:

• Record changes to the database

• Should be multiplexed to protect against loss

LogWriter writes:

• At commit

• When one-third full

• Every three seconds

• Before DBWn writesGroup 3

LogWriter

(LGWR)

Group 1 Group 2

Redo log buffer

SGA

Copyright © 2005, Oracle. All rights reserved.1-31

Archiver (ARCn)

• Is an optional background process

• Automatically archives online redo log files when ARCHIVELOG mode is set for the database

• Preserves the record of all changes made to the database

LogWriter(LGWR)

Archiver(ARCn)

Redo log buffer

SGA

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

System Monitor (SMON)

• Performs instance recovery at startup

• Coalesces free space

• Deallocates temporary segments

SystemMonitor(SMON)

Instance

SGA

Other

processes

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

Process Monitor (PMON)

PMON cleans up the database buffer cache and frees resources after failed processes by:

• Rolling back the transaction

• Releasing locks

• Releasing other resources

Instance

SGA

Other

processes

Serverprocess

PGA

User process

ProcessMonitor(PMON)

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

Oracle Instance Management: Summary

SystemMonitor(SMON)

DatabaseWriter

(DBWn)

LogWriter(LGWR)

ProcessMonitor(PMON)

Archiver(ARCn)

SGA

Java pool

Shared pool Large poolStreams pool

Databasebuffer cache

Redo log buffer

Checkpoint(CKPT)

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

How the Oracle Database Works

Instance

SGA

DatabaseWriter

(DBWn)

LogWriter(LGWR)

Databasebuffer cache

Redo log buffer

Serverprocess

User process

1

2

3

Starting a database instance

Establishing a connection

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

How the Oracle Database WorksInstance

SGA

DatabaseWriter

(DBWn)

LogWriter(LGWR)

Databasebuffer cache

Redo log buffer

Serverprocess

User process

4 The user updates a row.

10

7

6

5

8

9

Processing a SQL statement

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

Summary

In this lesson, you should have learned how to:

• Describe the course objectives

• Explain the Oracle Database 10g architecture

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

Database Architecture: Quiz

Mark each of the following statements about an Oracle database as True or False:1. Control files store information about the physical

database structure.2. Transaction changes are stored in redo log files.3. Tablespaces consist of one or more data files.4. A data file can be used for more than one

tablespace.5. LogWriter (LGWR) writes redo log entries to the

disk.6. Database Writer (DBWn) writes modified blocks

from the buffer cache to the disk.7. All Oracle background processes are optional.