windows 在 VMWare VM 中运行 Vagrant
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17175696/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running Vagrant Inside VMWare VM
提问by Josh
I realize this is essentially OSCeption (Operating System Inception), but I think it might make the most sense for me (please tell me if there's a better option, this seems really awful).
我意识到这本质上是 OSCeption(操作系统启动),但我认为这对我来说可能最有意义(请告诉我是否有更好的选择,这看起来真的很糟糕)。
Here's the situation:I have a windows 8 machine. I like it - it works great for everything but development. For development, I've been using a VMWare virtual machine running Ubuntu. I've dabbled with using Cygwin, but it just didn't feel right.
情况是这样的:我有一台 Windows 8 机器。我喜欢它 - 它适用于除开发之外的所有事情。对于开发,我一直在使用运行 Ubuntu 的 VMWare 虚拟机。我曾尝试使用 Cygwin,但感觉不太对劲。
I'm now joining a project where they've been using Vagrant to manage development environments so I need to be able to use Vagrant. But, from what I've seen, Vagrant is mainly used to run code within a consistent environment, but not necessarily to write it. And if I wanted to write code by SSH'ing into my vagrant boxes, then I would have to re-configure my preferences like my .vimrc file and what not for every machine.
我现在加入了一个他们一直在使用 Vagrant 来管理开发环境的项目,所以我需要能够使用 Vagrant。但是,据我所知,Vagrant 主要用于在一致的环境中运行代码,但不一定用于编写代码。如果我想通过 SSH 将代码写入我的流浪盒子,那么我将不得不重新配置我的首选项,比如我的 .vimrc 文件,而不是每台机器的配置。
Does it then make sense to install Vagrant within my Ubuntu VirtualMachine? I feel like at some point VMs within VMs will get out of hand and cause problems. Is there any better way to do this?
那么在我的 Ubuntu 虚拟机中安装 Vagrant 有意义吗?我觉得在某些时候虚拟机中的虚拟机会失控并导致问题。有没有更好的方法来做到这一点?
Edit:So I tried it out - as I expected I hit some errors. When I try and boot the machine, I get the following error message:
编辑:所以我试了一下 - 正如我所料,我遇到了一些错误。当我尝试启动机器时,我收到以下错误消息:
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}
Looks like my vmware virtual machine can't run another virtual machine. Any ideas on the best way to go about doing this?
看起来我的 vmware 虚拟机无法运行另一个虚拟机。关于执行此操作的最佳方法的任何想法?
回答by Andrew Orsich
I've run into the same issue today. The solution is quite simple.
我今天遇到了同样的问题。解决方法很简单。
- Power off vmware vitrual machine.
- Go to "edit virtual machine settings"
- Go to processors. There are three checkboxes there.
- Check second checkbox (enable VT-x/AMD-V)
- Power on machine.
- 关闭 vmware 虚拟机。
- 转到“编辑虚拟机设置”
- 去处理器。那里有三个复选框。
- 选中第二个复选框(启用 VT-x/AMD-V)
- 打开机器电源。
After this virtualbox should work inside vmware.
在这个 virtualbox 应该在 vmware 中工作之后。
回答by dragon788
To answer the original question as well as @blong's Vagrant forum post, this is what I've done to make this work.
为了回答原始问题以及@blong 的 Vagrant 论坛帖子,这就是我为完成这项工作所做的工作。
I was trying to do something similar myself (actually Vagrant/VMware hosting Vagrant/Vbox) and I have performed all the optimizations I can think of, giving my "host" VM a large amount of RAM (24GB) and 6 cores, disabling swapping VMs to disk (this KILLS things on Windows when it happens) by setting "Fit all VM memory into reserved host memory", and allowing per VM page files (otherwise they live in the system page file which limits how many VMs you can run at once).
我试图自己做类似的事情(实际上是 Vagrant/VMware 托管 Vagrant/Vbox)并且我已经执行了我能想到的所有优化,为我的“主机”VM 提供大量 RAM(24GB)和 6 个内核,禁用交换通过设置“将所有 VM 内存放入保留的主机内存”并允许每个 VM 页面文件(否则它们位于系统页面文件中,这会限制您可以运行的 VM 数量)一次)。
What I am doing has been working perfectly, the networking issues I've had were due to the corporate proxy I'm behind. Once I configured that my VM got internet access and all was right with the world.
我正在做的工作一直很好,我遇到的网络问题是由于我支持的公司代理。一旦我配置了我的虚拟机可以访问互联网并且一切正常。
I did have to manually set --natbindip1 and --natnet1 via the Vagrantfile in addition to the natdnsproxy1 and naddnshostresolver1 that were already set in my example (Virtualbox) Vagrantfile. These settings can be found in the Virtualbox documentation for the correct usage.
除了在我的示例(Virtualbox)Vagrantfile 中已经设置的 natdnsproxy1 和 naddnshostresolver1 之外,我确实必须通过 Vagrantfile 手动设置 --natbindip1 和 --natnet1。这些设置可以在 Virtualbox 文档中找到以了解正确用法。
To sum it up, use the VT-x passthrough/"virtualize" option in your VM CPU settings, give the VM adequate memory, don't allow that memory to be swapped on the "root" host machine, and try to make sure your network ranges don't overlap or you'll have routing trouble.
总而言之,在 VM CPU 设置中使用 VT-x passthrough/“virtualize”选项,为 VM 提供足够的内存,不允许在“root”主机上交换该内存,并尝试确保您的网络范围不重叠,否则您将遇到路由问题。
Here is the Vagrantfile I was working from, it is based almost entirely on andreptb's gist for the modern.ie vagrant setup. https://gist.github.com/andreptb/57e388df5e881937e62a
这是我工作的 Vagrantfile,它几乎完全基于 andreptb 的现代.ie vagrant 设置要点。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
My additional changes:
我的额外变化:
# 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"]
Remove the + signs and add those lines into the Vagrantfile above and you should have an equivalent working system to what I've been using.
删除 + 符号并将这些行添加到上面的 Vagrantfile 中,您应该有一个与我一直在使用的系统等效的工作系统。
回答by Matthewgao
If you are running virualbox in a VM in vsphere, you have to ssh to the ESXi to update a configuration.
如果您在 vSphere 的虚拟机中运行 virualbox,则必须通过 ssh 连接到 ESXi 以更新配置。
Steps:
脚步:
- ssh to ESXi server.
- find the vmx file which belong to your VM
find / -name *.vmx
- poweroff your VM.(very important, or your change will be overwrite)
- edit that vmx, append a new configuration at the bottom of the file:
vhv.enable = "TRUE"
- power on your VM
- enjoy the Vagrant. :)
- ssh 到 ESXi 服务器。
- 找到属于您的虚拟机的 vmx 文件
find / -name *.vmx
- 关闭您的虚拟机。(非常重要,否则您的更改将被覆盖)
- 编辑那个 vmx,在文件底部附加一个新配置:
vhv.enable = "TRUE"
- 打开你的虚拟机
- 享受流浪者。:)
回答by tbc0
I have tried this in two VMware products. Right-click on the VM:
我已经在两个 VMware 产品中尝试过这个。右键单击虚拟机:
- In vCloud Director 5.5 VM properties on the Hardware tab there's an "Expose hardware-assisted CPU virtualization to guest OS" checkbox, but it's grayed out for me. YMMV.
- In vSphere Version 5.5.0 Edit Settings > Virtual Hardware > CPU the checkbox is called "Expose hardware assisted virtualization to the guest OS," and that worked for me.
- 在硬件选项卡上的 vCloud Director 5.5 虚拟机属性中,有一个“将硬件辅助的 CPU 虚拟化暴露给来宾操作系统”复选框,但对我来说它是灰色的。天啊。
- 在 vSphere 版本 5.5.0 编辑设置 > 虚拟硬件 > CPU 中,复选框称为“将硬件辅助虚拟化暴露给来宾操作系统”,这对我有用。