使用Vagrant配置本地开发环境
从二零一四年开始使用vagrant+VirtualBox搭建linux开发环境,配置简单灵活,后台运行占用内存少,比vmware好用很多,果断弃用vmware转投vagrant的怀抱;无论是个人搭建开发环境还是团队统一开发环境,vagrant是最方便快捷的方式。
问题一:
但是最近在使用的时候遇到一些坑,记录下来以免下次遇到浪费时间去查找解决;经过是这样的:从家里的agrant打包了一份开发环境到公司的新电脑上,vagrant init {boxname}初始化后使用vagrant up启动虚拟机却一直启动失败,提示如下:
D:\webroot\vagrant>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that Vagrant had when attempting to connect to the machine. These errors are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly working and you're able to connect to the machine. It is a common problem that networking isn't setup properly in these boxes. Verify that authentication configurations are also setup properly,as well.
If the box appears to be booting properly, you may want to increase the timeout ("config.vm.boot_timeout") value.
通过查找资料,在stackowverflow上有网友也遇到过相同问题并给出解决方案如下:
将Vagrantfile配置文件中vb.gui = true的注释去掉
config.vm.provider "virtualbox" do |vb|
# # Don't boot with headless mode
vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
# vb.customize ["modifyvm", :id, "--memory", "1024"]
end
运行vagrant up 启动 virtualbox 后,GUI会给出提示
VT-x/AMD-V硬件加速在您的系统中不可用。您的64-位虚拟机将无法检测到 64-位处理器,从而无法启动。
- 这是由于在BOIS中没有开启cpu虚拟化支持,重启F2或F10等进入BIOS设置Virtualization为Enable(我的Thinkpad是Security=>Virtualizatio设置为Enable);
- 电脑重启后,再次vagrant up启动虚拟机还是有一些问题,当时也没有记录下来错误信息,只记得解决方案是使用vagrant destroy将虚拟机从磁盘中删除,然后使用vagrant up命令重新创建。
问题二 (2015.5.7更新)
vagrant启动报错The following SSH command responded with a non-zero exit status.
D:\vagrant_web>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 80 => 8080 (adapter 1)
default: 3000 => 3000 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
ARPCHECK=no /sbin/ifup eth1 2> /dev/null
Stdout from the command:
Device eth1 does not seem to be present, delaying initialization.
Stderr from the command:
解决方案
虽然vagrant up启动报错,但是vagrant ssh还是能登陆虚拟机的,进入虚拟机后,执行如下命令
sudo rm -f /etc/udev/rules.d/70-persistent-net.rules
对, 问题就处在在持久网络设备udev规则(persistent network device udev rules)是被原VM设置好的,再用box生成新VM时,这些rules需要被更新。而这和Vagrantfile里对新VM设置private network的指令发生冲突。删除就好了。
vagrant reload 再次启动就OK。
以上问题完美解决,记录下来,避免忘记!
Vagrant官网 文档齐全.
segment安装使用方法 网友分享的使用说明,简单明了!
使用Vagrant配置本地开发环境的更多相关文章
- Windows下配置Java开发环境
学习Java第一步是配置本地开发环境,学习最基本的桌面开发,下面以win7为例配置Java开发环境,即:JDK+JRE+Eclipse,安装JDK的时候会默认安装JRE,根据提示安装就可以了. 首先去 ...
- 【OpenStack】OpenStack系列1之OpenStack本地开发环境搭建&&向社区贡献代码
加入OpenStack社区 https://launchpad.net/,注册用户(597092663@qq.com/Admin@123) 修改个人信息,配置SSH keys.OpenPGP keys ...
- 如何利用Vagrant快速搭建相同配置的开发环境?
作为一名程序猿,我们常常会遇到需要搭建开发环境的问题,特别是在新入职的时候,sublime, node, apache, mysql, php等等以及各种框架的安装.如果入职的是大公司有可能这些必要的 ...
- 配置https and http2 local本地开发环境
今天,几乎所有你访问的网站都是受HTTPS保护的.如果你还没有这样做,是时候这样做了.使用HTTPS保护您的服务器也就意味着您无法从非HTTPS的服务器发送请求到此服务器.这对使用本地开发环境的开发人 ...
- spark-windows(含eclipse配置)下本地开发环境搭建
spark-windows(含eclipse配置)下本地开发环境搭建 >>>>>>注意:这里忽略JDK的安装,JDK要求是1.8及以上版本,请通过 java ...
- vue-router History 本地开发环境和nginx配置
vue-router mode=history本地开发环境配置 解决方法1.修改webpack的的devServer配置项(devServe存在于,rvue-cli2在webapck.config.j ...
- UPUPW Apache5.5系列本地开发环境配置
UPUPW Apache5.5系列 1. 在官网下载 Apache5.5系列,选择云端下载. 官网地址: http://www.upupw.net/aphp55/n110.html 2. 下载后,将压 ...
- 使用 Vagrant 打造跨平台开发环境
Vagrant 是一款用来构建虚拟开发环境的工具,非常适合 php/python/ruby/java 这类语言开发 web 应用,“代码在我机子上运行没有问题”这种说辞将成为历史. 我们可以通过 Va ...
- 使用 Vagrant 打造跨平台开发环境fffff
Vagrant 是一款用来构建虚拟开发环境的工具,非常适合 php/python/ruby/java 这类语言开发 web 应用,“代码在我机子上运行没有问题”这种说辞将成为历史. 我们可以通过 Va ...
随机推荐
- K2 BPM_快消零售连锁行业门店选址解决方案_十年专注业务流程管理系统
>>>业务流程管理软件选型攻略 快消零售连锁行业门店选址解决方案 业内有句名言:“门店最重要的是什么?第一是选址,第二是选址,第三还是选址” 选址是一个很复杂的综合性商业决策过 ...
- LINUX学习笔记——LINUX下EXP命令全库备份数据库文件
LINUX下EXP命令全库备份数据库文件 1)建立备份目录,目录操作权限授权给Oracle用户 mkdir /backup --创建backup文件夹 cd / --进入cd语句 ls -l ...
- CSRF(cross-site request forgery )跨站请求攻击
CSRF(cross-site request forgery )跨站请求伪造,攻击者盗用了你的身份,以你的名义发送恶意请求,对服务器来说这个请求是完全合法的,但是却完成了攻击者所期望的一个操作,通过 ...
- Nginx中ngx_http_log_module模块
指定⽇日志格式记录请求指令: access_log设置缓冲⽇日志写⼊入的路路径,格式和配置Syntax: access_log path [format[buffer=size] [gzip[=lev ...
- WCF之.NET Remoting通讯
一.NET Remoting 介绍 简介 .NET Remoting与MSMQ不同,它不支持离线可得,另外只适合.NET平台的程序进行通信.它提供了一种允许对象通过应用程序域与另一个对象进行交互的框架 ...
- SQLCommand命令、DbTransaction事务
一.SqlDataReader SqlConnection conn = new SqlConnection("server=10.126.64.11;user=it_oper;pwd=IT ...
- Codeforces Round #554 (Div. 2) F2. Neko Rules the Catniverse (Large Version) (矩阵快速幂 状压DP)
题意 有nnn个点,每个点只能走到编号在[1,min(n+m,1)][1,min(n+m,1)][1,min(n+m,1)]范围内的点.求路径长度恰好为kkk的简单路径(一个点最多走一次)数. 1≤n ...
- Ubuntu 执行 apt-get install ××× 报错
执行apt-get install fcitx时,报如下错误 grub-pc E: Sub-process /usr/bin/dpkg returned an error code (1) 通过执行下 ...
- SIGAI深度学习第六集 受限玻尔兹曼机
讲授玻尔兹曼分布.玻尔兹曼机的网络结构.实际应用.训练算法.深度玻尔兹曼机等.受限玻尔兹曼机(RBM)是一种概率型的神经网络.和其他神经网络的区别:神经网络的输出是确定的,而RBM的神经元的输出值是不 ...
- Codeforces Round #595 (Div. 3) A,B,C,D
A题:n个学生,分成任意组,要求每组中任意两名学生的技能值相差不等于1,问最小分组. #include<bits/stdc++.h> using namespace std; #defin ...