2.2.Oracle的内存的分配、回收
2.2.1.空闲列表和LRU链表
2.2.2.空闲内存分配和回收
2.2.3.Shared Pool的分配和回收
- SQL>
select * from v$sgastat -
2 where pool = 'shared pool' -
3 and name = 'free memory'; -
- POOL
NAME BYTES - ------------
-------------------------- ---------- - shared
pool free memory 18334468 -
- SQL>
- select
-
-
avg(v.value) shared_pool_size, -
-
greatest(avg(s.ksmsslen) - sum(p.ksmchsiz), 0) spare_free, -
-
to_char( -
-
100 * greatest(avg(s.ksmsslen) - sum(p.ksmchsiz), 0) / avg(v.value), -
-
'99999' -
-
) || '%' wastage -
- from
-
-
sys.x$ksmss s, -
-
sys.x$ksmsp p, -
-
sys.v$parameter v -
- where
-
-
s.inst_id = userenv('Instance') and -
-
p.inst_id = userenv('Instance') and -
-
p.ksmchcom = 'free memory' and -
-
s.ksmssnam = 'free memory' and -
-
v.name = 'shared_pool_size';
- SQL>
column kghlurcr heading "RECURRENT|CHUNKS" - SQL>
column kghlutrn heading "TRANSIENT|CHUNKS" - SQL>
column kghlufsh heading "FLUSHED|CHUNKS" - SQL>
column kghluops heading "PINS AND|RELEASES" - SQL>
column kghlunfu heading "ORA-4031|ERRORS" - SQL>
column kghlunfs heading "LAST ERROR|SIZE" - SQL>
select -
2 kghlurcr "RECURRENT_CHUNKS", -
3 kghlutrn "TRANSIENT_CHUNKS", -
4 kghlufsh "FLUSHED_CHUNKS", -
5 kghluops "PINS AND_RELEASES", -
6 kghlunfu "ORA-4031_ERRORS", -
7 kghlunfs "LAST ERROR_SIZE" -
8 from -
9 sys.x$kghlu -
10 where -
11 inst_id = userenv('Instance'); -
- RECURRENT_CHUNKS
TRANSIENT_CHUNKS FLUSHED_CHUNKS PINS AND_RELEASES ORA-4031_ERRORS LAST ERROR_SIZE - ----------------
---------------- -------------- ----------------- --------------- --------------- -
327 368 0 7965 0 0 -
865 963 2960 102138 0 0 -
1473 5657 96 20546 1 540 -
0 0 0 0 0 0 -
2.3.Oracle在UNIX下的内存管理
2.3.1.共享内存和信号量
参数名称 | 建议大小(各个平台的Oracle建议值可以去metalink上找) | 参数描述 |
SHMMAX | 可以得到的物理内存 (0.5*物理内存) | 定义了单个共享内存段能分配的最大数. SHMMAX |
SHMMIN | | 定义了单个共享内存段能分配的最小数. |
SHMMNI | 512 | 定义了整个系统共享内存段的最大数。 |
NPROC | 4096 | 系统的进程总数 |
SHMSEG | 32 | 定义了一个进程能获取的共享内存段的最大数. |
SEMMNS | (NPROC * 2) * 2 | 设置系统中的信号数. SEMMNS的默认值是128 |
SEMMNI | (NPROC * 2) | 定义了系统中信号集的最大数 |
SEMMSL | 与Oracle中参数processes大小相同 | 一个信号集中的信号最大数 |
SEMMAP | ((NPROC * 2) + 2) | 定义了信号映射入口最大数 |
SEMMNU | (NPROC - 4) | 定义了信号回滚结构数 |
SEMVMX | 32768 | 定义了信号的最大值 |
- $
sysdef | more
- $ipcrm
–m 851975
- $
ipcs -sop - IPC
status from /dev/kmem as of Thu Jul 6 14:44:16 2006 - T
ID KEY MODE OWNER GROUP - Semaphores:
- s
0 0x4f1c0139 --ra------- root root - ...
... - s
14 0x6c200ad8 --ra-ra-ra- root root - s
15 0x6d200ad8 --ra-ra-ra- root root - s
16 0x6f200ad8 --ra-ra-ra- root root - s
17 0xffffffff --ra-r--r-- root root - s
18 0x410c05c7 --ra-ra-ra- root root - s
19 0x00446f6e --ra-r--r-- root root - s
20 0x00446f6d --ra-r--r-- root root - s
21 0x00000001 --ra-ra-ra- root root - s
45078 0x67e72b58 --ra-r----- oracle oinstall
$ipcrm -s 45078
- $
ipcs -mop - IPC
status from /dev/kmem as of Thu Jul 6 10:32:12 2006 - T
ID KEY MODE OWNER GROUP NATTCH CPID LPID - Shared
Memory: - m
0 0x411c29d6 --rw-rw-rw- root root 0 899 899 - m
1 0x4e0c0002 --rw-rw-rw- root root 2 899 901 - m
2 0x4120007a --rw-rw-rw- root root 2 899 901 - m
458755 0x0c6629c9 --rw-r----- root sys 2 9113 17065 - m
4 0x06347849 --rw-rw-rw- root root 1 1661 9150 - m
65541 0xffffffff --rw-r--r-- root root 0 1659 1659 - m
524294 0x5e100011 --rw------- root root 1 1811 1811 - m
851975 0x5fe48aa4 --rw-r----- oracle oinstall 66 2017 25076
2.3.2.私有内存
2.3.3.SWAP的保留区
- >
swapinfo -mt -
Mb Mb Mb PCT START/ Mb - TYPE
AVAIL USED FREE USED LIMIT RESERVE PRI NAME - dev
4096 0 4096 0% 0 - 1 /dev/vg00/lvol2 - dev
8000 0 8000 0% 0 - 1 /dev/vg00/swap2 - reserve
- 12026 -12026 - memory
20468 13387 7081 65% - total
32564 25413 7151 78% - 0 -