天天看點

我的oracle 9i學習日志(2)--記憶體結構

oracle記憶體結構包括兩個區域:SGA和PGA.

SGA(system global area):

<a href="http://luotaoyang.blog.51cto.com/attachment/201002/20/545649_12666623808QD7.png"></a>

SGA有叫共享全局區域(shared global area)。在instance啟動時被配置設定,用來存儲資料庫程序共享資訊,包括資料和控制資訊。主要組成包括:

       – Shared Pool 

       – Database Buffer Cache 

       – Redo Log Buffer 

       – Other structures (for example, lock and latch management, statistical data)

還有兩個可選項: Large Pool, Java Pool。

下面語句可以檢視SGA的配置設定情況:

SQL&amp;gt; SHOW SGA; 

Total System Global Area 36437964 bytes 

Fixed Size 6543794 bytes 

Variable Size 19521536 bytes 

Database Buffers 16777216 bytes 

Redo Buffers 73728 bytes

從9i開始,可以在不關閉instance的情況下動态調整SGA的大小,這樣Database Buffer Cache, Shared Pool, 和Large Pool可以動态的調整而不需要關閉instance。

SGA的大小主要由以下幾個參數決定:

SGA_MAX_SIZE:規定了SGA的最大值。

DB_CACHE_SIZE:cache标準的塊大小,預設Unix 48M,NT 52M。

LOGG_BUFFER:redo log buffer的大小,機關Byte。

SHARED_POOL_SIZE, LARGE_POOL_SIZE, JAVA_POOL_SIZE。

SGA有一個配置設定粒度稱為granule,預設大小為 4 MB如果 SGA_MAX_SIZE&amp;lt; 128 MB,其他情況則為 16 MB 。

The minimum SGA configuration is three granules (one granule for fixed SGA 

[includes redo buffers]; one granule for Database Buffer Cache; one granule for Shared Pool).

各元件介紹:

shared pool

包括library cache和data dictionary cache,分别用于存儲最近執行過的編譯解釋後的SQL語句和最近用到的資料資訊(資料字典)。

可以通過這條指令ALTER SYSTEM SET SHARED_POOL_SIZE = 64M;動态修改SHARED_POOL_SIZE的值。

Database Buffer Cache

最大的一塊記憶體,用于緩存從資料檔案裡讀出的資料和被更新的資料,能有效地增強資料庫伺服器的性能。

可以通過下面的指令動态改變它的大小:ALTER SYSTEM SET DB_CACHE_SIZE = 96M;

Buffer Cache Advisory功能,收集統計對于不同大小的Database Buffer Cache所表現出來的性能的資訊,并在V$DB_CACHE_ADVICE這個視圖中列出。

The Buffer Cache Advisory is enabled via the DB_CACHE_ADVICE initialization 

parameter. It is a dynamic parameter, and can be altered using ALTER SYSTEM. Three values (OFF, ON, READY) are available. 

DB_CACHE_ADVICE Parameter Values 

OFF: Advisory is turned off and the memory for the advisory is not allocated. 

ON: Advisory is turned on and both cpu and memory overhead is incurred. 

Attempting to set the parameter to the ON state when it is in the OFF state may lead to the following error: ORA-4031 Inability to allocate from the Shared Pool when the parameter is switched to ON. If the parameter is in a READY state it can be set to ON without error because the memory is already allocated. 

READY: Advisory is turned off but the memory for the advisory remains allocated. Allocating the memory before the advisory is actually turned on will avoid the risk of ORA-4031. If the parameter is switched to this state from OFF, it is possible that an ORA-4031 will be raised.

Redo Log Buffer

記錄所有的資料庫資料塊的改變記錄,主要目的用于恢複。

每條記錄被稱為重做條目,重做條目包含恢複資訊或改變資訊(information to econstruct or redo changes)。

Large Pool

可選項,緩解shared pool的負擔,用于

– Session memory (UGA) for the Shared Server 

– I/O server processes 

– Backup and restore operations or RMAN(Recovery Manager) 

– Parallel execution(并行處理) message buffers 

               PARALLEL_AUTOMATIC_TUNING set to TRUE

Java Pool

對Java的支援,如解釋執行Java編寫的存儲過程。

Program Global Area(PGA)

PGA是一塊記憶體區域,包含了單個server process或單個background process資訊的資料和控制資訊。當程序開始運作時PGA被配置設定,當程序結束時PGA被回收。與共享方式的SGA相對比,PGA是一個程序一塊記憶體。注意:oracle的server process和background process是嚴格區分的。

本文轉自 d185740815 51CTO部落格,原文連結:http://blog.51cto.com/luotaoyang/277173,如需轉載請自行聯系原作者