Apache 2.4,CPU 运行速度高达 100%,原因不明

Apache 2.4,CPU 运行速度高达 100%,原因不明

我正在尝试弄清楚为什么我的服务器的 CPU 消耗如此之高(来自 Apache 2.4)。Ubuntu 16

以下是我目前在“顶部”看到的内容:

root@mail:~# top
top - 12:54:47 up 42 min,  2 users,  load average: 1.96, 1.94, 1.97
Tasks: 178 total,   3 running, 175 sleeping,   0 stopped,   0 zombie
%Cpu(s): 43.5 us, 56.5 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  2044912 total,   214760 free,  1316416 used,   513736 buff/cache
KiB Swap:   262140 total,   255940 free,     6200 used.   638968 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
 6541 www-data  20   0  721368 112640   8528 R 49.8  5.5   1:16.68 /usr/sbin/apach
 6542 www-data  20   0  522556 103532   3504 R 49.8  5.1   1:16.60 /usr/sbin/apach
 3532 mysql     20   0 1112464 151152  17516 S  0.3  7.4   0:01.45 mysqld
 3674 jetty     20   0 2329684 213996  18208 S  0.3 10.5   0:15.11 java
 4526 root      20   0   95404   6776   5836 S  0.3  0.3   0:00.16 sshd
 5866 root      20   0   41816   3888   3172 R  0.3  0.2   0:01.02 top

在网上查找后,我发现了这个strace -p PID功能。我在其中一个有问题的进程上运行了它,得到了数十万个这样的结果:

read(2, 0x7ffcae1de7d3, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7ffcae1de7d3, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7ffcae1de7d3, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7ffcae1de7d3, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7ffcae1de7d3, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7ffcae1de7d3, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7ffcae1de7d3, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7ffcae1de7d3, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7ffcae1de7d3, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7ffcae1de7d3, 1)              = -1 EBADF (Bad file descriptor)

我试图回到这个过程的最初开始处(看看发生了什么),但我无法足够快地做出反应!

它有 2Gb RAM 和 1 CPU,以及 SSD 驱动器。

按照建议,我使用 gdb 测试了相同的过程,并收到此错误:

../sysdeps/unix/syscall-template.S: No such file or directory.

我偶然看到了这个帖子:

http://www.squaregoldfish.co.uk/2013/01/06/debugging-in-ubuntu-12-10-missing-file-syscall-template-s/

他们建议这样做:

sudo apt-get install eglibc-source

我找不到该包,但找到了glibc-source,所以安装了它。不幸的是,我仍然得到同样的错误(即使重启后);

84      ../sysdeps/unix/syscall-template.S: No such file or directory.

经过进一步挖掘,我发现:

root@mail:~# gdb --pid=7708
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Attaching to process 7708
[New LWP 7712]
[New LWP 7713]
[New LWP 7714]
[New LWP 7715]
[New LWP 7716]
[New LWP 7717]
[New LWP 7718]
[New LWP 7719]
[New LWP 7720]
[New LWP 7721]
[New LWP 7722]
[New LWP 7723]
[New LWP 7724]
[New LWP 7725]
[New LWP 7726]
[New LWP 7727]
[New LWP 7728]
[New LWP 7729]
[New LWP 7730]
[New LWP 7731]
[New LWP 7732]
[New LWP 7733]
[New LWP 7734]
[New LWP 7735]
[New LWP 7736]
[New LWP 7737]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007fcc946f051d in read () at ../sysdeps/unix/syscall-template.S:84
84      ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) n
86      in ../sysdeps/unix/syscall-template.S
(gdb) n
0x000055b4134ed9b7 in ap_mpm_podx_check ()
(gdb) n
Single stepping until exit from function ap_mpm_podx_check,
which has no line number information.
0x00007fcc9163935b in ?? () from /usr/lib/apache2/modules/mod_mpm_event.so
(gdb) n
Cannot find bounds of current function
(gdb)

我也有glibc 源安装,所以我很困惑为什么它会出现这个错误:

root@mail:~# apt-get install glibc-source
Reading package lists... Done
Building dependency tree
Reading state information... Done
glibc-source is already the newest version (2.23-0ubuntu7).
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.

如果我执行 a 则locate syscall-template.S不会得到任何结果(即使运行之后updatedb),所以我猜它确实丢失了,但我不确定为什么)

但我还是不确定那是什么意思 :/

相关内容