Itanium服务器
1752573 成员
4631 在线
108788 解答
新建帖子

SD2主机内存不能完全使用的问题,报错“fork: Not enough space”,原因:swap区大小和内存比例不足1:1.

 
liyouwei
投稿人

SD2主机内存不能完全使用的问题,报错“fork: Not enough space”,原因:swap区大小和内存比例不足1:1.

设备信息:
主机名:w4sd24pa ,机型:SD2,64Core,320G Mem ,OS:11.31.1303 , veritas卷管理及双机,oracle 11g RAC。
故障现象:
2015年2月26日 15:30--18:00期间,由于双机中的另一节点宕机,业务切换至该主机运行。但这段时间业务运行非常缓慢,主机上执行unix命令、数据库的外连接都报“fork: Not enough space”,ssh 也无法正常登录。
但主机的性能监控记录显示:内存使用率只有92%(切换前是84%),free内存还有8%,约24G。
主机的vmstat记录:
procs memory page faults cpu
r b w avm free re at pi po fr de sr in sy cs us sy id
15:28 7 36 0 17873806 16226155 0 0 169 0 0 0 0 34610 291009 38881 8 4 87
15:28 32 20 0 25815212 11872374 0 0 1 0 0 0 0 109766 1252958 56139 18 9 73
15:31 32 20 0 34496713 8410635 0 0 0 0 0 0 0 212943 2148180 99298 31 9 60
16:01 26 82 0 31331035 7046117 0 0 74 0 0 0 0 215470 2465509 100145 34 8 58
16:34 24 4 0 30840902 6966489 0 0 3 0 0 0 0 217890 2233155 97663 28 6 66
17:01 21 11 0 29982598 6929006 0 0 0 0 0 0 0 198525 1976624 84902 24 5 70
17:55 14 2 0 28268274 6835115 0 0 3 0 0 0 0 163955 1730801 63946 22 5 73
17:58 21 3 0 25069671 10045892 0 0 0 0 0 0 0 140191 1271028 51898 22 4 74
18:10 34 16 0 27210258 17203992 0 0 1 0 0 0 0 220870 2043173 90148 28 8 64

Glance记录
故障期间的:
Total VM : 227.7gb Sys Mem : 41 gb User Mem: 215.2gb Phys Mem : 319.7gb
Active VM: 62.9gb Buf Cache: 1mb Free Mem: 24 gb FileCache: 15.2gb
正常情况:
Total VM : 227.8gb Sys Mem : 40.9gb User Mem: 214.3gb Phys Mem : 319.7gb
Active VM: 79.9gb Buf Cache: 1mb Free Mem: 48.4gb FileCache: 15.2gb
从glance来看,故障与非故障期间:sys/user的内存占用没有什么变化,只是体现在free的区别上,差了24G。
(从数据库的角度分析:切换后,该主机的数据库外连接增加了5000多个,按每个外连接会占用5m内存估算,约24G,与free的差别相吻合)

Syslog中内存不足的报错:
Feb 26 15:39:45 w4sd24pa syslog[16347]: malloc() FAILED at file Memory.C, line 375, memory could not be allocated. Process ID 16347 dumping core deliberately!
Feb 26 15:42:40 w4sd24pa sshd[22035]: fatal: fork of unprivileged child failed
Feb 26 15:42:58 w4sd24pa sshd[5302]: error: fork: Not enough space
Feb 26 15:43:29 w4sd24pa sshd[23630]: fatal: xmalloc: out of memory (allocating 263624 bytes) [preauth]
Feb 26 16:03:14 w4sd24pa sshd[22283]: error: do_exec_pty: fork: Not enough space


附件中的两个核心点:
1、When a process is spawned, the kernel will check virtual memory to see if there is space to accommodate the process. First the kernel checks that there is enough RAM available for the new process to run, that is not locked by other processes or used by the kernel. Then the kernel checks to make sure that the new process is able to reserve enough space in the swap area. If either of these tests fails, the process will not spawn or the process will be terminated, and the resulting error messages like those listed above are produced.
2、物理内存与swap的配置比建议要1:1
结合本案例:
物理内存:320G
swap区:物理swap 60G+伪交换320G*3/4=300G,按1:1有配置关系,少了20G,与故障现象相吻合。

因机器前期安装时内存配置没有那么大,如:物理内存240G,swap:60G+240G*3/4=240G 1:1,所以此类问题没有体现。
因此如果机器进行内存扩容,相应的swap区大小也要调整,物理内存与swap的配置比建议要1:1。
硬盘资源充足的话还是建议配置设备swap。