联系:手机/微信(+86 17813235971) QQ(107644445)
作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]
本文是针对linux下面显示oracle用户进程占用大量内存的一个猜想性说明,希望各位专家和我一起继续探讨该问题
ORACLE用户进程占用私有内存分析
top命令结果
[oracle@ora02 31500]$ top -c top - 12:13:16 up 254 days, 12:14, 2 users, load average: 1.53, 1.62, 1.33 Tasks: 293 total, 3 running, 290 sleeping, 0 stopped, 0 zombie Cpu(s): 3.4% us, 0.8% sy, 0.0% ni, 94.7% id, 1.1% wa, 0.0% hi, 0.0% si Mem: 4147172k total, 4129724k used, 17448k free, 20348k buffers Swap: 4192956k total, 217772k used, 3975184k free, 2575320k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 12505 oracle 17 0 1561m 972m 970m R 100 24.0 3:45.89 oracletxzldb (LOCAL=NO) 12475 oracle 16 0 1561m 931m 929m S 4 23.0 4:08.65 oracletxzldb (LOCAL=NO) 12477 oracle 16 0 1561m 945m 942m S 2 23.3 3:36.92 oracletxzldb (LOCAL=NO) 12479 oracle 16 0 1561m 944m 941m S 2 23.3 4:27.29 oracletxzldb (LOCAL=NO) 12483 oracle 16 0 1561m 939m 937m R 2 23.2 3:49.00 oracletxzldb (LOCAL=NO) 12493 oracle 16 0 1561m 958m 955m S 2 23.7 3:35.35 oracletxzldb (LOCAL=NO)
补充说明:
VIRT 进程使用的虚拟内存总量 RES 进程使用的、未被换出的物理内存大小 SHR 共享内存大小
通过这里可以得出几个信息
12505进程实际使用内存情况:972-970=2M
12505进程%MEM:972*1024/4147172=0.24000162
12505进程在数据库中占用内存
SQL> select PGA_ALLOC_MEM/1024/1024 MEM from v$process where spid=12505; MEM ---------- 1.90997028
通过这里可以看出12505进程实际上是占用了970M的共享内存,占用2M的PGA内存
ORACLE用户进程占用共享内存分析
分析12505进程的当前进程状态
[oracle@ora02 31500]$ cd /proc/12505 [oracle@ora02 12505]$ cat status Name: oracle State: S (sleeping) SleepAVG: 92% Tgid: 12505 Pid: 12505 PPid: 1 TracerPid: 0 Uid: 501 501 501 501 Gid: 502 502 502 502 FDSize: 32 Groups: 501 502 VmSize: 1599004 kB <--使用内存(包括虚拟内存)总量1599004/1024=1561.52734和top中VIRT基本吻合 VmLck: 0 kB VmRSS: 996132 kB <--实际使用内存996132/1024 =972.785156和top看到RES基本吻合 VmData: 832 kB VmStk: 120 kB VmExe: 37307 kB VmLib: 4641 kB StaBrk: 0ad6e000 kB Brk: 0adf2000 kB StaStk: bffff850 kB ExecLim: ffffffff Threads: 1 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000006005203 SigCgt: 00000001c9802cfc CapInh: 0000000000000000 CapPrm: 0000000000000000 CapEff: 0000000000000000
pmap命令分析
[oracle@ora02 12505]$ pmap -d 12505 12505: oracletxzldb (LOCAL=NO) Address Kbytes Mode Offset Device Mapping 0013f000 88 r-x-- 0000000000000000 008:00002 ld-2.3.4.so 00155000 4 r-x-- 0000000000015000 008:00002 ld-2.3.4.so 00156000 4 rwx-- 0000000000016000 008:00002 ld-2.3.4.so 00159000 1176 r-x-- 0000000000000000 008:00002 libc-2.3.4.so 0027f000 8 r-x-- 0000000000125000 008:00002 libc-2.3.4.so 00281000 8 rwx-- 0000000000127000 008:00002 libc-2.3.4.so 00283000 8 rwx-- 0000000000283000 000:00000 [ anon ] 00287000 132 r-x-- 0000000000000000 008:00002 libm-2.3.4.so 002a8000 4 r-x-- 0000000000020000 008:00002 libm-2.3.4.so 002a9000 4 rwx-- 0000000000021000 008:00002 libm-2.3.4.so 002ac000 8 r-x-- 0000000000000000 008:00002 libdl-2.3.4.so 002ae000 4 r-x-- 0000000000001000 008:00002 libdl-2.3.4.so 002af000 4 rwx-- 0000000000002000 008:00002 libdl-2.3.4.so 003b5000 56 r-x-- 0000000000000000 008:00002 libpthread-2.3.4.so 003c3000 4 r-x-- 000000000000d000 008:00002 libpthread-2.3.4.so 003c4000 4 rwx-- 000000000000e000 008:00002 libpthread-2.3.4.so 003c5000 8 rwx-- 00000000003c5000 000:00000 [ anon ] 00ba4000 72 r-x-- 0000000000000000 008:00002 libnsl-2.3.4.so 00bb6000 4 r-x-- 0000000000011000 008:00002 libnsl-2.3.4.so 00bb7000 4 rwx-- 0000000000012000 008:00002 libnsl-2.3.4.so 00bb8000 8 rwx-- 0000000000bb8000 000:00000 [ anon ] 08048000 37308 r-x-- 0000000000000000 0fd:00001 oracle 0a4b7000 8804 rwx-- 000000000246f000 0fd:00001 oracle 0ad50000 648 rwx-- 000000000ad50000 000:00000 [ anon ] 50000000 1540096 rwxs- 0000000000000000 000:00006 [ shmid=0x9000e ] ae000000 4 r-xs- 000000005e000000 000:00006 [ shmid=0x9000e ] ae001000 1156 rwxs- 000000005e001000 000:00006 [ shmid=0x9000e ] ae122000 4 r-xs- 000000005e122000 000:00006 [ shmid=0x9000e ] ae123000 2932 rwxs- 000000005e123000 000:00006 [ shmid=0x9000e ] b79d4000 1024 rwx-- 00000000000f4000 000:0000d zero b7ad4000 512 rwx-- 0000000000074000 000:0000d zero b7b54000 512 rwx-- 0000000000000000 000:0000d zero b7bd4000 36 r-x-- 0000000000000000 008:00002 libnss_files-2.3.4.so b7bdd000 4 r-x-- 0000000000008000 008:00002 libnss_files-2.3.4.so b7bde000 4 rwx-- 0000000000009000 008:00002 libnss_files-2.3.4.so b7bdf000 148 rwx-- 00000000b7bdf000 000:00000 [ anon ] b7c04000 2940 r-x-- 0000000000000000 0fd:00001 libjox9.so b7ee3000 1088 rwx-- 00000000002de000 0fd:00001 libjox9.so b7ff3000 8 rwx-- 00000000b7ff3000 000:00000 [ anon ] b7ff5000 4 r-x-- 0000000000000000 0fd:00001 libskgxn9.so b7ff6000 8 rwx-- 0000000000000000 0fd:00001 libskgxn9.so b7ff8000 4 r-x-- 0000000000000000 0fd:00001 libskgxp9.so b7ff9000 4 --x-- 0000000000001000 0fd:00001 libskgxp9.so b7ffa000 4 rwx-- 0000000000001000 0fd:00001 libskgxp9.so b7ffb000 4 r-x-- 0000000000000000 0fd:00001 libodmd9.so b7ffc000 4 rwx-- 0000000000000000 0fd:00001 libodmd9.so b7ffd000 4 r-x-- 0000000000000000 008:00002 libcwait.so b7ffe000 4 rwx-- 0000000000000000 008:00002 libcwait.so b7fff000 4 rwx-- 00000000b7fff000 000:00000 [ anon ] bffe2000 120 rwx-- 00000000bffe2000 000:00000 [ stack ] ffffe000 4 ----- 0000000000000000 000:00000 [ anon ] mapped: 1599008K writeable/private: 12944K shared: 1544192K
补充说明:
mapped :映射到文件的内存数量 writable/private :进程所占用的私有地址空间数量 shared :与其它进程共享的地址空间数量
ipcs 命令
[oracle@ora02 12505]$ ipcs -m ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x0000cace 65536 root 666 2 0 0x4d4e5251 98305 root 644 330752 0 0x55315352 131074 root 666 4096 0 0x44525354 163843 root 644 632832 0 0x53494152 196612 root 644 1024 0 0x00005643 229381 root 666 1024 1 0x00005654 262150 root 666 1024 1 0x992ad3dc 589838 oracle 640 1581252608 595
结合pmap和ipcs分析(shmid=0x9000e)
SQL> select to_number('9000e','xxxxxxxx') from dual; TO_NUMBER('9000E','XXXXXXXX') ----------------------------- 589838 SQL> select 1540096+4+1156+4+2932 from dual; 1540096+4+1156+4+2932 --------------------- 1544192 SQL> select 1581252608/1024 from dual; 1581252608/1024 --------------- 1544192
通过这里可以得出12505进程中的共享内存,主要是数据库SGA中的共享内存
补充猜测
SQL> show sga; Total System Global Area 1561926292 bytes Fixed Size 453268 bytes Variable Size 603979776 bytes Database Buffers 956301312 bytes Redo Buffers 1191936 bytes SQL> select 1561926292/1024 from dual; 1561926292/1024 --------------- 1525318.64
这里显示数据库配置的sga比ipcs中配置共享内存段小,但是进程在分配总的共享内存时候,使用的是ipcs设定的内存段大小,实际使用的内存可能是sga设置大小(未得到权威资料)
感谢飞总的文档。
您好,我也遇到了这样的问题,ra_dbw进程占用内存非常高,top命令显示出来的MEm分配率也特别高;
Tasks: 1174 total, 1 running, 1173 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.6%us, 0.4%sy, 0.0%ni, 99.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 57813980k total, 54527544k used, 3286436k free, 155016k buffers
Swap: 131074324k total, 9934412k used, 121139912k free, 44955880k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1849 oracle 20 0 19.2g 13g 13g S 0.0 24.6 4:34.56 ora_dbw7_hhtrep1
1847 oracle 20 0 19.2g 12g 12g S 0.0 23.1 4:14.40 ora_dbw6_hhtrep1
1835 oracle 20 0 19.2g 12g 12g S 0.0 22.9 4:28.66 ora_dbw0_hhtrep1
1837 oracle 20 0 19.2g 12g 12g S 0.0 22.5 4:11.95 ora_dbw1_hhtrep1
1845 oracle 20 0 19.2g 12g 12g S 0.0 22.2 4:02.48 ora_dbw5_hhtrep1
1841 oracle 20 0 19.2g 12g 12g S 0.0 21.9 4:03.43 ora_dbw3_hhtrep1
1839 oracle 20 0 19.2g 12g 12g S 0.0 21.9 4:03.49 ora_dbw2_hhtrep1
我通过您的方法用pmap命令做了分析:
[etl@hhtrep1 ~]$ pmap -d 1849
1849: ora_dbw7_hhtrep1
Address Kbytes Mode Offset Device Mapping
mapped: 0K writeable/private: 0K shared: 0K
[etl@hhtrep1 ~]$ pmap -x 1849
1849: ora_dbw7_hhtrep1
Address Kbytes RSS Dirty Mode Mapping
—————- —— —— ——
total kB 0 0 0
占用的内存都为0,现在我不知道该如何查下去了。
能否帮助解决我的疑惑。
gouaili,
你的sga配置多少,显示出来我看下
show sga;
一般来说,dbwr的显示内存大小和sga相差不大(因为其他私有内存部分都比较小)