因为数据库系统为了提高性能, 需要大量的内存分配给data buffer和sort area, 所以用户都希望配置大量内存来实现性能上的飞跃. 但是在windows平台上由于Oracle使用的是一个服务进程内的众多线程来实现用户服务"进程"和后台"进程", 这些线程在32位系统上只能共享2G或者3G( /3GB)虚拟寻址空间. 由于微软提供了/3GB和/PAE功能, 使得用户可能使用接近63GB的虚拟内存, 所以如何配置系统和Oracle来实现大内存使用, 以及性能结果如何, 是很多windows平台上Oracle用户非常关心的问题. 以下所有windows平台仅限2000 和 2003 32bit, 除非特别说明. Source: http://www.microsoft-oracle.com/oracledb/Pages/Workshops.aspx
一 先介绍一下32bit windows对大内存的使用方式 一个32bit Windows系统的进程可以访问 4GB的地址空间, 但是这4GB空间又划分为用户地址空间和系统地址空间. 系统地址空间是所有进程共享的, 只有用户地址空间是用户程序真正能够分配和使用的. 一般情况下, 系统占2GB, 用户占2GB. Windows 提供了/3GB 选项可以压缩系统地址空间为1GB, 让用户地址空间为3GB. 如果机器配置了4GB以上的物理内存, 这是一个不错的选择. Windows还提供了/PAE (Physical Address Extension)选项, 在IA32机器上支持到64GB物理内存. 它使用36bit内存寻址方式. 需要应用程序使用AWE API来访问高端内存, 有一定的额外开销(Overhead). 主要是Mapping问题.(有点像我们在286上使用扩展内存). PAE 和AWE是解决同一个问题是用硬件技术和软件接口. AWE (Address Windowing Extension)是一套API, 用于访问4GB以外的内存, 只是为32位系统开发的. 使用AWE可以让高端内存Non paged out. 用户程序负责在自己地址空间内分配缺省1GB内存作为窗口来实现mapping or translation, 相应的内存开销和CPU使用都是overhead. 必须要求相应的32位硬件平台, 安装了大内存, 而且OS起用了PAE. 如果把/3GB和/PAE一起使用可以让用户使用尽可能多的4GB以内的内存, 但最多能访问16GB. 由于PAE/AWE需要mapping windows, 这个大小缺省是1GB(注册表项AWE_WINDOW_SIZE), 留给用户的只剩下1GB或者2GB (/3GB and /PAE), 而且还需要用户translation, 所以在物理内存是8GB PAE的情况下可能还不如4GB /NOPAE呢, 只有安装了12GB以上才开始显出性能上的改进. 总结一下: 物理内存 Boot.ini 开关 <4GB None (or /NOPAE) =4GB /3GB (or /3GB /NOPAE) >4GB & <=16GB /3GB and /PAE >16GB /PAE 在Windows2003上支持/NOPAE这样可以快一些. 只有以下这些系统支持如上选项: Windows 2000 Advanced Server Windows 2000 Datacenter Server Windows 2003 Enterprise Edition 32位x86机器上 最大内存限制: Windows 2003 Datacenter Edition Example of boot.ini with /3GB and /PAE for a system with more than 4GB and <=16GB (32-bit only): [boot loader] timeout=30 default=multi(0)disk(0)rdisk(0)partition(2)WINDOWS [operating systems] multi(0)disk(0)rdisk(0)partition(2)WINDOWS="Windows Server 2003, Enterprise" /fastdetect /3GB /PAE 二 Oracle对大内存的使用方式 Oracle.exe使用的是同一用户地址空间来实现SGA和PGA, 只是作为一个正常的User进程在系统中运行(User Thread Mode). 所以所有的oracle进程(shadow进程和background进程)使用的内存局限在一个windows进程内部,就是2GB或者3GB的最大值. 另外只有data buffer可以使用4GB以上的内存,只解决了访问数据文件速度的问题(相当于提高了硬盘的速度,如果我的硬盘系统也有32GB的cache,这个不用也罢,虽然算法不是很一样),对于sort area这个也很重要的区域无能为力. As a result, Oracle on 32-bit systems is severely restricted on the number of user connections supported n100s ? low thousands (5000?)with Shared Servers AWE mapping window占用了4gb内的内存,从Oracle系统的角度你可以减少PGA或UGA对内存的使用: Oracle initialization parameters can be used to decrease per user memory usage bitmap_merge_area_size create_bitmap_area_size hash_area_size open_cursors sort_area_size (sort_area_retained_size) The Orastack command can be used to decrease memory use per thread Default allocation is 1 MB Risky to decrease below 700KB; any change must be tested Example usage: orastack oracle.exe 700000 orastack tnslsnr.exe 700000 orastack svrmgrl.exe 700000 orastack sqlplus.exe 700000 这样做的代价可想而知. 我觉得这样做对用户不多的联机交易系统或者用户更少的DSS系统也许有好的作用. 三 Oracle AWE的实现 Setting up AWE for Oracle just takes a few extra steps. First, the /PAE flag is set in the boot.ini file. In addition, two entries are edited in the init.ora file or spfile. These are the “USE_INDIRECT_BUFFERS=TRUE” parameter and the use of the DB_BLOCK_BUFFERS parameter instead of the DB_CACHE parameter. By default, a registry parameter ? AWE_WINDOW_SIZE is set to map low memory to high memory. The default window size is 1 GB. The user account under which Oracle Database runs ( typically the LocalSystem account), must have the "Lock memory pages" Windows 2000/2003 and XP privilege. Dynamic SGA and multiple block size are not supported with VLM. Only DB_BLOCK_SIZE and DB_BLOCK_BUFFERS are in effect. Increasing the value of AWE_WINDOW_MEMORY will improve the performance especially when DB_BLOCK_SIZE is set largerk the default AWE_WINDOW_MEMORY value of 1GB may not be sufficient to start the database. The database startup fails without of memory error 27102 and 34. Increase the value of AWE_WINDOW_MEMORY by 20 percent when needed. Having a large cache in a VLM configuration may also slow down database write threads. Having more DBWR threads will distribute work required to identify and write buffers to disk and will distribute I/O loads among threads. Initialization parameter DB_WRITER_PROCESS enables you to configure multiple database writer threads. A large cache can also incur contention on the LRU latch. On SMPs, Oracle sets the number of LRU latches to a value equal to 1/2 of process number. You can reduce contention by increasing the number to twice or four times of the process number on the system. 四 专家的建议 如果你真的需要16GB以上的内存,就用64位系统,否则就用/3Gb还是不错的选择.如果系统有些慢,换好一点的硬盘系统,再从调优角度下点功夫.
|