2013-06-18 142 views
39

我意识到这基本上是OSCeption(操作系统初始),但我认为它可能对我最有意义(请告诉我是否有更好的选项,这看起来真的很糟糕)。在VMWare虚拟机中运行Vagrant

这种情况: 我有一个Windows 8机器。我喜欢它 - 它适用于除开发以外的任何事情。对于开发,我一直在使用运行Ubuntu的VMWare虚拟机。我已经涉足了使用Cygwin,但它感觉不对。

我现在加入他们一直在使用Vagrant来管理开发环境的项目,所以我需要能够使用Vagrant。但是,从我看到的,Vagrant主要用于在一致的环境中运行代码,但不一定要编写它。如果我想通过SSH进入我的流浪箱来编写代码,那么我将不得不重新配置我的喜好,比如我的.vimrc文件,以及哪些不适用于每台机器。

然后在我的Ubuntu VirtualMachine中安装Vagrant是否有意义?我觉得虚拟机中的虚拟机在某些时候会失控并导致问题。有没有更好的方法来做到这一点?

编辑:所以我试了一下 - 正如我预料的那样,我遇到了一些错误。当我尝试启动机器,我得到了以下错误消息:

Failed to open a session for the virtual machine vagranttest_1371583212. 

VT-x is not available. (VERR_VMX_NO_VMX). 

Result Code: NS_ERROR_FAILURE (0x80004005) 
Component: Console 
Interface: IConsole {db7ab4ca-2a3f-4183-9243-c1208da92392} 

看起来像我的VMware虚拟机不能运行其他虚拟机。任何关于如何去做这件事的想法?

+0

看起来您正在尝试运行嵌入式类型2的虚拟机管理程序。首先,不是所有的hypervisors都支持在其中运行另一个hypervisor(相同或差异)。第二,你真的启用了虚拟机的设置 - CPU - '可视化Intel VT-x或AMD-V'选项吗? –

+4

顺便说一句:只要启用VT-x/AMD-V加速,VirtualBox内部的VirtualBox就是可能的。 –

+0

我可以证实Terry的评论 - 在我以前的地方,我们在vSphere虚拟机内部运行Vagrant虚拟机,以便构建和测试新的核心​​Vagrant框图像:) –

回答

50

今天我遇到了同样的问题。解决方案非常简单。

  1. 关闭vmware虚拟机。
  2. 转到“编辑虚拟机设置”
  3. 转到处理器。那里有三个复选框。
  4. 选中第二个复选框(启用VT-x/AMD-V)
  5. 启动机器。

之后这个virtualbox应该在vmware里面工作。

+1

@ b.long:不,实际上它听起来很粗鲁。我希望我的解决方案能帮助你:) –

+0

确实如此,谢谢! – blong

+0

在使用CentOS安装在VMWare虚拟机上并在CentOS内部使用VirtualBox的情况下,您是否遇到过任何问题?无论我做什么,我的内部虚拟机都运行缓慢。我不希望这样,因为我给了CentOS VM 7140MB的内存,以及来自我的2.7GHz Core i7的2个内核。 当我尝试启动我的内部虚拟机(有或没有Vagrant)时,它们运行缓慢,似乎没有分配太多的内存。在虚拟机引导时,我看到CPU 1和2有点尖峰,然后最终下降,但内存使用量永远不会超过1GB。当试图启动VM时,它会像这样超时:https://gist.github.com/b-long/3ef3a726f9f4d28f4d59 – blong

4

要回答原来的问题以及@ blong的Vagrant论坛帖子,这是我所做的工作。我正在尝试做类似的事情(实际上是Vagrant/VMware托管Vagrant/Vbox),我已经执行了所有我能想到的优化,为我的“主机”虚拟机提供了大量的RAM(24GB)和6个通过设置“将所有虚拟机内存装入保留的主机内存”,并允许每个虚拟机页面文件(否则它们将存在于限制多少虚拟机的系统页面文件中),禁止将虚拟机交换到磁盘(在Windows上发生这种情况)你可以一次运行)。

我正在做的工作一直很完美,我遇到的网络问题是由于我背后的公司代理。一旦我配置了我的虚拟机可以访问互联网,并且全世界都是正确的。

除了在我的示例(Virtualbox)Vagrantfile中已经设置的natdnsproxy1和naddnshostresolver1之外,我必须通过Vagrantfile手动设置--natbindip1和--natnet1。这些设置可以在Virtualbox文档中找到,以获取正确的用法。总结一下,在虚拟机CPU设置中使用VT-x passthrough /“虚拟化”选项,为虚拟机提供足够的内存,不允许在“根”主机上交换内存,并且尽量确保你的网络范围不重叠,否则你会遇到路由问题。

