oracle architecture overview

oracle體系結構包括以下幾個方面:oracle server、oracle instance、oracle database

oracle server是數據庫管理系統dbms,由instance和databse組成,提供開放、廣泛、集成的信息管理

oracle instance由memory和bg進程組成,是訪問數據庫的手段,memory主要包括SGA系統全局區

oracle database主要包括data file、redo log file、control file

memory structure主要由SGA、PGA組成:

當instance啓動時SGA分配,SGA用來存儲被database process共享的數據庫信息,包括shared pool、database buffer cache、redo log buffer、large pool、java pool等,是動態的,大小由sga_max_size參數設定,SGA動態分配跟蹤最小單元是guanule,guanule大小由SGA大小決定,如果SGA小於128M,granule大小爲4M,如果SGA大於128M,granule爲16M,也和OS有關,如32-bit WinX的平臺,如果SGA大小大於128M,granule大小爲8M。


shared pool用來存儲最近執行的SQL語句和最近使用的數據定義,由library cache和data dictionary cache組成,大小由shared_pool_size決定,可使用alter system set命令修改library cache存儲最近使用的SQL、PL/SQL語句,通過LRU最近最少使用算法管理。

data dictionary cache包括data files、tables、indexes、columns、users、privileges和其他數據庫對象,在parse phase解析階段,server進程在DD中查找信息進行解析對象名和驗證訪問validate access,內存中緩存數據字典信息能提高在查詢和DML上的響應時間。


database buffer cache存儲從data files檢索到的數據塊拷貝,獲取更新數據時有很大性能提升。大小由db_block_size決定,LRU算法管理。db buffer cache由db_cahce_size、db_keep_cache_size、db_recycle_cache_size3個獨立的子緩存組成,統計信息可查v$db_cache_advice,db_cache_advice設置用來收集統計信息預測不同緩存大小行爲。

redo log buffer記錄所有數據塊的改變,修改記錄稱爲redo entries,redo entries包含reconstruct重建或redo重做changes信息,大小由log_buffer決定,recovery時用。


large pool緩解shared pool中的負擔,用來作爲共享服務器的會話內存session memory(UGA)、server processes I/O操作、備份恢復RMAN、並行執行消息緩存(paralle_automatic_tuning=true)。不使用LRU list,大小由large_pool_size決定,能動態調整resize。


java pool解析java請求命令,安裝使用java時需要,大小由java_pool_size決定


PGA(Program Global Area):內存保留爲每一個用戶進程連接oracle數據庫,當server process啓動時PGA分配空間,當process終結terminate時回收deallocate


進程分3種:user process、server procss、background process

user process:用戶和oracle server建立連接connection

server process:分爲dedicated和shared兩種,在dedicated環境裏server process處理單獨一個用戶請求,在shared環境裏server process處理幾個用戶請求,server process通過OPI(Oracle Program Interface)和Oracle server通信。

background process:維護執行物理和內存結構間的關係,5個必備:DBWn、PMON、SMON、LGWR、CKPT,可選的有ARCn:ARChiver、QMNn:Queue Monitor Process、CJQ0:Coordinator Job Queue、RECO:RECOverer、Dnnn:Dispatcher、Snnn:Shared Server、LCKn:LoCK、Pnnn:Parallel query slaves、

RAC中用到的LMS:Lock Manager Server、LMON:Lock MONitor、LMDn

補充 RAC 環境啓動時,各個進程的啓動順序:

PMON started with pid=2, OS id=18042

DIAG started with pid=3, OS id=18044

PSP0 started with pid=4, OS id=18051

LMON started with pid=5, OS id=18053

LMD0 started with pid=6, OS id=18055

LMS0 started with pid=7, OS id=18057

MMAN started with pid=8, OS id=18061

DBW0 started with pid=9, OS id=18063

LGWR started with pid=10, OS id=18065

CKPT started with pid=11, OS id=18067

SMON started with pid=12, OS id=18069

RECO started with pid=13, OS id=18071

CJQ0 started with pid=14, OS id=18073

MMON started with pid=15, OS id=18075

MMNL started with pid=16, OS id=18077


DBWn:將dirty data從db buffer cache寫到data files,DBWn寫條件:檢查點發生、dirty buffers達到臨界值threshold、沒有free buffers、超時、表空間offline或read only或begin backup、表drop或truncate、RAC ping發生

LGWR:按順序從redo log buffer寫到redo log files,寫條件:commit、log buffer1/3滿、1M修改記錄在redo log buffer、每3秒、在DBWn寫前

SMON:負責instance recovery:前滾變化redo buffer、回滾未提交事務、爲用戶訪問打開數據庫,合併coalesce空閒空間,釋放臨時segments

PMON:在failed processes後通過回滾事務、釋放鎖、其他資源、重啓dead dispatchers 清理

CKPT:負責給DBWn信號,更新數據文件頭和控制文件



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章