Oracle的服务器的物理结构有实例和数据库两部分组成:
一、实例(Instance)。
An Oracle Instance consists of Memory structure and Background process ,is a mean to access an Oracle Database 。
An oracle instance always opens one and only one database .
1)内存结构:SGA--System Global Area (系统级共享):
Database buffer cache (默认缓存,保持缓存,再生缓存);
Redo log buffer cache ;
Shared pool--(Library cache(shared SQL,PL/SQL area) ;Data Dictionary cache(row cache)) ;
# Large pool ;
# Java pool 。
show sga 查看内存结构的信息。
show parameter sga 系统全局区大小(SGA_MAX_SIZE)
show parameter shared 共享池大小
show parameter db_cache 数据缓存大小
show parameter log_buffer 日志缓存大小
在不超过 SGA_MAX_SIZE 的情况下,可以动态调整 共享池、数据缓存、日志缓存的大小。
alter session set nls_language=american;
alter system set db_cache_size=90m;
alter system set db_cache_advice=on;根据系统运行情况给出分配内存的建议。
alter system set shared_pool_size=64m;此值决定Lib.cache和Dic.cache的大小,它们本身不可调整。
alter system set log_buffer=20m;
large_pool_size ; java_pool_size .
PGA--Program Global Area (针对某一个系统进程)。依据系统是共享服务器还是独占服务器的模式不同,PGA 的内容不同。
独占:Stack space ;sort area ;cursor information ;Session information .
共享:Stack space ;sort area ;cursor information .
此时 Session information 在 SGA 中。
2)后台进程:
****************************************
DBWn(db write process),writes when :
Checkpoint ; Dirty buffers threshold reached ; No free buffers ; Timeout ; Tablespace offline ; Tablespace read only ; Table DROP or TRUNCATE ; Tablespace BEGIN BACKUP ; RAC ping request.
*****************************************
LGWR(Redo etc.),writes
At commit ; When 1/3 full ; When there is 1 MB of redo ; Every 3 seconds ; Before DBWn writes .
*****************************************
SMON(System Monitor Process)
*****************************************
PMON(process cleanup)
*****************************************
CKPT(checkpoint)
*****************************************
RECO(distributed recovery)
*****************************************
ARCn (Archival Process n)
*****************************************
select * from v$bgprocess ; 查看所有的后台进程
select * from v$bgprocess where paddr<>'00'; 查看必需的后台进程。
二、数据库(Database)。
Database是物理的存在,是为了某一个特定的目的而组织在一起的数据集合。
# Parameter files ;Password files ;Archived log files ;
Data files ;Control files ;Redo log files 。
Control files 是用来连接 Instance 和 Database 的。
select name from v$controlfile;
select name from v$datafile;
select member from v$logfile;
User process --> Server process --> Instance --> Database .
Oracle 的逻辑结构:Data file --> Tablespace --> Segment --> Extent --> Block .