NFS:安装时服务器拒绝访问。客户端是 LXC proxmox(!)

Posted

技术标签:

【中文标题】NFS:安装时服务器拒绝访问。客户端是 LXC proxmox(!)【英文标题】:NFS: access denied by server while mounting. client side is a LXC proxmox(!) 【发布时间】:2017-03-27 12:58:20 【问题描述】:

对不起,我和https://***.com/questions/22246477/mounting-nfs-results-in-access-denied-by-server开始了相同的话题

我从解决方案中完成所有步骤,但这对我来说没有任何意义。还是不行。

我有什么:

服务器是 Ubuntu 14.04.5 LTS

客户端是 Ubuntu 14.04.2 LTS - 即 proxmox LXC

#cat /etc/exports

/nfs        192.168.88.0/24(ro,fsid=0,insecure,no_root_squash,no_subtree_check,sync)
/nfs/keycdn 192.168.88.0/24(rw,nohide,insecure,no_root_squash,no_subtree_check,sync)

如果我从服务器运行此命令:

mount 192.168.88.185:/nfs/keycdn /mnt

它已安装,并且可以工作 - 我可以创建一个文件

如果我在客户端运行,我会收到错误:

root@kafka-02:/# mount 192.168.88.185:/nfs/keycdn /mnt
mount.nfs: access denied by server while mounting 192.168.88.185:/nfs/keycdn

我对文件夹拥有这样的权限: 服务器

#ll /nfs/
drwxrwxrwx  3 nobody nogroup 4096 Mar 27 13:49 ./
drwxr-xr-x 24 root   root    4096 Mar 27 12:41 ../
drwxrwxrwx  2 nobody nogroup 4096 Mar 27 15:17 keycdn/

为了在修改 /etc/exports 后生效,我运行了 exportfs -rav 和 service nfs-kernel-server restart

我尝试在客户端的 /etc/fstab 中定义 nfs 的版本。但没有效果

在服务器和客户端上运行 mount 命令有详细说明:

服务器

mount -vvvvvv 192.168.88.185:/nfs/keycdn /mnt
mount: fstab path: "/etc/fstab"
mount: mtab path:  "/etc/mtab"
mount: lock path:  "/etc/mtab~"
mount: temp path:  "/etc/mtab.tmp"
mount: UID:        0
mount: eUID:       0
mount: no type was given - I'll assume nfs because of the colon
mount: spec:  "192.168.88.185:/nfs/keycdn"
mount: node:  "/mnt"
mount: types: "nfs"
mount: opts:  "(null)"
mount: external mount: argv[0] = "/sbin/mount.nfs"
mount: external mount: argv[1] = "192.168.88.185:/nfs/keycdn"
mount: external mount: argv[2] = "/mnt"
mount: external mount: argv[3] = "-v"
mount: external mount: argv[4] = "-o"
mount: external mount: argv[5] = "rw"
mount.nfs: timeout set for Mon Mar 27 15:51:33 2017
mount.nfs: trying text-based options 'vers=4,addr=192.168.88.185,clientaddr=192.168.88.185'
mount.nfs: mount(2): No such file or directory
mount.nfs: trying text-based options 'addr=192.168.88.185'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 192.168.88.185 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=17
mount.nfs: trying 192.168.88.185 prog 100005 vers 3 prot UDP port 34598

客户 vers=3

