HPUNIX内存热点问题及案例分享

上传人:cn****1 文档编号:570067162 上传时间:2024-08-01 格式:PPT 页数:44 大小:316.69KB
返回 下载 相关 举报
HPUNIX内存热点问题及案例分享_第1页
第1页 / 共44页
HPUNIX内存热点问题及案例分享_第2页
第2页 / 共44页
HPUNIX内存热点问题及案例分享_第3页
第3页 / 共44页
HPUNIX内存热点问题及案例分享_第4页
第4页 / 共44页
HPUNIX内存热点问题及案例分享_第5页
第5页 / 共44页
点击查看更多>>
资源描述

《HPUNIX内存热点问题及案例分享》由会员分享,可在线阅读,更多相关《HPUNIX内存热点问题及案例分享(44页珍藏版)》请在金锄头文库上搜索。

1、2004Hewlett-PackardDevelopmentCompany,L.P.Theinformationcontainedhereinissubjecttochangewithoutnotice内存热点问题及案内存热点问题及案例分享例分享张永军张永军企业客户技术支持中心企业客户技术支持中心支持服务事业部支持服务事业部中国惠普有限公司中国惠普有限公司2004.2检查内存检查内存1.dmesg:MemoryInformation:physicalpagesize=4096bytes,logicalpagesize=4096bytesPhysical:1048576Kbytes,lockab

2、le:790684Kbytes,available:918096Kbytes2.sam:samPerformanceMonitorsSystemPropertiesMemory3.syslog.log4.glanceMemory的角色的角色三个部分三个部分:1.Physicalmemory2.AvailableMemoryTheamountofmainmemorynotreservedforthekernelistermedavailablememory.Availablememoryisusedbythesystemforexecutinguserprocesses.3.LockableMe

3、moryPageskeptinmemoryforthelifetimeofaprocessbymeansofasystemcall(suchasmlock,plock,orshmctl)aretermedlockedmemory.Lockedmemorycannotbepagedandprocesseswithlockedmemorycannotbedeactivated.Kernelparameter:unlockable_mem.Total available system memory - unlockable_mem = lockable memory检查空闲内存检查空闲内存1.Top

4、Memory: 126108K (79812K) real, 419716K (324852K) virtual, 98184K free2.Glance3.Vmstat#vmstat11procsmemorypagefaultscpurbwavmfreereatpipofrdesrinsycsussyid10093405598951000004487371331199与内存相关的内核参数与内存相关的内核参数Buffercacherelated:nbufandbufpages=0表示使用动态内存dbc_max_pct50dbc_min_pct5BuffercacheusedbyFilesyst

5、em.建议调低dbc_max_pct(尤其大量使用rawdevice),否则占用太多内存。与内存相关的内核参数与内存相关的内核参数(续续)vx_ninode=0表示使用动态内存,可能占用很大内存,造成系统内存资源耗尽,还可能造成superpagepoolcorruptionOrfragmentation。unlockable_mem使用缺省值(=0)内存的分配内存的分配内存分配的三种方式,需要相同数量的swap.1.plainmemoryasallocatedwithmalloc(3C)systemcall.2.sharedmemoryasallocatedwithshmget(2)syste

6、mcall.3.memorymappedfilesasallocatedwithmmap(2)systemcall.内存的分配(续)内存的分配(续)1.一般内存的分配由一般内存的分配由malloc(3C)系统调用完成系统调用完成a)Toreportprocessmemoryusage,bylargestfirst,run:#psefl|sortrnk10|moreAndlookat10thcolumn(SZ)toseetheamountofmemoryusedbythisprocessfordata/textandstack(asthisvalueisinpages,youcanmultipl

7、yby4096todeterminethesizeinbytes.)Anytimeyouseethatthesize(SZ)isafour-digitnumber,watchitovertimeandseeifitcontinuestogrow.Alternativepscommand-Alternatively,youcanusetheUNIX95optionstolookatbothVirtualSizeaswellastheactualSize.Run:#UNIX95=1ps-efovsz,sz,pid,args|grep-vgrep|sort-rnk1|more内存的分配(续)内存的分

8、配(续)b)Andanotherwayistosortglancesprocesslist(orapplicationlist)byRSS(orResMemVirtMem).Forexample:PROCESSLISTUsers=5UserCPUUtilCumDiskThdProcessNamePIDPPIDPriName(100%max)CPUIORateRSSCnt-pax1381913818148root2.7/5.8273.39.4/32.8284kb1glance144641822158root2.1/3.13.00.0/2.14.3mb1scopeux17151127root1.7

9、/0.2518.41.5/0.04.1mb1swapper00127root1.5/0.82213.00.3/0.016kb1java100951168root1.0/2.7348.70.0/4.242.0mb28vxfsd350138root0.2/0.1289.41.9/1.3352kb16c)Unsupportedtools:procsize&kmeminfo内存的分配(续)内存的分配(续)2)共享内存的分配共享内存的分配:shmget(2)systemcall.a)Toseesharedmemoryusage,ipcscanbeused.Forexample,run:#ipcsmb|m

