gpt4 book ai didi

linux - 无法在 Centos 7 上自动挂载 NFS 共享

转载 作者:太空宇宙 更新时间:2023-11-04 13:01:23 28 4
gpt4 key购买 nike

我全新安装了 Centos 7。我似乎无法从 Centos 客户端自动挂载位于 192.168.254.105:/srv/nfsshare 的 NFS 共享。

然而,手动安装共享非常有效。

/etc/auto.master 已被完全注释掉以简化问题,保留以下行:

/-       /etc/auto.nfsshare 

/etc/auto.nfsshare 包含以下行:

/tests/nfsshare       -fstype=nfs,credentials=/etc/credentials.txt    192.168.254.105:/srv/nfsshare

/etc/credentials.txt 持有:

 user=user
password=password

预期的行为是当我 ls -l/tests/nfsshare 时,我会看到我的文件服务器的 /srv/nfsshare 目录包含的一些文件。

事实并非如此。相反,它什么也没显示。

sudo journalctl --unit=autofs.service 的日志在启动时显示了这一点(启用调试):

 Nov 20 00:25:38 localhost.localdomain systemd[1]: Starting Automounts filesystems on demand...
Nov 20 00:25:38 localhost.localdomain automount[21204]: Starting automounter version 5.0.7-48.el7, master map auto.master
Nov 20 00:25:38 localhost.localdomain automount[21204]: using kernel protocol version 5.02
Nov 20 00:25:38 localhost.localdomain automount[21204]: lookup_nss_read_master: reading master files auto.master
Nov 20 00:25:38 localhost.localdomain automount[21204]: parse_init: parse(sun): init gathered global options: (null)
Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_mount: mtab link detected, passing -n to mount
Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_umount: mtab link detected, passing -n to mount
Nov 20 00:25:38 localhost.localdomain automount[21204]: lookup_read_master: lookup(file): read entry /-
Nov 20 00:25:38 localhost.localdomain automount[21204]: master_do_mount: mounting /-
Nov 20 00:25:38 localhost.localdomain automount[21204]: automount_path_to_fifo: fifo name /run/autofs.fifo--
Nov 20 00:25:38 localhost.localdomain automount[21204]: lookup_nss_read_map: reading map file /etc/auto.nfsshare
Nov 20 00:25:38 localhost.localdomain automount[21204]: parse_init: parse(sun): init gathered global options: (null)
Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_mount: mtab link detected, passing -n to mount
Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_umount: mtab link detected, passing -n to mount
Nov 20 00:25:38 localhost.localdomain automount[21204]: mounted direct on /tests/nfsshare with timeout 300, freq 75 seconds
Nov 20 00:25:38 localhost.localdomain automount[21204]: do_mount_autofs_direct: mounted trigger /tests/nfsshare
Nov 20 00:25:38 localhost.localdomain automount[21204]: st_ready: st_ready(): state = 0 path /-
Nov 20 00:25:38 localhost.localdomain systemd[1]: Started Automounts filesystems on demand.

当我尝试通过 ls -l/tests/nfsshare 强制安装 nfs 共享时,我的日志中出现以下内容:

 Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet: type = 5
Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet_missing_direct: token 21, name /tests/nfsshare, request pid 22057
Nov 20 00:48:05 localhost.localdomain automount[22030]: attempting to mount entry /tests/nfsshare
Nov 20 00:48:05 localhost.localdomain automount[22030]: lookup_mount: lookup(file): looking up /tests/nfsshare
Nov 20 00:48:05 localhost.localdomain automount[22030]: lookup_mount: lookup(file): /tests/nfsshare -> -fstype=nfs,credentials=/etc/credenti...fsshare
Nov 20 00:48:05 localhost.localdomain automount[22030]: parse_mount: parse(sun): expanded entry: -fstype=nfs,credentials=/etc/credentials.tx...fsshare
Nov 20 00:48:05 localhost.localdomain automount[22030]: parse_mount: parse(sun): gathered options: fstype=nfs,credentials=/etc/credentials.txt
Nov 20 00:48:05 localhost.localdomain automount[22030]: [90B blob data]
Nov 20 00:48:05 localhost.localdomain automount[22030]: dev_ioctl_send_fail: token = 21
Nov 20 00:48:05 localhost.localdomain automount[22030]: failed to mount /tests/nfsshare
Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet: type = 5
Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet_missing_direct: token 22, name /tests/nfsshare, request pid 22057
Nov 20 00:48:05 localhost.localdomain automount[22030]: dev_ioctl_send_fail: token = 22

此外,ls -l/tests/nfsshare 实际上会产生错误:

 ls: cannot access nfsshare/: No such file or directory

我该如何解决这个问题?如前所述,手动安装共享工作正常。

最佳答案

我认为问题在于目录 /tests/nfsshare 存在,尝试:

  • 使用 rm -r/tests/nfsshare 删除它
  • 然后强制挂载ls -la/tests/nfsshare

来自此链接 Redhat: 21.2.2. Mounting NFS File Systems using autofs autofs 的目标目录不应该存在,因为它是由 automount 创建的。

希望这对您有所帮助。

关于linux - 无法在 Centos 7 上自动挂载 NFS 共享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33810579/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com