`

突破Oracle for win2k的2G内存限制

 
阅读更多

....众所周知,在32位的操作系统如win2K上,操作系统能管理的内存为4GB(power(2,32) =<chmetcnv w:st="on" unitname="g" sourcevalue="4" hasspace="False" negative="False" numbertype="1" tcsc="0">4G</chmetcnv>) oracle使用的总内存有<chmetcnv w:st="on" unitname="g" sourcevalue="2" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">2G</span></chmetcnv>限制。目前大多数信息系统都能为数据库服务器配上<chmetcnv w:st="on" unitname="g" sourcevalue="4" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">4G</span></chmetcnv>物理内存甚至更多,但无论你为系统配置多大的物理内存,正常情况下都不能使oracle使用超过<chmetcnv w:st="on" unitname="g" sourcevalue="2" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">2G</span></chmetcnv>的内存(包含SGAPGA),从而造成系统资源浪费。那么,有没有什么办法能使运行在windows系统上的oracle使用超过<chmetcnv w:st="on" unitname="g" sourcevalue="2" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">2G</span></chmetcnv>的内存呢?windows 提供了一种叫4GT(<chmetcnv w:st="on" unitname="g" sourcevalue="4" hasspace="False" negative="False" numbertype="1" tcsc="0">4G</chmetcnv> Tuning)的技术,使得oracle使用超过<chmetcnv w:st="on" unitname="g" sourcevalue="2" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">2G</span></chmetcnv>(不超过<chmetcnv w:st="on" unitname="g" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">3G</span></chmetcnv>)的内存成为可能。而为了让应用程序使用更大的内存,还有一种PSE36的技术,可以让oracle使用超过<chmetcnv w:st="on" unitname="g" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">3G</span></chmetcnv>的内存。这里,只对我们使用4GT特性让oracle使用超过<chmetcnv w:st="on" unitname="g" sourcevalue="2" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">2G</span></chmetcnv>的内存进行讨论。

使用4GT特性的基本要求:
....
尽管可以在不超过<chmetcnv w:st="on" unitname="g" sourcevalue="2" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">2G</span></chmetcnv>物理内存的系统上使用4GT特性,但oracle并不推荐这种做法,因为这将会严重降低系统性能。以我的经验来讲,如果系统未安装<chmetcnv w:st="on" unitname="g" sourcevalue="4" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">4G</span></chmetcnv>物理内存,最好也不要使用这种方法来让oracle使用更多的内存。此外,在需要你的oracle使用超过<chmetcnv w:st="on" unitname="g" sourcevalue="2" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">2G</span></chmetcnv>的内存时,数据库服务器最好不要再运行其他的服务,以减小系统的压力,让oracle工作得更好。
....
另外,据MS的文档,4GT只能用于 Advanced Server , Datacenter版本上,Server 版以及 Professional 版不能使用4GT特性(实际上是不是也没有必要?<shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></path><lock aspectratio="t" v:ext="edit"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 15pt; HEIGHT: 15pt" type="#_x0000_t75" alt="大笑"><imagedata o:href="http://www.itpub.net/images/smilies/29.gif" src="file:///C:/DOCUME~1/hexiong/LOCALS~1/Temp/msohtml1/01/clip_image001.gif"></imagedata></shape>)

为什么4GT能让应用程序使用超过<chmetcnv w:st="on" unitname="g" sourcevalue="2" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">2G</span></chmetcnv>的内存
....
在正常情况下,windows系统对内存的分配是这样的:在内存地址0x00000000 0x7FFFFFFF之间的空间,交给应用程序使用,操作系统内核及其支持则使用内存地址 0x80000000 0xFFFFFFFF之间的空间。在使用4GT之后,操作系统将内核及其支持程序使用的内存地址空间压缩到 0xC0000000 0xFFFFFFFF之间,从而为应用程序出来<chmetcnv w:st="on" unitname="g" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">1G</span></chmetcnv>的空间。但是,仅仅出来了这<chmetcnv w:st="on" unitname="g" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">1G</span></chmetcnv>的空间还是不够的,还需要指定哪一个应用程序来使用这多出来的”<chmetcnv w:st="on" unitname="g" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0">1G</chmetcnv>空间,以及如何分配份额等。后面将结合具体的参数设置来讨论。为便于讨论,我们将正常情况下应用程序可以使用的<chmetcnv w:st="on" unitname="g" sourcevalue="2" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">2G</span></chmetcnv>内存(即地址在 0x00000000 0x7FFFFFFF 之间的内存)称作普通内存,而将windows “出来的<chmetcnv w:st="on" unitname="g" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">1G</span></chmetcnv>内存(地址在 0x80000000 0xBFFFFFFF之间)称作间接内存。

oracle使用超过<chmetcnv w:st="on" unitname="g" sourcevalue="2" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">2G</span></chmetcnv>内存,不超过<chmetcnv w:st="on" unitname="g" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">3G</span></chmetcnv>内存的具体设置步骤:
1
首先应卸载实例,关闭oracle服务。
2
打开操作系统<chmetcnv w:st="on" unitname="g" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">3G</span></chmetcnv>开关:
....
修改boot.ini文件,在启动windows项中添加 /<chmetcnv w:st="on" unitname="g" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0">3G</chmetcnv>参数。修改过后的boot.ini文件应该类似以下内容:

[boot loader]
timeout=8
default=multi(0)disk(0)rdisk(0)partition(1)/WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)/WINNT="Microsoft Windows 2000 Advanced Server" /<chmetcnv w:st="on" unitname="g" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0">3G</chmetcnv> /fastdetect

注意在启动win2K AdvServer的一栏里,多了一个 /<chmetcnv w:st="on" unitname="g" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0">3G</chmetcnv>参数。这个参数的作用,就是让windows启动时,将自己的内核及支持程序装载到内存地址 0xC0000000 0xFFFFFFFF 之间,给应用程序留出<chmetcnv w:st="on" unitname="g" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">3G</span></chmetcnv>的空间来。

3
修改oralce init.ora 文件
..1)
确定oracle的缓冲区及共享池大小,假设作如下定义:
........ db_block_size = 4096
........ db_block_buffers = 262144 #
缓冲区大小为<chmetcnv w:st="on" unitname="g" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">1G</span></chmetcnv>
........ share_pool_size = 314572800 # 使用<chmetcnv w:st="on" unitname="m" sourcevalue="300" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">300M</span></chmetcnv>共享池
..2)
添加下列各项内容:
........ use_indirect_data_buffers = true
........ #
告诉oracle可以使用间接内存(即可以使用windows让出来的<chmetcnv w:st="on" unitname="g" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">1G</span></chmetcnv>内存作为数据缓冲区)
........ pre_page_sga = true
........ #
oracle SGA锁定到内存中,不产生页面交换文件(8i的参数可能是lock_sga = true)
........ #
对于一个有<chmetcnv w:st="on" unitname="g" sourcevalue="4" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">4G</span></chmetcnv>物理内存的系统来讲,可能这一个参数并不是必须的

4
修改注册表,定义oracleDBbuffer使用常规内存大小
....
在注册表 /Hkey_Local_Machine/software/oracle/home0 中添加一个二进制值,名称为AWE_WINDOW_MEMORY ,值的单位为字节,大小为你需要让oracle使用普通内存作为缓存的大小(不是windows让出来的<chmetcnv w:st="on" unitname="g" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">1G</span></chmetcnv>,而是内存地址在0x00000000 0x7FFFFFFF 之间的内存大小)。假如设为209715200,即<chmetcnv w:st="on" unitname="m" sourcevalue="200" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">200M</span></chmetcnv>大小,那么oracle的数据缓冲区将占用<chmetcnv w:st="on" unitname="m" sourcevalue="200" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">200M</span></chmetcnv>的普通内存,其余部分(<chmetcnv w:st="on" unitname="g" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0">1G</chmetcnv> - <chmetcnv w:st="on" unitname="m" sourcevalue="200" hasspace="False" negative="False" numbertype="1" tcsc="0">200M</chmetcnv> = <chmetcnv w:st="on" unitname="m" sourcevalue="824" hasspace="False" negative="False" numbertype="1" tcsc="0">824M</chmetcnv>)则使用间接内存。

5
重新启动操作系统,启动数据库。OK,你现在的 oracle 可以使用<chmetcnv w:st="on" unitname="g" sourcevalue="2" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">2G</span></chmetcnv> + <chmetcnv w:st="on" unitname="m" sourcevalue="824" hasspace="False" negative="False" numbertype="1" tcsc="0">824M</chmetcnv>内存了。

几个补充讨论
1 windows
系统出来的<chmetcnv w:st="on" unitname="g" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">1G</span></chmetcnv>间接内存,只能用于数据缓冲区
....
4GT特性测试中发现,间接内存只能用于数据缓冲区,而不能用于共享池,也不能分配给用户作为PGA。或许有其他的参数可以定义,但我查到的文献中没有任何一篇讲间接内存可以用于哪些地方,而在我们的测试中发现按上面的修改后,间接内存只能用于数据缓冲区。此结论只作为一个经验,不是定论,请各位大侠补充修正。

2
注册表中 AWE_WINDOW_MEMORY 参数大小的定义
....
这个参数定义缓冲池使用普通内存的大小,不能太小。在数据块大小为4K,缓冲池为<chmetcnv w:st="on" unitname="g" sourcevalue="1" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">1G</span></chmetcnv>(即使用262144个块作缓冲池)大小的情况下,此参数定义为<chmetcnv w:st="on" unitname="m" sourcevalue="100" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">100M</span></chmetcnv>时,oracle不能启动,定义为<chmetcnv w:st="on" unitname="m" sourcevalue="200" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">200M</span></chmetcnv>时正常启动。根据我阅读文献后对这个情况的理解,数据缓冲区的每一个块的块头信息都将存放于普通内存中,不能存放于间接内存中。如果此参数定义过小,导致缓冲区块头信息都不能存放,则可导致数据库启动失败。那么,是不是同样大小的缓冲区,数据库块越大,则这个参数就可以定义得越小,因而可以占用更少的普通内存呢?有待验证。
....
在具体的应用中,如何定义此参数,应综合考虑最大并发连接数(专用服务器模式下)、用户重用的堆栈大小、排序区、共享池、大池等内存参数的设置情况,尽可能的将数据缓冲区放到间接内存中,充分利用系统的资源。

3
间接内存的性能
....
oracle的文献讲,间接内存的性能(我想主要是指速度和效率吧?)不如直接内存,绝不推荐在未安装有<chmetcnv w:st="on" unitname="g" sourcevalue="4" hasspace="False" negative="False" numbertype="1" tcsc="0"><span lang="EN-US" style="font-family:Verdana;FONT-SIZE: 10pt;">4G</span></chmetcnv>物理内存的系统上使用4GT特性。我不知道如何比较间接内存与直接内存的速度和效率,因而未作测试,姑且信之。

....
一点小结,期望能对大家有所启发。还请各位大侠补充指正。

以上内容的测试环境:
IBM X360 +<chmetcnv w:st="on" unitname="g" sourcevalue="4" hasspace="False" negative="False" numbertype="1" tcsc="0">4G</chmetcnv>
内存 + RAID 5阵列
Windows 2000 Advaced Server SP3 + oracle <chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False">8.1.6</chsdate>
专用服务器模式

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics