防止断开的 NFS 连接冻结客户端系统

UpT*_*eek 23 nfs

我们有一个 NFS 4 共享,在多个服务器(NFS 服务器和所有 Debian 8 的客户端)之间共享一个卷。我们最近遇到了一些问题,网络中断会冻结客户端系统。

我们的NFS选项是最小的,只是rw(所以默认值hardfg等等)。

我现在正在试验这些选项,但没有得到我期望的行为: rw,soft,bg,retrans=6,timeo=150

(我增加了转发以抵消一些软风险)

我要测试的程序是:

  • 开机机器
  • cd/mnt/mountpoint
  • 验证 NFS 连接正常
  • cd /
  • 杀网 ifdown eth0
  • cd/mnt/mountpoint
  • ls

此时命令行冻结,我无法中断它。 一段时间后,消息“nfs: server [servername] 没有响应,超时”,似乎每分钟重复一次(不确定)。

我希望/期望发生的操作失败并返回控制权。

请有人告诉我这些设置哪里出了问题?

(PS:我也试过用 autofs 挂载,但看到了类似的行为)

谢谢

Bow*_*Red 4

intr当您点击 时,应该可以让您再次获得控制权^C,但通常不会立即获得控制权。

   intr           If an NFS file operation has a major timeout and it is hard mounted, then allow signals to interupt the
                  file  operation  and cause it to return EINTR to the calling program.  The default is to not allow file
                  operations to be interrupted.
Run Code Online (Sandbox Code Playgroud)

正如你所说,期望是这里的问题。网络问题可能是暂时的,但操作失败是永久性的。因此,大多数操作默认只是阻塞,直到操作完成。

这是标准答案,但查看当前的手册页我看到:

                  The  intr / nointr mount option is deprecated after ker-
                  nel 2.6.25.  Only SIGKILL can interrupt  a  pending  NFS
                  operation on these kernels, and if specified, this mount
                  option is ignored  to  provide  backwards  compatibility
                  with older kernels.
Run Code Online (Sandbox Code Playgroud)

所以在我看来这不是一个 NFS3/NFS4 问题,而是一个关于如何intr工作的决定。所以你应该能够完成KILL这个过程,但这可能不会给你带来太多用处。

我找不到有关为什么删除该选项的讨论。你能杀死-KILL你的进程吗?

  • 是的,我试过了,好像没有什么效果。Man 说它在最近的内核版本中被忽略了。 (3认同)