Centos5 报告内存不足

Centos5 报告内存不足

我的网络服务器 CENTOS5 不断出现内存问题。

 -bash: fork: Cannot allocate memory

在我的网站页面上我得到...

 Can't create a new thread (errno 12); if you are not out of available memory, you can 
 consult the   manual for a possible OS-dependent bug in /opt/lampp/htdocs/toplogin.php on line 36
 Could not connect: Can't create a new thread (errno 12); if you are not out of 
 available memory,  you can consult the manual for a possible OS-dependent bug

我有 4GB 的内存,但流量不是很大,不知道到底发生了什么……

 [root@s15433245 lampp]# ps aux
 USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
 root         1  0.0  0.0  10364   748 ?        Ss   Aug03   0:16 init [3]
 postfix   1470  0.0  0.0  54224  2360 ?        S    Aug03   0:00 tlsmgr -l -t unix -u
 root      6029  0.0  0.0  46140  4184 ?        SLs  Aug31   0:00 proftpd: 74.84.118.99:3419:       USER userftp
 root     11890  0.0  0.4  69480 18808 ?        Ss   Sep02   1:50 /opt/lampp/bin/httpd -k start   -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 root     11910  0.0  0.0   9984  1412 ?        S    Sep02   0:00 /bin/sh /opt/lampp/bin/mysqld_safe --datadir=/opt/lampp/var/mysql --pid-file=/opt/lampp/var/mysql/s15433245.onli
 nobody   12177  0.0  0.3  48940 12772 ?        S    Sep02   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   12272  0.3  0.8 215536 34452 ?        Sl   Sep02  65:28 /opt/lampp/sbin/mysqld --basedir=/opt/lampp --datadir=/opt/lampp/var/mysql --plugin-dir=/opt/lampp/lib/mysql/plu
 root     13931  0.0  0.0  96588  3796 ?        Ss   08:00   0:00 sshd: root@pts/0
 root     13933  0.0  0.0  12212  1788 pts/0    Ss   08:00   0:00 -bash
 root     16321  0.0  0.0  46140  4184 ?        SLs  Sep08   0:00 proftpd: 74.84.118.99:6751: USER userftp
 root     16322  0.0  0.0  46144  4184 ?        SLs  Sep08   0:00 proftpd: 74.84.118.99:6761: USER userftp
 root     16342  0.0  0.0  46140  4184 ?        SLs  Sep08   0:00 proftpd: 74.84.118.99:6782: USER userftp
 root     16345  0.0  0.0  46136  4180 ?        SLs  Aug19   0:00 proftpd: 75.5.72.144:52094: USER userftp
 root     16346  0.0  0.0  46136  4180 ?        SLs  Aug19   0:00 proftpd: 75.5.72.144:52115: USER userftp
 root     17440  0.0  0.0  12780   772 ?        S<s  Aug03   0:00 /sbin/udevd -d
 root     17557  0.0  0.0  46136  4184 ?        SLs  Aug15   0:00 proftpd: 74.84.118.99:4172: USER userftp
 root     17559  0.0  0.0  46132  4184 ?        SLs  Aug15   0:00 proftpd: 74.84.118.99:4195: USER userftp
 nobody   19502  0.2  0.4  69984 17280 ?        S    13:56   0:01 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 root     19644  0.0  0.0   5924   624 ?        Ss   Aug03   0:52 syslogd -m 0
 root     21647  0.0  0.0  46132  4184 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:4128: USER userftp
 root     21648  0.0  0.0  46136  4188 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:4140: USER userftp
  root     21749  0.0  0.0  46136  4188 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:4206: USER userftp
  root     21756  0.0  0.0  46136  4188 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:4234: USER userftp
  root     22095  0.0  0.0  46132  4184 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:4805: USER userftp
  root     22126  0.0  0.0  46136  4188 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:4892: USER userftp
  root     23670  0.0  0.0  46128  4176 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:6703: USER userftp
  root     23912  0.0  0.0  46132  4180 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:6988: USER userftp
  root     23914  0.0  0.0  46128  4176 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:1365: USER userftp
  root     24011  0.0  0.0  46132  4180 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:1396: USER userftp
 root     24015  0.0  0.0  46132  4180 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:1421: USER userftp
 root     24033  0.0  0.0  46136  4184 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:1438: USER userftp
 root     25900  0.0  0.0  46136  4180 ?        SLs  Aug23   0:00 proftpd: 74.84.118.99:34857: USER userftp
 root     26130  0.0  0.0  46140  4184 ?        SLs  Aug23   0:00 proftpd: 74.84.118.99:34873: USER userftp
 root     26262  0.0  0.0  46144  4188 ?        SLs  Aug23   0:00 proftpd: 74.84.118.99:34880: USER userftp
nobody   28389  0.3  0.4  70152 17416 ?        S    13:43   0:04 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 root     28399  0.0  0.0  62640  1208 ?        Ss   Aug03   1:24 /usr/sbin/sshd
 root     30128  0.0  0.0  54164  2304 ?        Ss   Aug03   0:57 /usr/libexec/postfix/master
 postfix  30153  0.0  0.0  54412  2432 ?        S    Aug03   0:06 qmgr -l -t fifo -u
 postfix  30231  0.0  0.0  54228  2264 ?        S    14:02   0:00 pickup -l -t fifo -u -c -o content_filter smtp:127.0.0.1:10027
 root     30257  0.0  0.0  20888  1188 ?        Ss   Aug03   0:15 crond
 root     30268  0.0  0.0  46752   812 ?        Ss   Aug03   0:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2
 root     30281  0.0  0.0  46752   540 ?        S    Aug03   0:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2
