Week1 Introduction Enterprise Database Systems

37
Week 1 Enterprise DB Architecture 1

Transcript of Week1 Introduction Enterprise Database Systems

Page 1: Week1 Introduction Enterprise Database Systems

Week 1

Enterprise DB Architecture

1

Page 2: Week1 Introduction Enterprise Database Systems

2

In this lecture, you will learn

• What is an Enterprise Database System?

• Oracle Database Application Architectures

• Oracle Database Server Architecture

– Overview of the Physical DB Structure

– Overview of an Oracle Instance

• Tools for Oracle Administration

• Starting up and Shutting Down an Oracle DB Server

Page 3: Week1 Introduction Enterprise Database Systems

3

Readings • Required Readings

– Oracle Database Concepts (“Concepts”) • Chapter 1 Introduction to Oracle database

• Chapter 14 Memory Architecture

• Chapter 15Process Architecture

– Oracle Database Administrator's Guide, • Chapter 3 Starting Up and Shutting Down

• Further Readings – Oracle Database Concepts

• Chapter 6 Data Dictionary and Dynamic Performance Views

Page 4: Week1 Introduction Enterprise Database Systems

4

What is an Enterprise Database?

• Database (DB): Data and Metadata

• Database Management System (DBMS)

• Systems that provide services and tools for managing DBs

• Enterprise Database – Used by the Entire Organization

– Supports Many Users (more than 50, usually hundreds or thousands)

– Across Many Departments/Business Units and could be across countries

Page 5: Week1 Introduction Enterprise Database Systems

5

Oracle Database Application Architectures

• Client/Server Architecture – Client: initiates request and presents data to users

– Database server: runs Oracle software, stores data, receives and processes SQL and PL/SQL statements that originate from clients

• Multitier Architecture with Application Server(s) – Client: initiates a request and presents data to users

– Application server(s): interfaces between clients and multiple database servers, provide additional features on top of the database servers

– Database server(s): runs Oracle software, stores data, receives and processes SQL and PL/SQL statements that originate from clients and

application servers. DB

Page 6: Week1 Introduction Enterprise Database Systems

6

Oracle Client/Server Architecture

Page 7: Week1 Introduction Enterprise Database Systems

7

Multitier Architecture with Application Server(s)

http://docs.oracle.com/database/121/CNC

PT/dist_pro.htm#CNCPT702

Page 8: Week1 Introduction Enterprise Database Systems

8

Oracle Database Server Architecture

• An Oracle database server architecture contains:

– Database

– User Processes

– Server Processes

– Oracle Instance

– Other files and memory structures

Page 9: Week1 Introduction Enterprise Database Systems

9

Oracle Database Server Architecture (Diagram)

Page 10: Week1 Introduction Enterprise Database Systems

10

Physical Database Structures • Data files:

– contain all the database data

• Control files: – contain entries that specify the physical structure of the database

• Redo log files: – contain redo entries

• Archived log files: – contain archived redo log entries

• Parameter file: – contains a list of configuration parameters for an instance and the database

• Alert and trace log files: – contains a chronological log of alter and error messages

• Backup files: – contain backup copies of database files

Further details of the Oracle Physical Database Structures can be found in Oracle Documentation.

Page 11: Week1 Introduction Enterprise Database Systems

11

Oracle Instance

• An Oracle instance is the part of an Oracle database executing in memory when an Oracle database is running (after start up)

• An Oracle instance consists of memory structures called the

System Global Area (SGA) and the Background Processes

Page 12: Week1 Introduction Enterprise Database Systems

Oracle Instance

12

Page 13: Week1 Introduction Enterprise Database Systems

13

Oracle Instance: Memory Structure (Diagram)

http://docs.oracle.com/database/121/CNC

PT/memory.htm#CNCPT7778

Page 14: Week1 Introduction Enterprise Database Systems

14

Oracle Instance: Memory Structure

• The two major memory structures associated with an Oracle instance are: • System Global Area (SGA)

– private to each Oracle instance, allocated when the Oracle instance is started, de-allocated when the Oracle instance is shut down.

– shared by multiple server and background processes of the same Oracle instance – contains shared program code, cached data, information about connected sessions,

database server parameters – stores data in memory to minimize disk I/O – SGA_MAX_SIZE in the initialization parameter file determines the maximum size of the

SGA – SGA_TARGET: a dynamic parameter that Oracle uses to determine the total size of the

SGA components.

• Program Global Area (PGA) – private to each Oracle server processes – configuration depends on the Oracle Server connection configuration

• shared server or dedicated server

Page 15: Week1 Introduction Enterprise Database Systems

15

Oracle Instance: Memory Structure, Major Components

• Database Buffer Cache – stores the most recently used blocks of data

– caches data that is kept in memory, less disk I/O is needed, improved performance

• Redo Log Buffer – stores redo entries - a log of changes made to the database

• Shared Pool – contains shared SQL areas

– each SQL statement has its own shared SQL area

• stores parse tree and execution plan

