NFS 服务器不导出 /etc/exports 中存在的主机

NFS 服务器不导出 /etc/exports 中存在的主机

我有一台在 CentOS 7.2 上运行的 NFS 服务器,我在我的文件中声明的一个(路径/客户端主机)有问题,/etc/exports该服务器应该导出,但不是......

我的/etc/exports文件:

/mnt/data/ host1(rw,all_squash,anonuid=1001,anongid=1001)
/mnt/data/ host2(rw,all_squash,anonuid=1001,anongid=1001)
/mnt/data/ host3(rw,all_squash,anonuid=1001,anongid=1001)
/mnt/data/ host3(rw,all_squash,anonuid=1001,anongid=1001)

我重新启动了我的 nfs 服务器,这样做的exportfs -a输出cat /var/lib/nfs/etab是正确的:

/mnt/data   host1(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=1001,anongid=1001,sec=sys,rw,secure,root_squash,all_squash)
/mnt/data   host2(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=1001,anongid=1001,sec=sys,rw,secure,root_squash,all_squash)
/mnt/data   host3(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=1001,anongid=1001,sec=sys,rw,secure,root_squash,all_squash)
/mnt/data   host4(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=1001,anongid=1001,sec=sys,rw,secure,root_squash,all_squash)

但是当我运行时showmount -e它没有显示 host1 :

/mnt/data host2 host3 host4

实际上我无法/mnt/data从 host1 挂载:

[root@host1 ~]# mount -a
mount.nfs: access denied by server while mounting nfs-server:/mnt/data/

而主机 2、3 和 4 的挂载正常。

PS:有关信息:

  • host1...hostn 可以看到并 ping NFS 服务器
  • SElinux 已被停用以进行测试
  • 服务器和客户端都没有防火墙(虚拟机是相互克隆的)

编辑

感谢您的回复。

strace没有显示太多东西:

stat("/run", {st_mode=S_IFDIR|0755, st_size=960, ...}) = 0
stat("/run/mount/utab", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
getcwd("/root", 4095)                   = 6
readlink("/root/nfs-server:", 0x7ffe3a9ee090, 4096) = -1 ENOENT (No such file or directory)
readlink("/mnt", 0x7ffe3a9edf70, 4096)  = -1 EINVAL (Invalid argument)
readlink("/mnt/data", 0x7ffe3a9edf70, 4096) = -1 EINVAL (Invalid argument)
stat("/sbin/mount.nfs", {st_mode=S_IFREG|S_ISUID|0755, st_size=113400, ...}) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fd1b08f6b50) = 51633
wait4(-1, mount.nfs: access denied by server while mounting nfs-server:/mnt/data/
[{WIFEXITED(s) && WEXITSTATUS(s) == 32}], 0, NULL) = 51633
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=51633, si_status=32, si_utime=0, si_stime=0} ---
close(1)                                = 0
close(2)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

我看到在 host1 端运行服务时没有nfsv4.0-svc服务正在运行:

[root@host1 ~]# ps -aux --forest | grep nfs
root      1199  0.0  0.0      0     0 ?        S<   Feb15   0:00  \_ [nfsiod]

而它正在成功挂载的其他主机上运行/mnt/data

[root@host2 ~]$ ps -ef | grep nfs
root      1296     2  0 févr.15 ?     00:00:00 [nfsiod]
root      1302     2  0 févr.15 ?     00:00:00 [nfsv4.0-svc]

但我不知道这是原因还是结果(即nfsv4.0-svc正在运行,因为安装成功......):它可能是 pb 的来源吗?

答案1

很抱歉上一篇文章没有得到回复...我对 stackexchange 很陌生。

我终于发现了问题:运行showmount -e或时showmount -e [nfs-server DNS],显示的导出不好。

但是在运行时showmount -e localhost或其showmount -e [nfs-server IP]显示了正确的导出(其中包含 host1)。

因此,使用 nfs-server IP 在 host1 上运行我的挂载解决了问题(对于我们基于 DNS 的克隆虚拟机自动化来说太糟糕了......)

我们正在 Azure 上运行或基础设施,因此这个 DNS 问题可能来自它。

谢谢。

亚历克斯.

相关内容