mount -o 'vers=3' -vvvvvvv 192.168.88.185:/nfs/keycdn /mnt
mount: fstab path: "/etc/fstab"
mount: mtab path:  "/etc/mtab"
mount: lock path:  "/etc/mtab~"
mount: temp path:  "/etc/mtab.tmp"
mount: UID:        0
mount: eUID:       0
mount: no type was given - I'll assume nfs because of the colon
mount: spec:  "192.168.88.185:/nfs/keycdn"
mount: node:  "/mnt"
mount: types: "nfs"
mount: opts:  "vers=3"
mount: external mount: argv[0] = "/sbin/mount.nfs"
mount: external mount: argv[1] = "192.168.88.185:/nfs/keycdn"
mount: external mount: argv[2] = "/mnt"
mount: external mount: argv[3] = "-v"
mount: external mount: argv[4] = "-o"
mount: external mount: argv[5] = "rw,vers=3"
mount.nfs: timeout set for Mon Mar 27 15:52:32 2017
mount.nfs: trying text-based options 'vers=3,addr=192.168.88.185'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 192.168.88.185 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=17
mount.nfs: trying 192.168.88.185 prog 100005 vers 3 prot UDP port 34598
mount.nfs: mount(2): Permission denied
mount.nfs: access denied by server while mounting 192.168.88.185:/nfs/keycdn

vers=4

mount -o 'vers=4' -vvvvvvv 192.168.88.185:/nfs/keycdn /mnt
mount: fstab path: "/etc/fstab"
mount: mtab path:  "/etc/mtab"
mount: lock path:  "/etc/mtab~"
mount: temp path:  "/etc/mtab.tmp"
mount: UID:        0
mount: eUID:       0
mount: no type was given - I'll assume nfs because of the colon
mount: spec:  "192.168.88.185:/nfs/keycdn"
mount: node:  "/mnt"
mount: types: "nfs"
mount: opts:  "vers=4"
mount: external mount: argv[0] = "/sbin/mount.nfs"
mount: external mount: argv[1] = "192.168.88.185:/nfs/keycdn"
mount: external mount: argv[2] = "/mnt"
mount: external mount: argv[3] = "-v"
mount: external mount: argv[4] = "-o"
mount: external mount: argv[5] = "rw,vers=4"
mount.nfs: timeout set for Mon Mar 27 15:56:55 2017
mount.nfs: trying text-based options 'vers=4,addr=192.168.88.185,clientaddr=192.168.88.252'
mount.nfs: mount(2): Permission denied
mount.nfs: access denied by server while mounting 192.168.88.185:/nfs/keycdn

【问题讨论】:

我想,如果你把这个问题发到askubuntu.com 网站上,这个问题会得到更多的关注。 谢谢。我也会尝试在 askubuntu 上发帖。 【参考方案1】:

此答案仅在您使用 LXC proxmox, 时才有帮助,但我认为您也应该在其他情况下尝试他的。

问题出在 proxmox 方面。 Proxmox 有 apparmor,而那个东西正在阻止一切。

要停止 apparmor 并使他无法工作,请执行以下步骤

# /etc/init.d/apparmor stop
# /etc/init.d/apparmor teardown
# update-rc.d apparmor disable

在这一步之后,一切都开始像魅力一样工作

【讨论】:

我在 Proxmox 容器上遇到了这个问题,您的回答是关键...谢谢。【参考方案2】:

如果您不想禁用 apparmor,还有更优雅的方法可以做到这一点 打开这个文件/etc/apparmor.d/lxc/lxc-default-cgns 并添加这一行

mount options=(rw, nosuid, noexec, remount, relatime, ro, bind),

然后我们应该重新阅读 apparmor 配置文件 - 运行命令

apparmor_parser -R /etc/apparmor.d/

这个答案取自https://forum.proxmox.com/threads/lxc-apparmor-denied-operation-mount-error-13.36173/

【讨论】:

【参考方案3】:

我在共享硬盘文件夹时遇到了这个问题。当我首先在本地安装硬盘文件夹并共享安装的文件夹时,它起作用了。我已经详细回答了here。

【讨论】:

以上是关于NFS:安装时服务器拒绝访问。客户端是 LXC proxmox(!)的主要内容,如果未能解决你的问题,请参考以下文章

linux下nfs客户机挂载服务器上的共享目录时,出现权限不够的错误,怎么解决?

windows访问NFS出错

nfs

Linux 客户端访问 NFS报Permission Denied错误

windows 怎么访问nfs服务器

ubuntu 中的 NFS 服务器和客户端安装