情况:我有一个服务器,上面有2-3个项目.从不久前开始,服务器开始挂起(我们无法通过ssh连接到服务器,连接的客户端必须等待20分钟才能得到结果)
今天早些时候,当gstat处于这种状态时,我成功地执行了gstat,并且看到它在da0、da0s1和da0s1f上保持100%。我不太清楚这些ids是什么意思,但我知道,有些进程只是通过轰炸它的请求而扼杀了HD。
我要求提出一些建议。我不知道如何找到文化坑,也无法阻止这一切。
服务器上有freebsd。
发布于 2011-12-10 19:50:54
如果您的FreeBSD版本相对较现代,top有一个-m选项,如果您向它提供"io“参数,它将显示最高级的I/O对话者:
top -m io在本例中,我还使用了-S选项(以显示系统进程,以防其中一个进程是罪魁祸首)。为了在负载下表现得更好,我将使用-q (将其重命名为以更高的优先级运行)和-u (跳过读取/etc/passwd,这将帮助它更快地加载)。
由于运行top需要很长时间,所以我会告诉它只显示输出的两次传递(-d 2),然后以批处理模式(-b)运行,因此它将自动退出。
在您以这种方式运行top的第一分钟,它的第一部分输出将显示大量进程的累积I/O计数(可能是从启动时开始)?我对此并不确定)。在第一次展示中,您可以看到谁是您的顶级健谈者。在第二次显示中,您可以在过去两秒钟内看到您的顶级健谈者。
因此,将所有这些放在一起,并运行一个find,从而实现一些实际的I/O:
# top -S -m io -qu -b -d 2 10
last pid: 39560; load averages: 0.28, 0.19, 0.08 up 6+04:02:29 11:28:28
125 processes: 2 running, 104 sleeping, 19 waiting
Mem: 96M Active, 668M Inact, 122M Wired, 25M Cache, 104M Buf, 17M Free
Swap: 2048M Total, 96K Used, 2048M Free
PID UID VCSW IVCSW READ WRITE FAULT TOTAL PERCENT COMMAND
11 0 0 81032823 0 0 0 0 0.00% idle: cpu0
39554 105 129857 556534 74894 0 0 74894 13.62% find
39533 105 443603 614796 0 0 0 0 0.00% sshd
36 0 1793393 0 0 0 0 0 0.00% irq23: vr0
24 0 2377710 2680 0 0 0 0 0.00% irq20: atapci0
50 0 533513 3415672 66 345350 0 345416 62.81% syncer
13 0 78651569 7230 0 0 0 0 0.00% swi4: clock sio
5 0 1911601 20905 0 0 0 0 0.00% g_down
4 0 2368511 12100 0 0 0 0 0.00% g_up
37 0 53308 313 0 0 0 0 0.00% acpi_thermal
last pid: 39560; load averages: 0.28, 0.19, 0.08 up 6+04:02:31 11:28:30
125 processes: 2 running, 104 sleeping, 19 waiting
CPU: 1.9% user, 0.0% nice, 6.0% system, 2.2% interrupt, 89.9% idle
Mem: 96M Active, 671M Inact, 123M Wired, 25M Cache, 104M Buf, 14M Free
Swap: 2048M Total, 96K Used, 2048M Free
PID UID VCSW IVCSW READ WRITE FAULT TOTAL PERCENT COMMAND
11 0 0 1115 0 0 0 0 0.00% idle: cpu0
39554 105 606 651 501 0 0 501 100.00% find
39533 105 616 695 0 0 0 0 0.00% sshd
36 0 1251 0 0 0 0 0 0.00% irq23: vr0
24 0 501 20 0 0 0 0 0.00% irq20: atapci0
50 0 2 2 0 0 0 0 0.00% syncer
13 0 313 3 0 0 0 0 0.00% swi4: clock sio
5 0 501 26 0 0 0 0 0.00% g_down
4 0 501 8 0 0 0 0 0.00% g_up
37 0 0 0 0 0 0 0 0.00% acpi_thermal一旦缩小了哪个进程正在执行所有I/O,就可以使用truss或devel/strace或sysutils/lsof端口来查看需要磁盘的进程正在做什么。(当然,如果您的系统非常繁忙,您将无法轻松安装端口):
例如,要查看我的ntpd进程正在使用哪些文件和其他资源:
# lsof -p 890
ntpd 890 root cwd VDIR 0,93 1024 2 /
ntpd 890 root rtd VDIR 0,93 1024 2 /
ntpd 890 root txt VREG 0,98 340940 894988 /usr/sbin/ntpd
ntpd 890 root txt VREG 0,93 189184 37058 /libexec/ld-elf.so.1
ntpd 890 root txt VREG 0,93 92788 25126 /lib/libm.so.5
ntpd 890 root txt VREG 0,93 60060 25130 /lib/libmd.so.4
ntpd 890 root txt VREG 0,98 16604 730227 /usr/lib/librt.so.1
ntpd 890 root txt VREG 0,93 1423460 25098 /lib/libcrypto.so.5
ntpd 890 root txt VREG 0,93 1068216 24811 /lib/libc.so.7
ntpd 890 root 0u VCHR 0,29 0t0 29 /dev/null
ntpd 890 root 1u VCHR 0,29 0t0 29 /dev/null
ntpd 890 root 2u VCHR 0,29 0t0 29 /dev/null
ntpd 890 root 3u unix 0xc46da680 0t0 ->0xc4595820
ntpd 890 root 5u PIPE 0xc4465244 0 ->0xc446518c
ntpd 890 root 20u IPv4 0xc4599190 0t0 UDP *:ntp
ntpd 890 root 21u IPv6 0xc4599180 0t0 UDP *:ntp
ntpd 890 root 22u IPv4 0xc4599400 0t0 UDP heffalump.prv.tycho.org:ntp
ntpd 890 root 23u IPv4 0xc4599220 0t0 UDP ns0.prv.tycho.org:ntp
ntpd 890 root 24u IPv4 0xc45995c0 0t0 UDP imap.prv.tycho.org:ntp
ntpd 890 root 25u IPv6 0xc4599530 0t0 UDP [fe80:4::1]:ntp
ntpd 890 root 26u IPv6 0xc45993b0 0t0 UDP localhost:ntp
ntpd 890 root 27u IPv4 0xc4599160 0t0 UDP localhost:ntp
ntpd 890 root 28u rte 0xc42939b0 0t0..。以及它所调用的系统(请注意,这可能是资源密集型的):
# truss -p 890
SIGNAL 17 (SIGSTOP)
select(29,{20 21 22 23 24 25 26 27 28},0x0,0x0,0x0) ERR#4 'Interrupted system call'
SIGNAL 14 (SIGALRM)
sigreturn(0xbfbfea10,0xe,0x10003,0xbfbfea10,0x0,0x806aed0) ERR#4 'Interrupted system call'
select(29,{20 21 22 23 24 25 26 27 28},0x0,0x0,0x0) ERR#4 'Interrupted system call'
SIGNAL 14 (SIGALRM)
sigreturn(0xbfbfea10,0xe,0x10003,0xbfbfea10,0x0,0x806aed0) ERR#4 'Interrupted system call'
select(29,{20 21 22 23 24 25 26 27 28},0x0,0x0,0x0) ERR#4 'Interrupted system call'
SIGNAL 14 (SIGALRM)
sigreturn(0xbfbfea10,0xe,0x10003,0xbfbfea10,0x0,0x806aed0) ERR#4 'Interrupted system call'
^Csysutils/strace类似于truss,但是您需要安装/proc文件系统:
# strace -p 890
strace: open("/proc/...", ...): No such file or directory
trouble opening proc file
# grep ^proc /etc/fstab
proc /proc procfs rw,noauto 0 0
# mount /proc
# mount | grep /proc
procfs on /proc (procfs, local)..。然后它就会起作用:
# strace -p 890
Process 890 attached - interrupt to quit
--- SIGALRM (Alarm clock: 14) ---
--- SIGALRM (Alarm clock: 14) ---
syscall_417(0xbfbfea10) = -1 (errno 4)
select(29, [?], NULL, NULL, NULL) = -1 EINTR (Interrupted system call)
--- SIGALRM (Alarm clock: 14) ---
--- SIGALRM (Alarm clock: 14) ---
syscall_417(0xbfbfea10) = -1 (errno 4)
select(29, [?], NULL, NULL, NULL^C <unfinished ...>
Process 890 detached祝你好运--让我们知道你发现了什么!一旦您确定了流程(Es),我可能会进一步提供帮助。
编辑:请注意,运行lsof、truss和strace本身可以是密集的。我做了一些小的更新,试图减少它们的影响。另外,如果一个进程正在快速生成许多子进程,您可能必须告诉truss或strace使用-f参数跟踪子进程。
发布于 2012-03-27 17:07:11
过了一段时间我发现了真正的问题。正如我在上次评论中所想的那样,这是一个记忆不足的问题。
炮台是ZODB的ZEO服务器。它非常依赖系统磁盘IO缓存,结果适得其反,当空闲内存不足500 MB时,它开始减速,300 MB时它只使用了太多磁盘,以致系统停止响应,甚至一些服务也开始崩溃(比如sshd)。
在更改缓存结构并释放高达2GB的空闲内存后,该问题已被清除。
https://serverfault.com/questions/339775
复制相似问题