【问题标题】:Use nfs to for default folder with vagrant将 nfs 用于带有 vagrant 的默认文件夹
【发布时间】:2014-10-27 19:22:47
【问题描述】:

我想用 virtualbox 将一个大项目(5000 个文件)迁移到 vagrant。 众所周知,Virtualbox 共享文件夹对于大型项目来说很慢,所以我想使用 NFS。

但是,我没有找到使用 NFS 代替默认共享文件夹问题的正确方法。当我将代码放在另一个文件夹中并共享它时,它可以工作。但我想将 Vagrant 整合到当前的版本中。

config.vm.synced_folder '.', '/vagrant', nfs: true

不起作用:

exportfs: duplicated export entries:
exportfs:   10.11.12.13:/home/vincent/workspace/gp
exportfs:   10.11.12.13:/home/vincent/workspace/gp

有什么办法可以解决这个奇怪的问题吗?

谢谢。

更新 1

这些参数同样的错误

config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/home/vagrant/gp", nfs: true

这是完整的错误堆栈:

nfsd running
exportfs: duplicated export entries:
exportfs:   10.11.12.13:/home/vincent/workspace/gp
exportfs:   10.11.12.13:/home/vincent/workspace/gp
==> default: Mounting NFS shared folders...
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.11.12.1:'/home/vincent/workspace/gp' /home/vagrant/gp

Stdout from the command:



Stderr from the command:

stdin: is not a tty
mount.nfs: access denied by server while mounting 10.11.12.1:/home/vincent/workspace/gp

【问题讨论】:

    标签: vagrant vagrantfile


    【解决方案1】:

    您可能需要通过在 Vagrantfile 中添加以下行来明确禁用默认同步文件夹,以便将 NFS 共享挂载到 /vagrant

    config.vm.synced_folder ".", "/vagrant", disabled: true

    之后比做一个vagrant reload 看看它是否有效。

    此外,考虑为您的用例使用rsync 类型同步文件夹,我认为它会更好。见https://docs.vagrantup.com/v2/synced-folders/rsync.html

    【讨论】:

    • 感谢您的帮助。我对这些参数有同样的错误:config.vm.synced_folder ".", "/vagrant", disabled: true config.vm.synced_folder ".", "/home/vagrant/gp", nfs: true
    • 直接更新问题,并添加完整的错误堆栈。
    • 使用 rsync 是一个很好的解决方案,因为 /vagrant 文件夹上使用的 NFS 存在错误(类似于“nfsnohostip”)。这就是我在 Vagrantfile 中所做的:# Disable nfs for main folder because nohostip issue。 cf : github.com/mitchellh/vagrant/issues/4192 config.nfs.functional = false config.vm.provider "virtualbox" do |v| # Disable virtualbox shared folder: really slow with 1000+ files. Use nfs or rsync instead v.functional_vboxsf = false end 要使用 rsync 实时同步文件夹,请使用:vagrant rsync-auto
    • RSync 也救了我的命。刚刚将 config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/" 添加到我的 Vagrantfile 中。另请注意,rsync__auto 在 Vagrant 中默认设置为 true
    【解决方案2】:

    如果您尝试在另一个先前创建的 vm 之上的目录中创建 vm,也可能会收到此错误消息。您需要销毁每个子目录中的虚拟机。

    【讨论】:

      猜你喜欢
      • 2014-02-07
      • 1970-01-01
      • 1970-01-01
      • 2014-12-29
      • 2016-04-25
      • 2015-11-12
      • 1970-01-01
      • 1970-01-01
      • 2016-01-08
      相关资源
      最近更新 更多