NFS服务器的IP发生变化时如何解决

NFS服务器的IP发生变化时如何解决

我有一个 Windows NFS 服务器和几个 CentOS linux 服务器,它们正在从中安装卷。 Windows 服务器移至新网络,即使 DNS 正常工作并且 NFS 挂载是通过主机名挂载的,NFS 客户端似乎也记录了 ipaddr 值,该值不再有效。这会导致典型的悬挂式安装 df 问题。我如何追溯解决这个问题?

答案1

如果 IP 地址已更改,那么您可能需要重新启动 NFS 客户端和/或运行umount显式释放已安装服务的命令。但这可能无法完成,因为原来的 NFS 服务现在已经消失了。

我能找到的唯一其他方法就是这个,写在这篇 Linux Journal 文章中,标题为:操作方法:无需重新启动即可释放卡住的 NFS 挂载。我从未使用过这种方法,直到今天也从未听说过这种方法,但仔细研究一下,它听起来确实可行。

另外,我相信您可能会遇到问题,具体取决于 NFS 挂载是否使用 intr/nointr 挂载。您可以在 NFS 手册页 中阅读有关此功能开关的更多信息man nfs

摘抄

intr / nointr  Selects whether to allow signals to interrupt file operations 
               on this mount point. If neither option is specified (or if 
               nointr is specified), signals do  not  interrupt NFS file 
               operations. If intr is specified, system calls return EINTR 
               if an in-progress NFS operation is interrupted by a signal.

               Using the intr option is preferred to using the soft option 
               because it is significantly less likely to result in data
               corruption.

               The  intr  / nointr mount option is deprecated after kernel 
               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.

答案2

这个帖子有对我有用的步骤。简而言之:

  • 将 NFS 服务器的旧 IP 分配给别名。ifconfig eth0:fakenfs Old_IP netmask xxx.xxx.xxx.xxx
  • umount -l /mount
  • 去掉别名:ifconfig eth0:fakenfs down
  • 再次挂载 NFS 共享:mount -a

相关内容