10、oreTototalthesharedmemoryusage,run:#ipcs-mb|sed-n/m/p|awktotal+=$NFENDprintf(“%dn”,total)b)unsupportedtoolcalledshminfo内存的分配(续)内存的分配(续)3)内存映像文件内存映像文件:mmap(2)systemcall.Notoolsavailablebutunsupportedshminfo.用户进程内存限制用户进程内存限制maxdsiz,maxssiz,maxtsizSharedmemorylimit:shmmaxswap32bitapp解释对通常的程序来说:第一象限用来存放

11、apptext第二象限用来存放data&stack第三四象限用来存放共享的数据The default usage for the quadrants is:Quadrant1ProcesstextQuadrant2ProcessdataQuadrant3SharedlibrariesSharedmemoryMemorymappedfilesQuadrant4SharedlibrariesSharedmemoryMemorymappedfilesThelastpartofquadrant4isreservedforsystemI/O.32bitappPrivate部分部分Maxdsiz&maxs

12、siz所决定的数据段和堆栈段位于同一个象限中,总和不能大于1GB。Maxdsiz&maxssiz应该合理配置,否则互相影响Maxssiz一般设置成64MB已足够正常32bit应用,数据段最大为940MB安装补丁,最大可以1.9GB。编译选项ld-NOR“chatr+q3penableexecutable_name”toenablethirdquadrantprivate32bitapp共享部分共享部分第3、4象限用来做32bitapp的共享寻址最大1.75GBSHMEM_MAGIC将第二象限用于共享数据(这时最大为2.75GB)TogetSHMEM_MAGIC,theexecutablenee

13、dstohavebeenlinked(ld)withEXEC_MAGIC(the-Noption)andchatredwithSHMEM_MAGIC(the-Moption).64bitappFor64bitprocessesthequadrantsizesare4tb,andthereforethemaximumsizesfortext,data,sharedmemory,etc,arequitelarge.For64bit11.00/11iexecutablesthereiscurrentlynoneedtohavedifferentmemorymapsavailableasthestan

14、dardoneallowsupto4TBfortheprogramtext,another4TBforitsprivatedataandatotalof8TBforsharedareas.考虑一下16GB物理内存将多个数据库置于同一台机器对32位数据库,只有1.75GB内存可用怎么办?Memory Windows!WhatdoestheMemoryWindowsfeaturedo?Enablingmemorywindowsdoeschangethekernelsdefaultallocationpolicy.Withonlytheglobalmemorywindowconfigured,the

15、kernelallocatessharedaddressesfromthe4thquadrantfirstandthenthe3rdquadrant.Whenmax_mem_windowissettoanon-zerovalue(enablingmemorywindows),thekernelchangesthedefaultallocationpolicysuchthatthe3rdquadrantistriedfirstfollowedbythe4th.内核设置内核设置Toenabletheuseofmemorywindowsthekerneltunablemax_mem_windowmu

16、stbesettothedesiredamountofmemorywindows.Thedisabledvalueis0.Agooddefaultis256.Note:Thistunableisnotdynamic.内核设置内核设置Toenable256memorywindowsinthekerneladdthefollowinglinetothekernelconfigurationfile(/stand/system):max_mem_window256Buildanewkernelandreboot.Settingmax_mem_windowto256resultsincreating2

17、56memorywindows,plustheglobalmemorywindow.Settingmax_mem_windowto1wouldcreate1memorywindow,plustheglobalwindow,foratotalof2.Services.windowModify/etc/services.window.database120database230database340相关命令相关命令getmemwindowisthecommandusedtoextractwindowidsofuserprocessesfromthe/etc/services.windowfile.

18、setmemwindowisthecommandthatchangesthewindowidofarunningprocessorstartsaspecifiedprograminaparticularmemorywindow.限制限制1.Anapplicationcannotdynamicallyswitchbetweenonewindowandanother.2.Applicationsareonlyallowedtochangetheirwindowatexectime.3.Applicationsarenotrequiredtochangetheirsourcecode,butinst

19、eadusethememorywindowcommandsetmemwindowtostartanapplicationinaspecifiedmemorywindow.例子例子Forexample:setmemwindow-i10myprogarg1arg2arg3Thiswouldstarttheexecutablemyprogwith3argumentsinthememorywindowcorrespondingtouserkey10.Thereareotheroptionstosetmemwindowtocontrolhowmemorywindowsarecreated.例子(续)例子

20、(续)getmemwindowisusedtoextracttheuserids/keysfromthe/etc/services.windowfilegivenaparticularstring.Thisavoidshavingtoembedthekeysinthescriptsthemselves.syntax:getmemwindow例子(续)例子(续)Puttingitalltogetherinarealexample:#catstartDB1.shWinId=$(getmemwindowdatabase1)setmemwindow-i$WinId/home/dave/memwinbb