这是我工作的Vagrantfile,它几乎完全基于andreptb的要求,为现代流行的流浪设置。 https://gist.github.com/andreptb/57e388df5e881937e62a

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

# box name into env var, same script can be used with different boxes. Defaults to win7-ie11. 
box_name = box_name = ENV['box_name'] != nil ? ENV['box_name'].strip : 'win7-ie11' 
# box repo into env var, so private repos/cache can be used. Defaults to http://aka.ms 
box_repo = ENV['box_repo'] != nil ? ENV['box_repo'].strip : 'http://aka.ms' 

Vagrant.configure("2") do |config| 
    # If the box is win7-ie11, the convention for the box name is modern.ie/win7-ie11 
    config.vm.box = "modern.ie/" + box_name 
    # If the box is win7-ie11, the convention for the box url is http://aka.ms/vagrant-win7-ie11 
    config.vm.box_url = box_repo + "/vagrant-" + box_name 
    # big timeout since windows boot is very slow 
    config.vm.boot_timeout = 500 

    # rdp forward 
    config.vm.network "forwarded_port", guest: 3389, host: 3389, id: "rdp", auto_correct: true 

    # winrm config, uses modern.ie default user/password. If other credentials are used must be changed here 
    config.vm.communicator = "winrm" 
    config.winrm.username = "IEUser" 
    config.winrm.password = "Passw0rd!" 

    config.vm.provider "virtualbox" do |vb| 
    # first setup requires gui to be enabled so scripts can be executed in virtualbox guest screen 
    #vb.gui = true 
    vb.customize ["modifyvm", :id, "--memory", "1024"] 
    vb.customize ["modifyvm", :id, "--vram", "128"] 
    vb.customize ["modifyvm", :id, "--cpus", "2"] 
    vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] 
    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] 
    vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000] 
    end 
end 

我额外的变化:

# Need the WinRM gem for managing from Linux 
$ sudo gem install winrm 

    config.vm.communicator = "winrm" 
+ config.winrm.host = "localhost" 
    config.winrm.username = "IEUser" 
    config.winrm.password = "Passw0rd!" 
# This one may not be necessary, I added it for completeness 
+ config.vm.guest = :windows 

# In order to USE the two CPUs you need the ioapic 
# Virtualbox gives an error in the GUI and only shows 1 CPU in the VM otherwise 
     vb.customize ["modifyvm", :id, "--cpus", "2"] 
+ vb.customize ["modifyvm", :id, "--ioapic", "on"] 
# We had to modify the network range because we are running Virtualbox inside VMware 
+ vb.customize ["modifyvm", :id, "--natnet1", "192.168.199.0/24"] 

取出+迹象,并添加这些行到Vagrantfile上面,你应该有一个相当的工作系统,我一直使用的是什么。

+0

我必须添加 v.customize [“modifyvm”,:id ,“--cpus”,“2”] v.customize [“modifyvm”,:id,“ - hwvirtex”,“on”]。 @ dragon788你是如何设定IP地址的? – vodich

+0

@vodich我做的和其他参数一样。 [“modifyvm”,:id,“ - natbindip1”,“true”]。我将仔细检查语法,但基本上它需要修改命令,VM ID,要更改的参数以及将其设置为的值。 – dragon788

+0

谢谢,我想我会在一个关于配置的新线程中询问一个关于配置的问题,而不是我们在这里讨论的,因为我花了6个小时试图弄清楚它没有成功: – vodich

1

如果您在vsphere的VM中运行virualbox,则必须ssh到ESXi才能更新配置。

步骤:

  1. SSH到ESXi服务器。
  2. 找到属于你的虚拟机VMX文件find/-name *.vmx
  3. 执行poweroff你的虚拟机(很重要的,否则你的改变将是覆盖)
  4. 编辑VMX,在该文件的底部添加一个新的配置:vhv.enable = "TRUE"
  5. 虚拟机上的电源
  6. 享受流浪者。 :)
1

我已经在两个VMware产品中尝试了此操作。在虚拟机上单击鼠标右键:

  • 在硬件选项卡上的vCloud Director 5.5 VM属性有一个“暴露的硬件辅助的CPU虚拟化客户机操作系统”复选框,但它变灰我。因人而异。
  • 在vSphere版本5.5.0编辑设置>虚拟硬件> CPU中,该复选框被称为“公开硬件辅助虚拟化到客户操作系统”,并且这对我很有用。
相关问题