• shared by multiple applications that issue the same statement

Page 16: Week1 Introduction Enterprise Database Systems

16

Oracle Instance: Memory Structure, SGA

• The size of the SGA is determined by several initialization parameters. The following parameters have the greatest effect on SGA size: – DB_CACHE_SIZE: specifies the size of the cache of standard blocks. – LOG_BUFFER: specifies the number of bytes allocated for the redo log

buffer. – SHARED_POOL_SIZE: specifies the size in bytes of the area devoted to

shared SQL and PL/SQL statements. – LARGE_POOL_SIZE: specifies the size of the large pool, the default is 0. – JAVA_POOL_SIZE: specifies the size of the Java pool.

• If the value for SGA_MAX_SIZE in the initialization parameter file is less than the sum the memory allocated for all components, the database ignores the setting for SGA_MAX_SIZE.

Page 17: Week1 Introduction Enterprise Database Systems

17

User Process & Server Process • User Process

– starts when a database client application connects to an Oracle database server, it runs an Oracle user process

– a session is established for each client connection – each Oracle user can run multiple sessions at the same time

• Server Process – handles the request on behalf of the user process(s)

• parse and run SQL statements • read data from disk into shared database buffer in SGA

– has a process specific memory area called the Program Global Area (PGA)

• Program Global Area – PGA_AGGREGATE_TARGET: specifies the total memory size dedicated

to the PGA for an Oracle instance

Page 18: Week1 Introduction Enterprise Database Systems

18

Shared & Dedicated Server

• Dedicated Server Configuration – one-to-one relation between the number of user processes and server

processes.

– maybe inefficient, most of the time, the server processes are idle

– suitable for systems with long transactions

• Shared Server Configuration – a dispatcher directs multiple user session requests to a pool of shared

server processes

– idle server processes can pick up a request from a common queue

– suitable for systems with a large number of users

Page 19: Week1 Introduction Enterprise Database Systems

19

Oracle Using Dedicated Server Processes (Diagram)

Page 20: Week1 Introduction Enterprise Database Systems

20

Oracle Using Shared Server Processes (Diagram)

http://docs.oracle.com/database/121/CNC

PT/dist_pro.htm#CNCPT006

Page 21: Week1 Introduction Enterprise Database Systems

21

Oracle Instance: Background Processes

• Oracle is a multi-process system,the background processes in an Oracle instance can include: – Database Writer Process (DBWn)

– Log Writer Process (LGWR)

– Checkpoint Process (CKPT)

– System Monitor Process (SMON)

– Process Monitor Process (PMON)

– Recoverer Process (RECO)

– Job Queue Processes

– Archiver Processes (ARCn)

– Queue Monitor Processes (QMNn)

– Other Background Processes

http://docs.oracle.com/database/121/CNC

PT/process.htm#CNCPT9840

Page 22: Week1 Introduction Enterprise Database Systems

22

Oracle Instance: Background Processes (Diagram)

http://docs.oracle.com

/database/121/CNCP

T/process.htm#CNCP

T1245

Page 23: Week1 Introduction Enterprise Database Systems

23

Oracle Instance: Background Processes (DBWn)

• Database writer process (DBWn) writes the contents of memory (buffer) to permanent storage (file)

• DBWn ensures that a sufficient number of free buffers are available in the database buffer cache

• DBWn can perform batched (multi-block) writes to improve efficiency

Page 24: Week1 Introduction Enterprise Database Systems

24

Oracle Instance: Background Processes (LGWR)

• Log Writer Process (LGWR) manages the redo log buffer

• LGWR writes the redo log buffer (circular buffer) to the redo log file

• LGWR writes:

– At commit

– When redo log buffer one-third full

– Every 3 seconds

– Before DBWn writes

Page 25: Week1 Introduction Enterprise Database Systems

25

Oracle Instance: Background Processes

• Checkpoint Process (CKPT) – synchronizes all database files with the checkpoint

information

– signals DBWn to write the buffer cache to disk

– signals LGWR to update the datafile header and control files

• System Monitor Process (SMON) – performs recovery, if necessary, at instance startup

– cleans up temporary segments that are no longer in use

• Process Monitor Process(PMON) – performs process recovery when a user process fails

– cleans up the database buffer cache and frees up resources

• SMON and PMON perform automatic checks regularly to facilitate recovery. These can be called by other processes

Page 26: Week1 Introduction Enterprise Database Systems

26

Static Data Dictionary Views & Dynamic Performance(V$) Views

• Static Data Dictionary Views – ALL_: views a user can access (e.g., ALL_TABLES)

– USER_: views a user own (e.g., USER_TABLES)

– DBA_: views available to DBA only (e.g., DBA_TABLES)

• Dynamic Performance Views (V$) – accessible by the administrator user SYS

– continuously updated while a database is open and in use

– contents relate primarily to performance.

http://docs.oracle.com/database/121/CNCPT/datadict.htm#CNCPT1209

Page 27: Week1 Introduction Enterprise Database Systems