21、/startDB1DB1sayshello!例子(续)例子(续)#./startDB1.shwritingtosegment:DB1sayshello!Keyis1377312562例子(续)例子(续)#ipcs-mobIPCstatusfrom/dev/kmemasofThuJul1008:52:342003TIDKEYMODEOWNERGROUPNATTCHSEGSZSharedMemory:m00x4124288b-rw-rw-rw-rootroot0348m10x4e000002-rw-rw-rw-rootroot161760m20x41280050-rw-rw-rw-rootroot

22、18192m52150x52181f32-rw-r-r-rootsys01024Ourkeyof1377312562convertedtohexis52181f32例子(续)例子(续)#./startDB2.shwritingtosegment:DB2saysBonJour!Keyis1377312563#./startDB3.shwritingtosegment:DB3saysOla!Keyis1377042734例子(续)例子(续)#morestopDB1.shWinId=$(getmemwindowdatabase1)setmemwindow-i$WinId/home/dave/memw

23、inbb/stopDB1#./stopDB1.sh#./stopDB2.sh#./stopDB3.sh工具介绍工具介绍pstopglanceps#psefl|sortrnk10|moreAndlookat10thcolumn(SZ)toseetheamountofmemoryusedbythisprocessfordata/textandstack(asthisvalueisinpages,youcanmultiplyby4096todeterminethesizeinbytes.)Anytimeyouseethatthesize(SZ)isafour-digitnumber,watchito

24、vertimeandseeifitcontinuestogrow.Alternativepscommand-Alternatively,youcanusetheUNIX95optionstolookatbothVirtualSizeaswellastheactualSize.Forexample:#UNIX95=1ps-efovsz,sz,pid,args|grep-vgrep|sort-rnk1|moreVSZSZPIDCOMMAND122526272745/opt/OV/bin/ovdbrun-c/var/opt/OV/share/databases/analysis/9060121423

25、62/opt/omni/lbin/rds-d880818922677/opt/hpwebjet-5.5/hpwebjetdtopLoadaverages:0.64,0.57,0.56195processes:194sleeping,1running.Memory:1444296K(1238320K)real,1967080K(1468152K)virtual,84908Kfree|12345Memoryisnotallofphyscial,memory,itis:1.1.分配给所有进程的物理内存分配给所有进程的物理内存DEDICATED to text, data or stack DEDIC

26、ATED to text, data or stack segments segments 2.2.所有所有runnablerunnable processes processes的物理内存,不包括的物理内存,不包括sleeping processessleeping processes的。的。 3.3.分配给所有进程的虚拟内存分配给所有进程的虚拟内存DEDICATED to text, data or stack DEDICATED to text, data or stack segmentssegments。不是所有都在物理内存,有部分在不是所有都在物理内存,有部分在swapswap区中

27、。区中。4.4.分配给所有进程的虚拟内存,不包括分配给所有进程的虚拟内存,不包括sleeping or stopped processessleeping or stopped processes5.5.新进程的可用物理内存,当比较低时,新进程的可用物理内存,当比较低时,swappingswapping. . Top(续)SizeisvirtualmemorysizeRESmeansthepartinRAMWhatiftoomanyCPUs?tophWhatifIwanttogetallprocessinfo?topn500ftop.outglanceTotalVM:121.1mbSysMem

28、:13.8mbUserMem:91.3mbPhysMem:144.0mbActiveVM:73.7mbBufCache:26.4mbFreeMem:12.6mbTotalVM:Thetotalprivatevirtualmemory(inKBsunlessotherwisespecified)attheendoftheinterval.virtualallocationofprivatedataandstackregionsforallprocesses.ActiveVM:Thetotalvirtualmemory(inKBsunlessotherwisespecified)allocated

29、forprocessescurrentlyareontherunqueueorprocessesthathaveexecutedrecently.SysMem:TheamountofphysicalmemoryKBsunlessotherwisespecified)usedbythesystem(kernel)duringtheinterval.UserMem:Theamountofphysicalmemory(inKBsunlessotherwisespecified)allocatedtousercodeanddataattheendoftheinterval.Memoryhog1.vx_

30、ninode2.dbc_max_pct3.SuperPagePool4.Semrelated5.OthermemoryleakVx_ninodeexample:Seefile:Dbc_max_pct缺省值是50,50%内存可以用于bufferDbc_min_pct缺省是5%在起机时,buffer很小随buffer增大,freememory急剧减小Vhand占据cpu忙于换页系统hungSuperPagePool1.11.00:HighSuperPagePoolfreelistusage2.Caused/introducedbyPHKL_25098.3.CorrectedinPHKL_28172(SRJAGae32238relatedJAGs:JAGad83301JAGad86735JAGae25556)SuperPagePoolfreelistexampleSeefile:SemrelatedSeefile:

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号