运行Vagrant时出错

时间:2016-11-02 16:39:44

标签: vagrant virtual-machine virtualbox vagrantfile

最初,我有8台流浪汉机器运行,出了点问题。所以我删除了〜/ VirtualBox \ VMs文件夹中的vms,并将备份的.vmdk文件放在同一个位置。 然后我试着跑了流浪汉...... 但我收到以下错误

使用'virtualbox'提供程序将计算机'virtual-am1'启动...

==> virtual-am1: Importing base box 'centos653'...
==> virtual-am1: Matching MAC address for NAT networking...
==> virtual-am1: Setting the name of the VM: vagrant_virtual-am1_1478100170176_83326
==> virtual-am1: Clearing any previously set network interfaces...
==> virtual-am1: Preparing network interfaces based on configuration...
    virtual-am1: Adapter 1: nat
    virtual-am1: Adapter 2: bridged
==> virtual-am1: Forwarding ports...
    virtual-am1: 22 (guest) => 2203 (host) (adapter 1)
==> virtual-am1: Running 'pre-boot' VM customizations...
   A customization command failed:

["modifyvm", :id, "--name", "virtual-am1"]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["modifyvm", "6dd13964-e648-40cd-932e-3e18be375d31", "--name", "virtual-am1"]

Stderr: VBoxManage: error: Could not rename the directory '/home/vagrant/VirtualBox VMs/vagrant_virtual-am1_1478100170176_83326' to '/home/vagrant/VirtualBox VMs/virtual-am1' to save the settings file (VERR_ALREADY_EXISTS)

VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface IMachine, callee nsISupports

VBoxManage: error: Context: "SaveSettings()" at line 2788 of file VBoxManageModifyVM.cpp

>Please fix this customization and try again.

这就是我的Vagrantfile的样子...... 我们有一个自定义的Vagrant文​​件

# -*- mode: ruby -*-
# vi: set ft=ruby :

#Parse nodes config file
nodes_config = (JSON.parse(File.read("nodes.json")))['nodes']

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.insert_key = false

  config.vm.box = "centos653"
  config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box"
 # config.vm.provision :shell, path: "bootstrap.sh"

  nodes_config.each do |node|
    node_name   = node[0] # name of node
    node_values = node[1] # content of node

    config.vm.define node_name do |config|
      # configures all forwarding ports in JSON array
      ports = node_values['ports']
      ports.each do |port|
        config.vm.network :forwarded_port,
          host:  port[':host'],
          guest: port[':guest'],
          id:    port[':id']
      end

      config.vm.synced_folder "/bits", "/vagrant/bits"
      config.vm.synced_folder "../virtual", "/vagrant/virtual"

      config.vm.hostname = node_values[':hostname']
      #config.vm.network :private_network, ip: node_values[':ip']
      config.vm.network "public_network", bridge: 'enp134s1f0', ip: node_values[':ip']

      config.vm.provider :virtualbox do |vb|
        vb.customize ["modifyvm", :id, "--memory", node_values[':memory']]
        vb.customize ["modifyvm", :id, "--name", node_values[':node']]
        vb.customize ["modifyvm", :id, "--cpus", 8]
      end

    end
  end
end

这就是我的nodes.json文件的样子

{
  "nodes": {
    "virtual-am1": {
      ":node": "virtual-am1",
      ":ip": "192.168.1.50",
      ":hostname": "am1.onefederation.org",
      "ports": [
        {
          ":host": 2203,
          ":guest": 22,
          ":id": "ssh"
        }
      ],
      ":memory": 1024
    },
  }
}

请帮助!!!

1 个答案:

答案 0 :(得分:0)

我发现此错误,您可以使用此修复程序:

删除vagrant中的文件夹项目

rm -rf /home/protobox/VirtualBox VMs/project_folder

转到项目文件夹:

cd /var/www/project_folder

然后重启流浪汉:

vagrant destroy**maybe more**`vagrant destroy -f`
vagrant reload

最后你开始流浪汉

vagrant up
vagrant ssh

或者你可以参考这里:http://getprotobox.com/docs/issues/vbox_rename

祝你好运!

相关问题