CPU 100% 空闲但仍显示平均负载

har*_*aut 4 central-processing-unit load-average

我有一台装有CentOS 6.4的刀片服务器。

在空闲状态下,它显示的恒定负载平均值大于 1。但是我准备了另一台具有相同硬件和 CentOS 版本的机器,它的负载平均值在空闲时保持在 0 左右。

top的输出如下:

top - 10:23:04 up 156 days, 18:15,  1 user,  load average: 1.08, 1.35, 1.31
Tasks: 534 total,   1 running, 533 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  65959040k total, 10021484k used, 55937556k free,   167092k buffers
Swap: 32767992k total,    13884k used, 32754108k free,  7084024k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
20951 root      20   0 15396 1608  952 R  0.3  0.0   0:01.52 top
    1 root      20   0 19352  684  472 S  0.0  0.0   0:01.64 init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.03 kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:15.31 migration/0
    4 root      20   0     0    0    0 S  0.0  0.0   0:12.32 ksoftirqd/0
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    6 root      RT   0     0    0    0 S  0.0  0.0   0:17.45 watchdog/0
    7 root      RT   0     0    0    0 S  0.0  0.0   0:16.26 migration/1
    8 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/1
    9 root      20   0     0    0    0 S  0.0  0.0   0:18.51 ksoftirqd/1
Run Code Online (Sandbox Code Playgroud)

哪个进程在完全空闲时导致系统平均负载 > 1?

Sob*_*que 6

平均负载并不意味着你认为它意味着什么。这不是关于即时 CPU 使用率,而是关于有多少进程正在等待运行。通常这是因为很多东西都需要 CPU,但并非总是如此。一个常见的罪魁祸首是等待 IO 的进程——磁盘或网络。

尝试运行ps -e v并查找进程状态标志。

state    The state is given by a sequence of characters, for example, "RWNA". The      first character indicates the run state of the process:
D    Marks a process in disk (or other short term, uninterruptible) wait.
I    Marks a process that is idle (sleeping for longer than about 20 seconds).  
L    Marks a process that is waiting to acquire a lock.
R    Marks a runnable process.
S    Marks a process that is sleeping for less than about 20 seconds.
T    Marks a stopped process.
W    Marks an idle interrupt thread.
Z    Marks a dead process (a "zombie").
Run Code Online (Sandbox Code Playgroud)

这是从ps手册页,让你找到一个更详细的有-RD过程可能是特别感兴趣的。

您的顶部输出包含:

Tasks: 534 total,   1 running, 533 sleeping,   0 stopped,   0 zombie
Run Code Online (Sandbox Code Playgroud)

1 个正在运行的进程是导致平均负载的原因。找到它,并弄清楚它在做什么。(编辑:如评论中所述 - 该running过程可能是top。所以忽略它)