oracle Memory Management 改进
Automatic Memory Management (AMM) 在ORACLE 11g中被引入,这是从OS级别内存管理的重大改变,回顾ORACLE的版本更新历程,内存管理也在逐步的更新
从ORACLE9I时的pga_aggregate_target 单一的参数统一控制了SORT_AREA,HASH_AREA等小POOL的分配
再到ORACLE10G时的ASMM,也是把shared_pool,buffer_cache等内存分配上升到了一个独立的POOL,有ORACLE自己调配各sub-pool的大小,只要指定sga_target和sga_max_target.
手动指定的方式还是保留,但只是作为自动调整时的下限
到了ORACLE11G,有了更大的改进,那就是把整个实例的内存都可以交给ORACLE现管理就是上面提到的AMM,只需要指定memory_target and memory_max_target. 系统参数,PGA and SGA就有一个大的pool来自由支配。
在oracle10G及以前的版本oracle用的是一种叫做 system v-style shared memory,可以用unix工具查看已存在的共享内存区大小比如ipcs
sys@ANBOB>select * from v$version where rownum=1; BANNER ---------------------------------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod sys@ANBOB>exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options [oracle@dbserver1 ~]$ ipcs -m ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x4f2dd44c 2752517 oracle 640 1052770304 18
可以看到分配了1052770304bytes的共享内存段
NATTCH 列The number of processes attached to the associated shared memory segment [oracle@dbserver1 ~]$ ps -ef|grep 'ora_'|grep -v 'grep ora_' oracle 29391 1 0 11:07 ? 00:00:00 ora_pmon_anbob oracle 29393 1 0 11:07 ? 00:00:00 ora_psp0_anbob oracle 29395 1 0 11:07 ? 00:00:00 ora_mman_anbob oracle 29397 1 0 11:07 ? 00:00:00 ora_dbw0_anbob oracle 29399 1 0 11:07 ? 00:00:00 ora_lgwr_anbob oracle 29401 1 0 11:07 ? 00:00:02 ora_ckpt_anbob oracle 29403 1 0 11:07 ? 00:00:01 ora_smon_anbob oracle 29405 1 0 11:07 ? 00:00:00 ora_reco_anbob oracle 29407 1 0 11:07 ? 00:00:01 ora_cjq0_anbob oracle 29409 1 0 11:07 ? 00:00:02 ora_mmon_anbob oracle 29411 1 0 11:07 ? 00:00:00 ora_mmnl_anbob oracle 29413 1 0 11:07 ? 00:00:00 ora_d000_anbob oracle 29415 1 0 11:07 ? 00:00:00 ora_s000_anbob oracle 29419 1 0 11:07 ? 00:00:00 ora_qmnc_anbob oracle 29425 1 0 11:07 ? 00:00:00 ora_q000_anbob oracle 29429 1 0 11:07 ? 00:00:00 ora_q002_anbob oracle 29431 1 0 11:07 ? 00:00:31 ora_j000_anbob oracle 30793 1 0 16:07 ? 00:00:00 ora_j001_anbob
因为没有客户端连接目前这有这些后台进程(目前18个)
[oracle@dbserver1 ~]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda5 64G 14G 47G 24% / /dev/sda3 965M 61M 855M 7% /tmp /dev/sda1 99M 12M 83M 12% /boot tmpfs 1010M 0 1010M 0% /dev/shm /dev/hdb 2.9G 2.9G 0 100% /mnt/cdrom
我们再看下11G的
[oracle@rac1 ~]$ ora SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 4 01:51:45 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production With the Partitioning, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options sys@ANBOB>show parameter memory_target NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ memory_target big integer 500M [oracle@rac1 ~]$ ipcs -m ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x714f0ec4 32768 grid 660 4096 0 0x49b6ab3c 98305 oracle 660 4096 0 [oracle@rac1 ~]$ ps -ef|grep ckpt grid 5172 1 0 01:23 ? 00:00:00 asm_ckpt_+ASM oracle 5570 1 0 01:47 ? 00:00:00 ora_ckpt_anbob oracle 5804 5353 0 01:57 pts/0 00:00:00 grep -i ckpt
因为我是在GRID用户下运行的ASM,ORACLE用户下是ORACLE RDBMS,所以目前分配两个内存段。但是得注意,每个内存段仅4K,且nattach为0
当给实例指定了memory_target参数11G使用了操作系统的另一种叫做Posix-Style shared memory management,这种管理方式把共享内存分成了更小的颗粒,也实现了从PGA分配的内存转给SGA或反分配,如果用posix-style那ipcs就不可用了,取而代之的是一种叫shmfs 或才tmpfs虚拟文件系统管理,它们必须mount到/dev/shm下
[oracle@rac1 ~]$ df -m /dev/shm Filesystem 1M-blocks Used Available Use% Mounted on tmpfs 1500 482 1019 33% /dev/shm [oracle@rac1 ~]$ ls -l /dev/shm total 493332 -rw-r----- 1 oracle asmadmin 4194304 Jun 4 01:46 ora_anbob_98305_0 -rw-r----- 1 oracle asmadmin 4194304 Jun 4 01:46 ora_anbob_98305_1 -rw-r----- 1 oracle asmadmin 0 Jun 4 01:48 ora_anbob_98305_10 -rw-r----- 1 oracle asmadmin 4194304 Jun 4 01:46 ora_anbob_98305_100 -rw-r----- 1 oracle asmadmin 4194304 Jun 4 01:46 ora_anbob_98305_101 -rw-r----- 1 oracle asmadmin 4194304 Jun 4 01:46 ora_anbob_98305_102 -rw-r----- 1 oracle asmadmin 4194304 Jun 4 01:46 ora_anbob_98305_103 -rw-r----- 1 oracle asmadmin 4194304 Jun 4 01:46 ora_anbob_98305_104 -rw-r----- 1 oracle asmadmin 4194304 Jun 4 01:46 ora_anbob_98305_105 ....... -rw-r----- 1 grid oinstall 4194304 Jun 4 01:23 ora_+ASM_32768_0 -rw-r----- 1 grid oinstall 0 Jun 4 01:23 ora_+ASM_32768_1 -rw-r----- 1 grid oinstall 0 Jun 4 01:23 ora_+ASM_32768_10 -rw-r----- 1 grid oinstall 0 Jun 4 01:23 ora_+ASM_32768_11 -rw-r----- 1 grid oinstall 0 Jun 4 01:23 ora_+ASM_32768_12
每个文件的粒度分0,4MB,16MB三种,当memory_max_target>1024时,颗粒为16MB,否则为4MB,当是0时,就好比虽然现在连接的是PGA,但随时有可以转为SGA
系统环境的工具可以用fuser或者pmap,
[oracle@rac1 ~]$ su - root Password: [root@rac1 ~]# /sbin/fuser -v /dev/shm/ora_anbob_98305_99 USER PID ACCESS COMMAND /dev/shm/ora_anbob_98305_99: oracle 5548 ....m oracle oracle 5550 ....m oracle oracle 5554 ....m oracle oracle 5556 ....m oracle oracle 5558 ....m oracle oracle 5560 ....m oracle oracle 5562 ....m oracle oracle 5564 ....m oracle oracle 5566 ....m oracle oracle 5568 ....m oracle oracle 5570 ....m oracle oracle 5572 ....m oracle oracle 5575 ....m oracle oracle 5577 ....m oracle oracle 5581 ....m oracle oracle 5583 ....m oracle oracle 5585 ....m oracle oracle 5589 ....m oracle oracle 5591 ....m oracle oracle 5601 ....m oracle oracle 5665 ....m oracle oracle 5668 ....m oracle oracle 5670 ....m oracle oracle 5685 ....m oracle oracle 5774 ....m oracle oracle 6243 ....m oracle oracle 6836 ....m oracle oracle 6838 ....m oracle [root@rac1 ~]# pmap 5548|grep 98305_99 38c00000 4096K rwxs- /dev/shm/ora_anbob_98305_99
note:
可以11G的这种内存管理方式更加灵活,11G的是新的里程碑。
SUMMARY
ASMM is supported with LINUX x86-64 Hugepages but AMM is not supported with Hugepages.
对不起,这篇文章暂时关闭评论。