HP-UNIX-内存热点问题及案例分享

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

©2004Hewlett-PackardDevelopmentCompany,L.P.Theinformationcontainedhereinissubjecttochangewithoutnotice内存热点问题及案例分享张永军企业客户技术支持中心支持服务事业部中国惠普有限公司2004.2检查内存•1.dmesg:•MemoryInformation:•physicalpagesize=4096bytes,logicalpagesize=4096bytes•Physical:1048576Kbytes,lockable:790684Kbytes,available:918096Kbytes•2.sam:•samPerformanceMonitorsSystemPropertiesMemory•3.syslog.log•4.glanceMemory的角色•三个部分:•1.Physicalmemory•2.AvailableMemory•Theamountofmainmemorynotreservedforthekernelistermedavailablememory.Availablememoryisusedbythesystemforexecutinguserprocesses.•3.LockableMemory•Pageskeptinmemoryforthelifetimeofaprocessbymeansofasystemcall(suchasmlock,plock,orshmctl)aretermedlockedmemory.Lockedmemorycannotbepagedandprocesseswithlockedmemorycannotbedeactivated.Kernelparameter:unlockable_mem.•Totalavailablesystemmemory-unlockable_mem=lockablememory检查空闲内存•1.Top•Memory:126108K(79812K)real,419716K(324852K)virtual,98184Kfree•2.Glance•3.Vmstat•#vmstat11•procsmemorypage•faultscpu•rbwavmfreereatpipofrdesrin•sycsussyid•1009340559895100000448•7371331199与内存相关的内核参数•Buffercacherelated:•nbufandbufpages=0表示使用动态内存dbc_max_pct50dbc_min_pct5BuffercacheusedbyFilesystem.建议调低dbc_max_pct(尤其大量使用rawdevice),否则占用太多内存。与内存相关的内核参数(续)vx_ninode=0表示使用动态内存,可能占用很大内存,造成系统内存资源耗尽,还可能造成superpagepoolcorruptionOrfragmentation。unlockable_mem使用缺省值(=0)内存的分配•内存分配的三种方式,需要相同数量的swap.1.plainmemoryasallocatedwithmalloc(3C)systemcall.2.sharedmemoryasallocatedwithshmget(2)systemcall.3.memorymappedfilesasallocatedwithmmap(2)systemcall.内存的分配(续)1.一般内存的分配由malloc(3C)系统调用完成a)Toreportprocessmemoryusage,bylargestfirst,run:#ps–efl|sort–rnk10|more•Andlookat10thcolumn(SZ)toseetheamountofmemoryusedbythisprocessfordata/textandstack(asthisvalueisinpages,youcanmultiplyby4096todeterminethesizeinbytes.)Anytimeyouseethatthesize(SZ)isafour-digitnumber,watchitovertimeandseeifitcontinuestogrow.•Alternativepscommand-Alternatively,youcanusetheUNIX95optionstolookatbothVirtualSizeaswellastheactualSize.Run:#UNIX95=1ps-efovsz,sz,pid,args|grep-vgrep|sort-rnk1|more内存的分配(续)•b)Andanotherwayistosortglance'sprocesslist(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/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.3352kb16•c)Unsupportedtools:procsize&kmeminfo内存的分配(续)•2)共享内存的分配:shmget(2)systemcall.•a)Toseesharedmemoryusage,ipcscanbeused.Forexample,run:#ipcs–mb|more•Tototalthesharedmemoryusage,run:•#ipcs-mb|sed-n'/^m/p'|\•awk'{total+=$NF}END{printf(“%d\n”,total)}‘•b)unsupportedtoolcalledshminfo内存的分配(续)•3)内存映像文件:mmap(2)systemcall.•Notoolsavailablebutunsupportedshminfo.用户进程内存限制•maxdsiz,maxssiz,maxtsiz•Sharedmemorylimit:shmmax•swap32bitapp解释•对通常的程序来说:•第一象限用来存放apptext•第二象限用来存放data&stack•第三四象限用来存放共享的数据Thedefaultusageforthequadrantsis:Quadrant1ProcesstextQuadrant2ProcessdataQuadrant3SharedlibrariesSharedmemoryMemorymappedfilesQuadrant4SharedlibrariesSharedmemoryMemorymappedfilesThelastpartofquadrant4isreservedforsystemI/O.32bitappPrivate部分•Maxdsiz&maxssiz所决定的数据段和堆栈段位于同一个象限中,总和不能大于1GB。•Maxdsiz&maxssiz应该合理配置,否则互相影响•Maxssiz一般设置成64MB已足够•正常32bit应用,数据段最大为940MB•安装补丁,最大可以1.9GB。•编译选项ld-NOR“chatr+q3penableexecutable_name”toenablethirdquadrantprivate32bitapp共享部分•第3、4象限用来做32bitapp的共享寻址•最大1.75GB•SHMEM_MAGIC将第二象限用于共享数据(这时最大为2.75GB)•TogetSHMEM_MAGIC,theexecutableneedstohavebeenlinked(ld)withEXEC_MAGIC(the-Noption)andchatr'edwithSHMEM_MAGIC(the-Moption).64bitapp•For64bitprocessesthequadrantsizesare4tb,andthereforethemaximumsizesfortext,data,sharedmemory,etc,arequitelarge.•For64bit11.00/11iexecutablesthereiscurrentlynoneedtohavedifferentmemorymapsavailableasthestandardoneallowsupto4TBfortheprogramtext,another4TBforit'sprivatedataandatotalof8TBforsharedareas.考虑一下……•16GB物理内存•将多个数据库置于同一台机器•对32位数据库,只有1.75GB内存可用•怎么办?MemoryWindows!WhatdoestheMemoryWindowsfeaturedo?Enablingmemorywindowsdoeschangethekernelsdefaultallocationpolicy.Withonlytheglobalmemorywindowconfigured,thekernelallocatessharedaddressesfromthe4thquadrantfirstandthenthe3rdquadrant.Whenmax_mem_windowissettoanon-zerovalue(enablingmemorywindows),thekernelchangesthedefaultallocationpolicysuchthatthe3rdquadrantistriedfirstfollowedbythe4th.内核设置Toenabletheuseofmemorywindowsthekerneltunablemax_mem_windowmustbesettothedesiredamountofmemorywindows.Thedisabledvalueis0.Agooddefaultis256.Note:Thistunableisnotdynamic.内核设置Toenable256memorywindowsinthekerneladdthefollowinglinetothekernelconfigurationfile(/stand/system):max_mem_window256Buildanewkernelandreboot.Settingmax_mem_windowto256resultsincreating256memorywindows,plustheglobalmemorywindow.Settingmax_mem_windowto1wouldcreate1memorywindow,plustheglobalwindow,foratotalof2.Services.windowModify/etc/services.window..database120database230database340相关命令•getmemwindowisthecomm

1 / 44
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功