linux – NFS:服务器脱机时无法卸载NFS共享

当我们的主NFS服务器脱机时,所有已安装共享的客户端都会受到以下影响:

1. `df` does not work (times out)
2. `lsof` does not work (times out)
3. I cannot unmount the share (umount times out)
4. I cannot restart the client PC, the shutdown process gets stuck 
   while trying to umount the dead NFS share: 
   `nfs server not responding still trying`
5. hard reboot (reset) works, but while booting the client PC gets 
   stuck while trying to mount the NFS share

现在我知道如何解决问题nr.我可以将fstab中的条目更改为noauto.但其他问题呢? NFS客户端是否没有智能停止等待死NFS服务器?为什么它会无休止地等待?我可以在某处设置超时,以便无论发生什么,在x秒后他放弃尝试?

最佳答案
是的,这是NFS的本质.客户端将无限期地等待NFS资源返回.信不信由你,它的设计就是这样!

挂载

更好的方法可能是使用autofs等工具根据需要自动挂载NFS共享,而不是无限期地挂载它们.

仅使用NFS

正如@Patrick在评论中指出的那样,您可以通过在挂载NFS共享时使用soft选项来减少此行为.

摘录自来源:http://www.tldp.org/HOWTO/NFS-HOWTO/client.html

soft

If a file request fails, the NFS client will report an error to the process on the client machine requesting the file access. Some programs can handle this with composure, most won’t. We do not recommend using this setting; it is a recipe for corrupted files and lost data. You should especially not use this for mail disks — if you value your mail, that is.

hard

The program accessing a file on a NFS mounted file system will hang when the server crashes. The process cannot be interrupted or killed (except by a “sure kill”) unless you also specify intr. When the NFS server is back online the program will continue undisturbed from where it was. We recommend using hard,intr on all NFS mounted file systems.

在/ etc / fstab文件中

   # device             mountpoint  fs-type    options    dump fsckord
   ...
   master.foo.com:/home  /mnt/home   nfs      rw,soft  0     0
   ...

转载注明原文:linux – NFS:服务器脱机时无法卸载NFS共享 - 代码日志