oracle 功能结构组件
DESCRIPTION
Oracle 功能结构组件. 目标. 学完这个课程,你应该可以掌握你下内容: Oracle 体系结构的概念和它的主要组件 List the structures involved in connecting a user to an Oracle Instance. Password file. Overview of Primary Components. Instance. User process. SGA. Shared Pool. Database Buffer Cache. Redo Log Buffer. Library Cache. - PowerPoint PPT PresentationTRANSCRIPT
1Copyright © Oracle Corporation, 2001. All rights reserved.
Oracle 功能结构组件
1-2 Copyright © Oracle Corporation, 2001. All rights reserved.
目标学完这个课程,你应该可以掌握你下内容 :• Oracle 体系结构的概念和它的主要组件• List the structures involved in connecting a user to
an Oracle Instance
1-3 Copyright © Oracle Corporation, 2001. All rights reserved.
Passwordfile
Overview of Primary ComponentsInstance
SGA
Redo LogBuffer
Shared Pool
Data DictionaryCache
LibraryCache
DBWRSMONPMON CKPTLGWR Others
Userprocess
Serverprocess
PGA
Control filesDatafiles
Database
DatabaseBuffer Cache
Redo Log files
Java Pool Large Pool
Parameterfile
Archived Log files
1-5 Copyright © Oracle Corporation, 2001. All rights reserved.
Oracle Server
An Oracle server:• Is a database management
system that provides an open, comprehensive, integrated approach to information management
• 由 Oracle 数据库事例和 Oracle数据库组成
Oracle Server
1-6 Copyright © Oracle Corporation, 2001. All rights reserved.
Oracle 事例一个 Oracle 事例 :• 意味着访问和存取一个 Oracle database• 可以打开一个而且只有一个数据库• 由内存和后台进程组成
Background process structures
Memory structures
InstanceSGA
Redo LogBuffer
Shared Pool
Data DictionaryCache
LibraryCache
DBWRSMONPMON CKPTLGWR Others
DatabaseBuffer Cache
Java Pool Large Pool
1-7 Copyright © Oracle Corporation, 2001. All rights reserved.
建立连接和创建会话连接到一个 Oracle 事例 :• 建立一个用户连接• 创建一个会话
创建会话
Database user
用户进程
Serverprocess建立连接
Oracle Server
1-9 Copyright © Oracle Corporation, 2001. All rights reserved.
Oracle 数据库一个 Oracle 数据库 :• 是一个被看作是一个完整单元的数据集合• 由三种文件类型组成
Passwordfile
Parameterfile
Archived Log files
Control filesDatafiles
Redo Log files
Oracle Database
1-10 Copyright © Oracle Corporation, 2001. All rights reserved.
物理结构物理结构包含三种文件类型 :• 控制文件• 数据文件• 重做日志文件
Controlfiles
Datafiles(includes
Data Dictionary)
Header
OnlineRedo Log
files
1-11 Copyright © Oracle Corporation, 2001. All rights reserved.
内存结构Oracle 的内存结构由两个内存区域构成 如下所示 : • 系统全局区 System Global Area (SGA): 在事例启动时分配 , 而且是数据库事例最基本的组成部件• 程序全局区 Program Global Area (PGA): 在后台进程启动时分配
1-12 Copyright © Oracle Corporation, 2001. All rights reserved.
系统全局区 SGA
• SGA 由几个内存结构组成 :– Shared Pool– Database Buffer Cache– Redo Log Buffer – Other structures (for example, lock and latch
management, statistical data)• 还有两个额外的内存结构也可以配置在 SGA 中 :
– Large Pool– Java Pool
1-14 Copyright © Oracle Corporation, 2001. All rights reserved.
System Global Area
• SGA 是动态的• 由 SGA_MAX_SIZE 参数控制大小• 通过 SGA 组件来分配和跟踪的粒度
– 连续的虚拟内存分配– 分配粒度的大小取决于 SGA_MAX_SIZE 总的大小
1-15 Copyright © Oracle Corporation, 2001. All rights reserved.
共享池 Shared Pool
• 用来存储 :– 最经常被执行的 SQL 块和语句– 最经常被使用的数据定义
• 它由两个重要的和性能有关的内存结构组成 :– Library Cache– Data Dictionary Cache
• Sized by the parameter SHARED_POOL_SIZE
Shared Pool
DataDictionary
Cache
LibraryCache
ALTER SYSTEM SET SHARED_POOL_SIZE = 64M;
1-16 Copyright © Oracle Corporation, 2001. All rights reserved.
Library Cache
• 存储的信息是一些最经常使用的 SQL and PL/SQL 块和语句• Enables the sharing of commonly used statements• 被 least recently used (LRU) 算法来管理• 由两个结构组成 :
– Shared SQL area– Shared PL/SQL area
• 大小由 Shared Pool sizing 来决定
1-17 Copyright © Oracle Corporation, 2001. All rights reserved.
Data Dictionary Cache
• 在数据库中最经常被用到的定义集合• 包含的信息是有关 database files, tables, indexes,
columns, users, privileges, 和其他数据库对象• 在解析的整个阶段 , 数据库 server 进程在数据字典里寻找信息来解决对象的名字和有效性访问• 缓存数据字典的信息到内存中来提高对查询和 DML 语句的响应时间• 大小由 Shared Pool sizing 来决定
1-18 Copyright © Oracle Corporation, 2001. All rights reserved.
Database Buffer Cache
• 存储已经从数据库数据文件中复制的数据块的副本• 当你获得和修改数据时,从而获得最大的性能• 通过 LRU algorithm 来管理• DB_BLOCK_SIZE 决定 primary block size
Database BufferCache
1-19 Copyright © Oracle Corporation, 2001. All rights reserved.
Database Buffer Cache
• 由独立的 sub-caches 组成 :– DB_CACHE_SIZE– DB_KEEP_CACHE_SIZE– DB_RECYCLE_CACHE_SIZE
• 能够被动态调整
• DB_CACHE_ADVICE 为预测不同的 cache size 行为收集统计信息• 字典表 V$DB_CACHE_ADVICE 显示统计状态
ALTER SYSTEM SET DB_CACHE_SIZE = 96M;
1-21 Copyright © Oracle Corporation, 2001. All rights reserved.
Redo Log Buffer
• 记录所有数据库中数据块的变化• Primary purpose is recovery• Changes recorded within are called redo entries• Redo entries contain information to reconstruct
or redo changes• 大小由 LOG_BUFFER 来决定
Redo LogBuffer
1-22 Copyright © Oracle Corporation, 2001. All rights reserved.
Large Pool
• SGA 中一个可选的内存区域• Relieves the burden placed on the Shared Pool• Used for:
– Session memory (UGA) for the Shared Server– I/O server processes– Backup and restore operations or RMAN– Parallel execution message buffers
– PARALLEL_AUTOMATIC_TUNING set to TRUE• 不使用 LRU 列表• 大小由 LARGE_POOL_SIZE 决定
1-24 Copyright © Oracle Corporation, 2001. All rights reserved.
Java Pool
• Services parsing requirements for Java commands• 如果安装并且使用 java 才使用• 大小由 JAVA_POOL_SIZE 参数决定
1-25 Copyright © Oracle Corporation, 2001. All rights reserved.
Program Global Area
• 为每一个用户连接到数据库预先分配的内存• 在进程创建时分配• 在进程终止时释放• 进程独占方式使用
Userprocess
PGAServer
process
1-28 Copyright © Oracle Corporation, 2001. All rights reserved.
Process Structure
Oracle 利用各种类型的进程 :• User process: Started at the time a database user
requests 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
1-29 Copyright © Oracle Corporation, 2001. All rights reserved.
User Process
• 程序发出请求和 Oracle server 进行交互• 必须第一次建立连接 • 不和 Oracle server 直接交互
Database user
Serverprocess
Userprocess
Connectionestablished
1-30 Copyright © Oracle Corporation, 2001. All rights reserved.
Server Process
• 和 Oracle server 可以直接进行交互的程序• 完成调用生成的和返回的结果数据• 可以是专用也可以是共享 Server
Connection established Session created
Database user
Userprocess
Serverprocess
Oracle server
1-31 Copyright © Oracle Corporation, 2001. All rights reserved.
Background Processes
Maintains and enforces relationships between physical and memory structures• Mandatory background processes:
– DBWn PMON CKPT– LGWR SMON
• Optional background processes:– ARCn LMDn RECO– CJQ0 LMON Snnn– Dnnn Pnnn– LCKn QMNn
1-32 Copyright © Oracle Corporation, 2001. All rights reserved.
Database Writer (DBWn)
DBWn writes when:• Checkpoint 发生• 脏缓存达到极限• 没有空闲的缓存• Timeout 发生• RAC ping request is made• Tablespace OFFLINE• Tablespace READ ONLY• Table DROP or TRUNCATE• Tablespace BEGIN BACKUP
InstanceSGA
Control files
Datafiles Redo Log files
Database
DBWn
DatabaseBufferCache
1-33 Copyright © Oracle Corporation, 2001. All rights reserved.
Log Writer (LGWR)
LGWR writes:• At commit • When 1/3 full• When there is 1 MB of
redo• Every three seconds• Before DBWn writes
InstanceSGA
Control filesDatafiles
Redo Log files
Database
Redo Log
Buffer
DBWn LGWR
1-34 Copyright © Oracle Corporation, 2001. All rights reserved.
System Monitor (SMON)
负责 :• Instance recovery
– Rolls forward changes in redo logs
– Opens database for user access
– Rolls back uncommitted transactions
• 合并 free space• 释放 temporary
segments
Control filesDatafiles
Redo Log files
Database
InstanceSGA
SMON
1-35 Copyright © Oracle Corporation, 2001. All rights reserved.
Process Monitor (PMON)
清理由于以下现象引起的失败进程 :• Rolling back the
transaction• Releasing locks• Releasing other
resources• Restarting dead
dispatchersPGA area
InstanceSGA
PMON
1-36 Copyright © Oracle Corporation, 2001. All rights reserved.
Checkpoint (CKPT)
Responsible for:• Signaling DBWn at
checkpoints• Updating datafile
headers with checkpoint information
• Updating control files with checkpoint information
Control filesDatafiles
Redo Log files
Database
InstanceSGA
DBWn LGWR CKPT
1-37 Copyright © Oracle Corporation, 2001. All rights reserved.
Archiver (ARCn)
• 可选的后台进程• 当数据库为归档模式是,自动归档在线日志• 保存数据库中所有变化的记录
ARCn Archived Redo Log
filesControl
filesDatafiles Redo Log files
1-39 Copyright © Oracle Corporation, 2001. All rights reserved.
Logical Structure
• 规定数据库中的物理空间怎样被使用• 按层状划分为 tablespaces, segments, extents, and
blocks
Tablespace
DatafileSegment
BlocksExtent
Segment
1-42 Copyright © Oracle Corporation, 2001. All rights reserved.
处理 SQL 状态• Connect to an instance using:
– User process– Server process
• Oracle server 组件的使用依赖于 SQL statement 类型 :– Queries return rows– DML statements log changes– Commit ensures transaction recovery
• 一些 Oracle server 组件不参加 SQL statement 处理
1-44 Copyright © Oracle Corporation, 2001. All rights reserved.
总结In this lesson, you should have learned how to:• Explain database files: datafiles, control files, online
redo logs• Explain SGA memory structures: Database Buffer
Cache, Shared Pool, and Redo Log Buffer• Explain primary background processes:
DBWn, LGWR, CKPT, PMON, SMON• Explain the use of the background process ARCn• Identify optional and conditional background
processes• Explain logical hierarchy
1-45 Copyright © Oracle Corporation, 2001. All rights reserved.
Practice 1 Overview
This practice covers the following topics:• Review of architectural components• Structures involved in connecting a user to an
Oracle Instance
1-48 Copyright © Oracle Corporation, 2001. All rights reserved.