我全新安装了Centos 7.我似乎无法从Centos客户端自动安装位于<link rel="stylesheet" href="css/custom.css">
的NFS共享。
然后手动挂载共享,效果很好。
/etc/auto.master 已被完全注释掉以简化问题,除以下一行外:
192.168.254.105:/srv/nfsshare
/etc/auto.nfsshare 包含以下行:
/- /etc/auto.nfsshare
/etc/credentials.txt 成立:
/tests/nfsshare -fstype=nfs,credentials=/etc/credentials.txt 192.168.254.105:/srv/nfsshare
预期的行为是,当我 user=user
password=password
时,我会看到我的文件服务器 / srv / nfsshare 目录中的一些文件。
没有。相反,它没有显示任何内容。
来自 sudo journalctl --unit = autofs.service 的日志在启动时显示此信息(已启用调试):
ls -l /tests/nfsshare
当我尝试通过 ls -l / tests / nfsshare 强制安装nfs共享时,我的日志中会出现以下内容:
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 实际上会产生错误:
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
如何解决此问题?如前所述,手动安装共享工作正常。
答案 0 :(得分:0)
我认为问题在于目录/tests/nfsshare
存在,请尝试:
rm -r /tests/nfsshare
ls -la /tests/nfsshare
。在此链接Redhat: 21.2.2. Mounting NFS File Systems using autofs中,autofs的目标目录不应存在,因为它是由automount创建的。
希望这有帮助。
答案 1 :(得分:0)
Autofs不会例如挂载在直接文件夹中。我们希望将nfs路径安装到/ var / www / test。
/ var / www包含其他文件。因此,解决该问题的最佳方法是将路径映射到单独的文件夹并创建指向相关路径的链接。
在本地计算机上创建路径
mkdir /mnt/tests/nfsshare
/etc/auto.master-输入以下内容以挂载nfs路径。
/mnt/tests /etc/auto.nfsshare
在/etc/auto.nfsshare
中进行以下输入nfsshare -fstype=nfs,credentials=/etc/credentials.txt 192.168.254.105:/srv/nfsshare
创建指向/ mnt / tests / nfsshare文件夹的链接
ln -s /mnt/tests/nfsshare /var/www/nfsshare