[计算机软件及应用]理解Oracle在AIX平台上的内存使用.doc_第1页
[计算机软件及应用]理解Oracle在AIX平台上的内存使用.doc_第2页
[计算机软件及应用]理解Oracle在AIX平台上的内存使用.doc_第3页
[计算机软件及应用]理解Oracle在AIX平台上的内存使用.doc_第4页
[计算机软件及应用]理解Oracle在AIX平台上的内存使用.doc_第5页
已阅读5页,还剩51页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

理解Oracle在AIX平台上的内存使用JULY 19, 2010BYMACLEAN LIU11 COMMENTS1.理解Oracle进程首先我们要做的是理解Oracle的3种进程类型:后台进程( background process)和服务进程(也叫前台进程)还有用户进程。当我们尝试启动Oracle实例,首先受到召唤的是后台进程,一组后台进程和内存组建构成了 Oracle 实例,这些后台进程包括 日志记录进程lgwr,数据库写出进程 dbwr, 系统监控进程smon, 进程监控进程pmon, 分布式恢复进程reco, 检查点进程ckpt, 11g后变得更多了,多到我记不住。 这些进程在UNIX上的具体args总是形如ora_functionname_sid, 这里的functionname即后台进程的功能名而sid 即 $ORACLE_SID所指出的值。第二类是用户进程,它可能是一个sqlplus命令行,可能是imp/exp工具,也可能是用户开发的一个java程序,当用户进程在本地启动时它们不直接操作SGA或者PGA,但毫无疑问它们也是需要消耗一定数量的虚拟内存的。第三类进程就是我们说的服务进程,启动一个sqlplus 连接(这个连接可能是连到本地的 也可能的是远程的,这在我们讨论内存使用时无关紧要)的同时我们需要用到一个服务进程,它直接向我们的sqlplus终端负责。我们有时候也称服务进程为影子进程。影子进程总是和每一个用户进程一一对应的映射除非我们用到了MTS(多线程服务器)时。影子进程一般形如oracleSID,这里的sid和前文所指一般。2.理解Oracle的内存使用Oracle对内存的使用可以划分为2个大类型,即私有的和共享的。私有内存仅供单个进程使用。相反的,共享内存可以供多个进程使用且在具体使用上要复杂得多。在合计共享内存时,我们只需将所有进程所共享的内存段累加一次即可(Oracle 的SGA具体反映到OS层可能是多个shared memory segment,我们只需要将这一个或多个段的大小加到一起就可以了)。我们可能使用到的最大的共享内存段毫无疑问会是SGA(SYSTEM GLOBAL AREA),我们看到的SGA被映射成虚拟地址且被每一个后台进程和前台进程attach到自己身上,以便随时能够利用到SGA; 我们有很多性能工具可以反映这部分的内存使用, 好比top,ps -lf, 但他们都无法分辨前后台进程内存使用中私有内存和共享内存分别得使用状况(我们往往只能得到一个Oracle使用内存很多的结论,却不知道是PGA还是 SGA消耗的更多的内存)。如果我们把从这些途径中获得每个进程的内存使用量相加,我们会发现这样计算的总内存使用量是SGA+PGA的几十倍,这是违反常识的,实际也分配不到那么多内存。 要真正了解Oracle内存使用,你使用的内存窥测命令需要能够分离Oracle使用的私有内存和共享内存。在Aix平台上有这样一个svmon(在其他 UNIX平台上有一个我认为更好的工具是pmap,与之对应AIX上有一个procmap命令,但这个命令并不能窥测Oracle 私有或共享内存的使用,所以我们只能退而求其次了)。您可能在AIX的安装光盘上通过安装文件(filesets) “perfagent.tools”来获取该工具。使用”smit install_lastest”命令可以配备这个命令。对于svmon,作为一个非AIX操作系统专家而言,我推荐您读一下我引用的这篇文档:The svmon CommandThe svmon command provides a more in-depth analysis of memory usage. It is more informative, but also more intrusive, than the vmstat and ps commands. The svmon command captures a snapshot of the current state of memory. However, it is not a true snapshot because it runs at the user level with interrupts enabled.To determine whether svmon is installed and available, run the following command:# lslpp -lI perfagent.toolsThe svmon command can only be executed by the root user.If an interval is used (-i option), statistics will be displayed until the command is killed or until the number of intervals, which can be specified right after the interval, is reached.You can use four different reports to analyze the displayed information:Global (-G)Displays statistics describing the real memory and paging space in use for the whole system.Process (-P)Displays memory usage statistics for active processes.Segment (-S)Displays memory usage for a specified number of segments or the top ten highest memory-usage processes in descending order.Detailed Segment (-D)Displays detailed information on specified segments.Additional reports are available in AIX 4.3.3 and later, as follows:User (-U)Displays memory usage statistics for the specified login names. If no list of login names is supplied, memory usage statistics display all defined login names.Command (-C)Displays memory usage statistics for the processes specified by command name.Workload Management Class (-W)Displays memory usage statistics for the specified workload management classes. If no classes are supplied, memory usage statistics display all defined classes.To support 64-bit applications, the output format of the svmon command was modified in AIX 4.3.3 and later.Additional reports are available in operating system versions later than 4.3.3, as follows:Frame (-F)Displays information about frames. When no frame number is specified, the percentage of used memory is reported. When a frame number is specified, information about that frame is reported.Tier (-T)Displays information about tiers, such as the tier number, the superclass name when the -a flag is used, and the total number of pages in real memory from segments belonging to the tier.How Much Memory is in UseTo print out global statistics, use the -G flag. In this example, we will repeat it five times at two-second intervals.# svmon -G -i 2 5m e m o r y i n u s e p i n p g s p a c esize inuse free pin work pers clnt work pers clnt size inuse16384 16250 134 2006 10675 2939 2636 2006 0 0 40960 1267416384 16254 130 2006 10679 2939 2636 2006 0 0 40960 1267616384 16254 130 2006 10679 2939 2636 2006 0 0 40960 1267616384 16254 130 2006 10679 2939 2636 2006 0 0 40960 1267616384 16254 130 2006 10679 2939 2636 2006 0 0 40960 12676The columns on the resulting svmon report are described as follows:memoryStatistics describing the use of real memory, shown in 4 K pages.sizeTotal size of memory in 4 K pages.inuseNumber of pages in RAM that are in use by a process plus the number of persistent pages that belonged to a terminated process and are still resident in RAM. This value is the total size of memory minus the number of pages on the free list.freeNumber of pages on the free list.pinNumber of pages pinned in RAM (a pinned page is a page that is always resident in RAM and cannot be paged out).in useDetailed statistics on the subset of real memory in use, shown in 4 K frames.workNumber of working pages in RAM.persNumber of persistent pages in RAM.clntNumber of client pages in RAM (client page is a remote file page).pinDetailed statistics on the subset of real memory containing pinned pages, shown in 4 K frames.workNumber of working pages pinned in RAM.persNumber of persistent pages pinned in RAM.clntNumber of client pages pinned in RAM.pg spaceStatistics describing the use of paging space, shown in 4 K pages. This data is reported only if the -r flag is not used. The value reported starting with AIX 4.3.2 is the actual number of paging-space pages used (which indicates that these pages were paged out to the paging space). This differs from the vmstat command in that vmstats avm column which shows the virtual memory accessed but not necessarily paged out.sizeTotal size of paging space in 4 K pages.inuseTotal number of allocated pages.In our example, there are 16384 pages of total size of memory. Multiply this number by 4096 to see the total real memory size (64 MB). While 16250 pages are in use, there are 134 pages on the free list and 2006 pages are pinned in RAM. Of the total pages in use, there are 10675 working pages in RAM, 2939 persistent pages in RAM, and 2636 client pages in RAM. The sum of these three parts is equal to the inuse column of the memory part. The pin part divides the pinned memory size into working, persistent and client categories. The sum of them is equal to the pin column of the memory part. There are 40960 pages (160 MB) of total paging space, and 12676 pages are in use. The inuse column of memory is usually greater than the inuse column of pg spage because memory for file pages is not freed when a program completes, while paging-space allocation is.In AIX 4.3.3 and later, systems the output of the same command looks similar to the following:# svmon -G -i 2 5size inuse free pin virtualmemory 65527 64087 1440 5909 81136pg space 131072 55824work pers clntpin 5918 0 0in use 47554 13838 2695size inuse free pin virtualmemory 65527 64091 1436 5909 81137pg space 131072 55824work pers clntpin 5918 0 0in use 47558 13838 2695size inuse free pin virtualmemory 65527 64091 1436 5909 81137pg space 131072 55824work pers clntpin 5918 0 0in use 47558 13838 2695size inuse free pin virtualmemory 65527 64090 1437 5909 81137pg space 131072 55824work pers clntpin 5918 0 0in use 47558 13837 2695size inuse free pin virtualmemory 65527 64168 1359 5912 81206pg space 131072 55824work pers clntpin 5921 0 0in use 47636 13837 2695The additional output field is the virtual field, which shows the number of pages allocated in the system virtual space.Who is Using Memory?The following command displays the memory usage statistics for the top ten processes. If you do not specify a number, it will display all the processes currently running in this system.# svmon -Pau 10Pid Command Inuse Pin Pgspace15012 maker4X.exe 4783 1174 47812750 X 4353 1178 554415706 dtwm 3257 1174 400317172 dtsession 2986 1174 382721150 dtterm 2941 1174 369717764 aixterm 2862 1174 36442910 dtterm 2813 1174 370519334 dtterm 2813 1174 370413664 dtterm 2804 1174 370617520 aixterm 2801 1174 3619Pid: 15012Command: maker4X.exeSegid Type Description Inuse Pin Pgspace Address Range1572 pers /dev/hd3:62 0 0 0 0.-1142 pers /dev/hd3:51 0 0 0 0.-11bde pers /dev/hd3:50 0 0 0 0.-12c1 pers /dev/hd3:49 1 0 0 0.79ab pers /dev/hd2:53289 1 0 0 0.0404 work kernel extension 27 27 0 0.245801d9b work lib data 39 0 23 0.607909 work shared library text 864 0 7 0.655355a3 work sreg4 9 0 12 0.327681096 work sreg3 32 0 32 0.327831b9d work private 1057 1 1219 0.1306 : 65307.655351af8 clnt 961 0 0 0.17160 work kernel 1792 1146 3488 0.32767 : 32768.65535The output is divided into summary and detail sections. The summary section lists the top ten highest memory-usage processes in descending order.Pid 15012 is the process ID that has the highest memory usage. The Command indicates the command name, in this case maker4X.exe. The Inuse column (total number of pages in real memory from segments that are used by the process) shows 4783 pages (each page is 4 KB). The Pin column (total number of pages pinned from segments that are used by the process) shows 1174 pages. The Pgspace column (total number of paging-space pages that are used by the process) shows 4781 pages.The detailed section displays information about each segment for each process that is shown in the summary section. This includes the segment ID, the type of the segment, description (a textual description of the segment, including the volume name and i-node of the file for persistent segments), number of pages in RAM, number of pinned pages in RAM, number of pages in paging space, and address range.The Address Range specifies one range for a persistent or client segment and two ranges for a working segment. The range for a persistent or a client segment takes the form 0.x, where x is the maximum number of virtual pages that have been used. The range field for a working segment can be 0.x : y.65535, where 0.x contains global data and grows upward, and y.65535 contains stack area and grows downward. For the address range, in a working segment, space is allocated starting from both ends and working towards the middle. If the working segment is non-private (kernel or shared library), space is allocated differently. In this example, the segment ID 1b9d is a private working segment; its address range is 0.1306 : 65307.65535. The segment ID 909 is a shared library text working segment; its address range is 0.65535.A segment can be used by multiple processes. Each page in real memory from such a segment is accounted for in the Inuse field for each process using that segment. Thus, the total for Inuse may exceed the total number of pages in real memory. The same is true for the Pgspace and Pin fields. The sum of Inuse, Pin, and Pgspace of all segments of a process is equal to the numbers in the summary section.You can use one of the following commands to display the file name associated with the i-node:* ncheck -i i-node_number volume_name* find file_system_associated_with_lv_name -xdev -inum inode_number -printTo get a similar output in AIX 4.3.3 and later, use the following command:# svmon -Put 10Pid Command Inuse Pin Pgsp Virtual 64-bit Mthrd2164 X 15535 1461 34577 37869 N NVsid Esid Type Description Inuse Pin Pgsp Virtual Addr Range1966 2 work process private 9984 4 31892 32234 0.32272 :65309.655354411 d work shared library text 3165 0 1264 1315 0.655350 0 work kernel seg 2044 1455 1370 4170 0.32767 :65475.65535396e 1 pers code,/dev/hd2:18950 200 0 - 0.7062ca3 work 32 0 0 32 0.3278343d5 work 31 0 6 32 0.327832661 work 29 0 0 29 0.32783681f work 29 0 25 29 0.32783356d f work shared library data 18 0 18 24 0.31034e8 3 work shmat/mmap 2 2 2 4 0.327675c97 pers /dev/hd4:2 1 0 - 0.05575 pers /dev/hd2:19315 0 0 - 0.04972 pers /dev/hd2:19316 0 0 - 0.54170 pers /dev/hd3:28 0 0 - 0.0755d pers /dev/hd9var:94 0 0 - 0.06158 pers /dev/hd9var:90 0 0 - 0.0Pid Command Inuse Pin Pgsp Virtual 64-bit Mthrd25336 austin.ibm. 12466 1456 2797 11638 N NVsid Esid Type Description Inuse Pin Pgsp Virtual Addr Range14c3 2 work process private 5644 1 161 5993 0.6550 :65293.655354411 d work shared library text 3165 0 1264 1315 0.655350 0 work kernel seg 2044 1455 1370 4170 0.32767 :65475.6553513c5 1 clnt code 735 0 - 0.4424d21 pers /dev/andy:563 603 0 - 0.6189e6 f work shared library data 190 0 2 128 0.3303942 pers /dev/cache:16 43 0 - 0.422ca3 work 32 0 0 32 0.3278349f0 clnt 10 0 - 0.4711b07 pers /dev/andy:8568 0 0 - 0.0623 pers /dev/hd2:22539 0 0 - 0.12de9 clnt 0 0 - 0.01541 5 mmap mapped to sid 761b 0 0 -5d15 pers /dev/andy:487 0 0 - 0.34513 pers /dev/andy:486 0 0 - 0.45cc4 4 mmap mapped to sid 803 0 0 -242a pers /dev/andy:485 0 0 - 0.0The Vsid column is the virtual segment ID, and the Esid column is the effective segment ID. The effective segment ID reflects the segment register that is used to access the corresponding pages.Detailed Information on a Specific Segment IDThe -D option displays detailed memory-usage statistics for segments.# svmon -D 404Segid: 404Type: workingDescription: kernel extensionAddress Range: 0.24580Size of page space allocation: 0 pages ( 0.0 Mb)Inuse: 28 frames ( 0.1 Mb)Page Frame Pin Ref Mod12294 3320 pin ref mod24580 1052 pin ref mod12293 52774 pin ref mod24579 20109 pin ref mod12292 19494 pin ref mod12291 52108 pin ref mod24578 50685 pin ref mod12290 51024 pin ref mod24577 1598 pin ref mod12289 35007 pin ref mod24576 204 pin ref mod12288 206 pin ref mod4112 53007 pin mod4111 53006 pin mod4110 53005 pin mod4109 53004 pin mod4108 53003 pin mod4107 53002 pin mod4106 53001 pin mod4105 53000 pin mod4104 52999 pin mod4103 52998 pin mod4102 52997 pin mod4101 52996 pin mod4100 52995 pin mod4099 52994 pin mod4098 52993 pin mod4097 52992 pin ref modThe detail columns are explained as follows:PageSpecifies the index of the page within the segment.FrameSpecifies the index of the real memory frame that the page resides in.PinSpecifies a flag indicating whether the page is pinned.RefSpecifies a flag indicating whether the pages reference bit is on.ModSpecifies a flag indicating whether the page is modified.The size of page space allocation is 0 because all the pages are pinned in real memory.An example output from AIX 4.3.3 and later, is very similar to the following:# svmon -D 629 -bSegid: 629Type: workingAddress Range: 0.77Size of page space allocation: 7 pages ( 0.0 Mb)Virtual: 11 frames ( 0.0 Mb)Inuse: 7 frames ( 0.0 Mb)Page Frame Pin Ref Mod0 32304 N Y Y3 32167 N Y Y7 32321 N Y Y8 32320 N Y Y5 32941 N Y Y1 48357 N N Y77 47897 N N YThe -b flag shows the status of the reference and modified bits of all the displayed frames. After it is shown, the reference bit of the frame is reset. When used with the -i flag, it detects which frames are accessed between each interval.Note: Use this flag with caution because of its performance impacts.List of Top Memory Usage of SegmentsThe -S option is used to sort segments by memory usage and to display the memory-usage statistics for the top memory-usage segments. If count is not specified, then a count of 10 is implicit. The following command sorts system and non-system segments by the number of pages in real memory and prints out the top 10 segments of the resulting list.# svmon -SauSegid Type Description Inuse Pin Pgspace Address Range0 work kernel 1990 1408 3722 0.32767 : 32768.655351 work private, pid=4042 1553 1 1497 0.1907 : 65307.655351435 work private, pid=3006 1391 3 1800 0.4565 : 65309.6553511f5 work private, pid=14248 1049 1 1081 0.1104 : 65307.6553511f3 clnt 991 0 0 0.1716681 clnt 960 0 0 0.1880909 work shared library text 900 0 8 0.65535101 work vmm data 497 496 1 0.27115 : 43464.65535a0a work shared library data 247 0 718 0.655351bf9 work private, pid=21094 221 1 320 0.290 : 65277.65535All output fields are described in the previous examples.An example output from AIX 4.3.3 and later is similar to the following:# svmon -Sut 10Vsid Esid Type Description Inuse Pin Pgsp Virtual Addr Range1966 work 9985 4 31892 32234 0.32272 :65309.6553514c3 work 5644 1 161 5993 0.6550 :65293.655355453 work 3437 1 2971 4187 0.4141 :65303.655354411 work 3165 0 1264 1315 0.655355a1e work 2986 1 13 2994 0.3036 :65295.65535340d work misc kernel tables 2643 0 993 2645 0.15038 :63488.65535380e work kernel pinned heap 2183 1055 1416 2936 0.655350 work kernel seg 2044 1455 1370 4170 0.32767 :65475.655356afb pers /dev/notes:92 1522 0 - 0.102952faa clnt 1189 0 - 0.2324Correlating svmon and vmstat OutputsThere are some relationships between the svmon and vmstat outputs. The svmon report of AIX 4.3.2 follows (the example is the same with AIX 4.3.3 and later, although the output format is different):# svmon -Gm e m o r y i n u s e p i n p g s p a c esize inuse free pin work pers clnt work pers clnt size inuse16384 16254 130 2016 11198 2537 2519 2016 0 0 40960 13392The vmstat command was run in a separate window while the svmon command was running. The vmstat report follows:# vmstat 5kthr memory page faults cpu r b avm fre re pi po fr sr cy in sy cs us sy id wa0 0 13392 130 0 0 0 0 2 0 125 140 36 2 1 97 00 0 13336 199 0 0 0 0 0 0 145 14028 38 11 22 6

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论