使用Vagrant构建虚拟开发环境的一番不顺利

      不知不觉虚拟化的世界里面又有新玩意出现了,一个叫做Vagrant开始引起人们关注,其使用了Oracle收购的Virtualbox技术,构建一种轻量级的虚拟开发环境,并且可以同时虚拟多台机器,也没有以往虚拟机所带来的系统资源消耗等问题,貌似不错,于是打算实验一番。PS:听说这么个东东还是基于ruby的,不得不感慨,现在ruby的能力大有超越python的趋势。。。

      其他不多说,站在巨人的肩膀上,参考下面两篇先行牛人的文章,一切顺利进行:

     http://www.cnblogs.com/fuyunbiyi/archive/2013/01/13/2858447.html

     http://blog.smdcn.net/article/1308.html

但是,不久问题来了,当配置虚拟容器private network时,只要加上诸如

  “config.vm.network :private_network, ip: "192.168.10.10"

这样的配置,就会必然报错,错误大致如下:

   here was an error while executing `VBoxManage`, a CLI used by Vagrant

for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "create"]

Stderr: 0%...
Progress state: E_INVALIDARG
VBoxManage.exe: error: Failed to create the host-only adapter
VBoxManage.exe: error: Assertion failed: [!aGuid.isValid()] at 'D:	inderboxwin
-4.3srcVBoxMainsrc-serverHostNetworkInterfaceImpl.cpp' (74) in long __cdecl
 HostNetworkInterface::init(class com::Bstr,class com::Bstr,class com::Guid,enum
 __MIDL___MIDL_itf_VirtualBox_0000_0000_0034).
VBoxManage.exe: error: Please contact the product vendor!
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component HostNetworkI
nterface, interface IHostNetworkInterface
VBoxManage.exe: error: Context: "int __cdecl handleCreate(struct HandlerArg *,in
t,int *)" at line 66 of file VBoxManageHostonly.cpp

这下吃瘪了,又中奖了,貌似两位先行大牛都没遇到的问题我遇到了,于是一番度娘搜索无果,vagrant毕竟在国内也算小众,刚刚兴起而已,果断FQ。。。不久料来了。

  参见:https://github.com/puphpet/puphpet/issues/272

原来这是一个oracle virtualbox的bug!在后续版本修正,也只能怪自己当初没有使用最新的Virtualbox了。不过也在过程中发现,vagrant和Virtualbox结合的非常紧密,在Windows这样的异类环境下,必须注意PATH路径的更新和修改,方能是二者协同工作,创建轻量级的容器虚拟环境。

转载请注明《Spenser Sheng的博客》 

原文地址:https://www.cnblogs.com/spenser/p/3548029.html