将NFS与vagrant一起使用不会';行不通

将NFS与vagrant一起使用不会';行不通,vagrant,nfs,vagrantfile,Vagrant,Nfs,Vagrantfile,我的档案中有以下内容: config.vm.network :private_network, ip: "10.0.0.103" config.vm.synced_folder ".", "/vagrant/", type: "nfs" 在一个新盒子上做vagrant up,得到: ==> default: Mounting NFS shared folders... The following SSH command responded with a non-zero exit sta

我的档案中有以下内容:

config.vm.network :private_network, ip: "10.0.0.103"
config.vm.synced_folder ".", "/vagrant/", type: "nfs"
在一个新盒子上做
vagrant up
,得到:

==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/app' /vagrant

Stdout from the command:



Stderr from the command:

stdin: is not a tty
mount.nfs: access denied by server while mounting 10.0.0.1:/Users/wayne/app
然后我需要
vagrant重新加载
,它似乎可以工作了。。。但我肯定不该这么做

[更新:日志输出]

INFO retryable: Retryable exception raised: #<Vagrant::Errors::LinuxNFSMountFailed: The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/sonatribe' /vagrant

Stdout from the command:



Stderr from the command:

stdin: is not a tty
mount.nfs: requested NFS version or transport protocol is not supported
>
 INFO ssh: Execute: mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/sonatribe' /vagrant (sudo=true)
 INFO retryable: Retryable exception raised: #<Vagrant::Errors::LinuxNFSMountFailed: The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/sonatribe' /vagrant

Stdout from the command:



Stderr from the command:

stdin: is not a tty
mount.nfs: requested NFS version or transport protocol is not supported
INFO可检索:引发可检索异常:#
infossh:Execute:mount-o'vers=3,udp'10.0.0.1:'/Users/wayne/sonabree'/vagrant(sudo=true)

信息可检索:引发可检索异常:#降级并将基础映像更改为LTS Ubuntu(与XUbuntu相反)似乎可以解决此问题。

对于Linux,我在主机上执行此操作:

systemctl stop nfs-kernel-server.service
systemctl disable nfs-kernel-server.service
systemctl enable nfs-kernel-server.service
systemctl start nfs-kernel-server.service
vagrant plugin install vagrant-vbguest

这可能是由于主机VirtualBox和来宾添加版本不匹配造成的。在这种情况下,在启动日志中的错误行之前,您应该得到:

  ==> default: Checking for guest additions in VM...
  default: The guest additions on this VM do not match the installed version of
  default: VirtualBox! In most cases this is fine, but in rare cases it can
  default: prevent things such as shared folders from working properly. If you see
  default: shared folder errors, please make sure the guest additions within the
  default: virtual machine match the version of VirtualBox you have installed on
  default: your host and reload your VM.
  default:
  default: Guest Additions Version: 5.0.26
  default: VirtualBox Version: 5.1
在我的例子中,将VirtualBox更新为最新版本修复了这个问题

或者,您可以确保在主机上使用vbguest Vagrant插件安装了正确的来宾添加版本:

systemctl stop nfs-kernel-server.service
systemctl disable nfs-kernel-server.service
systemctl enable nfs-kernel-server.service
systemctl start nfs-kernel-server.service
vagrant plugin install vagrant-vbguest

可能是由于操作系统补丁和软件包升级,我的流浪者环境停止工作,让我浪费了大约4个宝贵的小时。这就是我解决问题的方法:我使用Ubuntu18.04和VBOx6

  • 使用
    vagrant插件重新安装vagrant-vbguest插件安装vagrant-vbguest
  • 确保vbox来宾添加内容与VirtualBox匹配。最好安装最新版本
  • 不知怎的,NFS包丢失了,所以sudo apt get install-y NFS服务器
  • 重新启动
  • 使用管理员权限运行以下命令

    sudo systemctl stop nfs-kernel-server.service
    sudo systemctl disable nfs-kernel-server.service
    sudo systemctl enable nfs-kernel-server.service
    sudo systemctl start nfs-kernel-server.service
    
  • 只是为了确定我确实使用了
    vagrant全局状态进行了
    vagrant销毁--prune


  • TL;DR-检查以确保/etc/exports中的所有条目都指向存在的文件夹。如果您删除或重命名了以前配置为NFS共享的任何文件夹,则可能会导致以后在主机和客户端VM之间启动NFS共享的所有尝试失败。

    此线程仍然是搜索结果中此错误的主要原因,还有另一个潜在原因-在/etc/exports中装载失败


    NFS服务器将读取其装载列表的/etc/exports,如果其中配置的条目不再有效(例如,您移动/重命名/删除了文件夹),则会导致NFS服务器无法启动。命令会因您的操作系统而异,但如果检查NFS服务器的状态,您可能会发现由于/etc/exports中的配置问题,NFS无法启动。

    如前所述,有时在linux发行版中未安装NFS服务器时会发生这种情况。说明如何根据您的发行版安装它。这对我今天有用。o/

    您使用的是哪种操作系统?另外,你说重新加载实际上允许NFS工作?主机是OSX Yosemite,来宾是XUbuntu,重新加载允许NFS工作-重新加载时,我不需要重新输入密码,但它可以工作“VAGRANT\u LOG=info VAGRANT up”并粘贴输出。@Hassan done-似乎关键是:mount.nfs:请求的nfs版本或传输协议不受支持降级并将基础映像更改为LTS Ubuntu(与XUbuntu相反)似乎可以解决此问题您是在主机还是在来宾机中执行此操作的?ThanksI是在主机上完成的。仅供参考,这只适用于Linux,不适用于macOS和windows