root     30324  0.0  0.0  46136  4180 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:2005: USER userftp
 root     30462  0.0  0.0  46136  4184 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:2015: USER userftp
root     30466  0.0  0.0  46136  4184 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:2083: USER userftp
 root     30471  0.0  0.0  45352  3228 ?        Ss   Aug16   0:00 proftpd: 74.84.118.99:2118: USER userftp
 root     30478  0.0  0.0  46136  4184 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:2196: USER userftp
 root     30479  0.0  0.0  46132  4180 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:2249: USER userftp
 root     30485  0.0  0.0  46132  4180 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:2566: USER userftp
 root     30503  0.0  0.0  46140  4188 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:8057: USER userftp
 root     30554  0.0  0.0  46132  4184 ?        SLs  Aug12   0:00 proftpd: 74.84.118.99:3931: USER userftp
 root     30580  0.0  0.0  46128  4180 ?        SLs  Aug12   0:00 proftpd: 74.84.118.99:3994: USER userftp
 root     30683  0.0  0.0  46012  3984 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:8751: USER userftp
 root     31775  0.0  0.0  46012  3980 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:9220: USER userftp
 root     31778  0.0  0.0  46016  3984 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:9247: USER userftp
root     31781  0.0  0.0  46012  3980 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:9266: USER root
root     31784  0.0  0.0  46016  3984 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:9278: USER userftp
 root     31812  0.0  0.0  46012  3980 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:9355: USER root
 root     31831  0.0  0.0  46012  3980 ?        SLs  Aug16   0:00 proftpd: 74.84.118.99:9374: USER root
 root     31967  0.0  0.0  46140  4184 ?        SLs  Aug30   0:00 proftpd: 74.84.118.99:23694: USER userftp
 nobody   31988  0.0  0.4  69852 17088 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32019  0.0  0.4  69852 17084 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32020  0.0  0.3  69480 15532 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32023  0.0  0.4  69888 17244 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32039  0.0  0.4  69852 16968 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32041  0.0  0.3  69480 15524 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32044  0.0  0.3  69480 15536 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32063  0.0  0.4  69852 17156 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32066  0.0  0.4  69852 16960 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32067  0.0  0.4  70120 17260 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32068  0.0  0.4  70120 16968 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32070  0.0  0.4  70120 17224 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32099  0.0  0.4  69744 17344 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
  nobody   32101  0.0  0.3  69612 15612 ?        S    14:03   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
  nobody   32115  0.0  0.3  69480 15500 ?        S    14:07   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
  nobody   32116  0.0  0.3  69480 15500 ?        S    14:07   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
  nobody   32117  0.0  0.0      0     0 ?        Z    14:07   0:00 [httpd] <defunct>
  nobody   32118  0.0  0.3  69480 15516 ?        S    14:07   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 nobody   32120  0.0  0.3  69480 15496 ?        S    14:07   0:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5 -E /opt/lampp/logs/error_log
 root     32122  0.0  0.0  10740   992 pts/0    R+   14:07   0:00 ps aux
  root     32512  0.0  0.0  21660   984 ?        Ss   Aug16   0:00 xinetd -stayalive -pidfile /var/run/xinetd.pid

内存使用情况

 free -m
               total       used       free     shared    buffers     cached
 Mem:          4096        362       3733          0          0          0
 -/+ buffers/cache:        362       3733

我刚刚在我的日志中发现了这一点。

 Request exceeded the limit of 10 internal redirects due to probable configuration error. Use       'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.




 core file size          (blocks, -c) 0
 data seg size           (kbytes, -d) unlimited
 scheduling priority             (-e) 0
 file size               (blocks, -f) unlimited
 pending signals                 (-i) 138240
 max locked memory       (kbytes, -l) 32
 max memory size         (kbytes, -m) unlimited
 open files                      (-n) 1024
 pipe size            (512 bytes, -p) 8
 POSIX message queues     (bytes, -q) 819200
 real-time priority              (-r) 0
 stack size              (kbytes, -s) 10240
 cpu time               (seconds, -t) unlimited
 max user processes              (-u) 138240
 virtual memory          (kbytes, -v) unlimited
 file locks                      (-x) unlimited

答案1

ulimit -a将显示对进程施加的资源限制。如果您发现任何可疑的限制,请将其增加。如果您想在此处发布该命令的输出,我可以进一步提供帮助。另请检查 /etc/security/limits.conf。

在发布 ulimit -a 输出后,我认为这不一定是操作系统级别的问题。您是否检查过 apache/php 配置以查看是否存在任何内存限制?Web 服务通常具有相当严格的每个线程限制,因此这是我怀疑的下一个罪魁祸首。除非您对安全性非常有信心,否则我不鼓励在此处发布所有配置文件,但请检查文档以了解是否存在线程/内存限制,希望您能找到罪魁祸首。

相关内容