27

Some Useful Data Dictionary Views

• DESCRIBE V$SGA_DYNAMIC_COMPONENTS

– shows what columns are in the Data Dictionary view/table

– use a SELECT statement to get required information

Some Useful Data Dictionary Views

•V$DATABASE

•V$PARAMETER

•V$NLS_PARAMETERS

•V$SGA

•V$CONTROLFILE

•V$SGA_DYNAMIC_COMPONENTS

Page 28: Week1 Introduction Enterprise Database Systems

28

Oracle DB Administration & Application Development Tools

• Administration Tools: – Oracle Universal Installer (OUI): tool for installing, upgrading, or removing software

components – Database Configuration Assistant (DBCA): a graphical user interface tool that interacts

with the OUI, or can be used independently, to create, delete or modify a database – Database Upgrade Assistant: utility for upgrading an existing database to a new oracle

release – Oracle Net Manager: tool for configuring and managing Oracle database networks – Oracle Enterprise Manager: a graphical interface used to administer, monitor, and tune

one or more databases

• Application Development Tools: – SQL Developer: a graphical tool for database development, used to browse database

objects, run SQL, edit and debug PL/SQL – Oracle Application Express: a Web-based development tools for development of

database-centric web applications, used to create forms, reports and other web applications rapidly

Page 29: Week1 Introduction Enterprise Database Systems

29

Starting Up and Shutting Down a Database

• A database can be in one of the four stages when starting up or shutting down:

– SHUTDOWN

– NOMOUNT

– MOUNT

– OPEN

Page 30: Week1 Introduction Enterprise Database Systems

Starting Up a Database (2) NOMOUNT

OPEN

MOUNT

NOMOUNT

SHUTDOWN

System reads

the parameter

file, Instance

started

STARTUP

30

Page 31: Week1 Introduction Enterprise Database Systems

Starting Up a Database (3) MOUNT

OPEN

MOUNT

NOMOUNT

SHUTDOWN

Control file

opened for this

instance

STARTUP

SHUTDOWN

31

Page 32: Week1 Introduction Enterprise Database Systems

Starting Up a Database (4) OPEN

OPEN

MOUNT

NOMOUNT

SHUTDOWN

All files opened as

described by the control

file for this instance

Control file

opened for this

instance

System reads

the parameter

file, Instance

started

STARTUP

SHUTDOWN

32

Page 33: Week1 Introduction Enterprise Database Systems

33

Other Startup Options • Restricting Access to an Instance at Startup

– You can start an instance in restricted mode, so that it is available only to the database administrator • STARTUP RESTRICT

– Start the instance in restricted mode when: • performing an export or import of data • performing a data load • temporary preventing typical users from accessing data • performing migration or upgrade operations

• Forcing an Instance to Start – STARTUP FORCE – This command will first shut down the database with ABORT mode, and then

restart it. – Use STARTUP FORCE, only when

• cannot shut down the database with SHUTDOWN NORMAL, SHUTDOWN IMMEDIATE, or SHUTDOWN TRANSACTIONAL commands

• cannot startup the database with any other STRATUP mode

Page 34: Week1 Introduction Enterprise Database Systems

Shutting Down the Database

• Shutdown mode: – A = ABORT

– I = IMMEDIATE

– T = TRANSACTIONAL

– N = NORMAL

A

No

No

No

No

T

No

No

Yes

Yes

I

No

No

No

Yes

Shutdown Mode

Allow new connections

Wait until current sessions end

Wait until current transactions end

Force a checkpoint and close files

N

No

Yes

Yes

Yes

34

Page 35: Week1 Introduction Enterprise Database Systems

Shutdown and Startup a Clean Database

• On the way down: – Database buffer

cache is written to the data files

– Uncommitted changes rolled back

– Resources are released

• On the way up: – No instance

recovery

During

SHUTDOWN

NORMAL

or SHUTDOWN

TRANSACTIONAL

or SHUTDOWN

IMMEDIATE

Consistent database

(clean database)

35

Page 36: Week1 Introduction Enterprise Database Systems

Shutdown and Startup a Dirty Database

• On the way down: – Modified buffers

are not written to the data files

– Uncommitted changes are not rolled back

• On the way up: – Online redo log files are

used to reapply changes

– Undo segments are used to roll back uncommitted changes

– Resources are released

During

SHUTDOWN ABORT

or

Instance Failure

or STARTUP FORCE

Inconsistent database

(dirty database)

36

Page 37: Week1 Introduction Enterprise Database Systems

37

Revision Questions • What is an Enterprise Database System?

– How does it compare to a personal database system?

• What are the major components of an Oracle database server? – What physical files are associated with Oracle database? – What is an Oracle instance? – What are the major memory areas, and background processes?

• What are the differences between a shared and a dedicated connection configuration?

• What information can be found in the Oracle Data Dictionary? • What are the major administration and application development tools for

an Oracle database? • What are the possible options for starting up and shutting down an Oracle

database?