使用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:2222default: SSH username: vagrantdefault: SSH auth method: private keydefault: 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 thatVagrant was unable to communicate with the guest machine withinthe 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 modevb.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: natdefault: 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:2222default: SSH username: vagrantdefault: SSH auth method: private keydefault: 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/nullStdout 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 错误记录相关推荐

  1. php输出mysql错误日志_PHP_PHP中把错误日志保存在系统日志中(Windows系统),【将错误记录到系统日志中】 - phpStudy...

    PHP中把错误日志保存在系统日志中(Windows系统) [将错误记录到系统日志中] 在 php.ini 中将 error_log 设置为: error_log = syslog 或者在运行时使用 i ...

  2. 【错误记录】Android Studio 编译报错 ( Could not determine java version from ‘11.0.8‘. ② | 升级 Gradle 版本 )

    文章目录 一.报错信息 二.解决方案 解决 Could not determine java version from '11.0.8'. 问题 , 有两种方案 , 方案一 : Android Stu ...

  3. 【错误记录】VMware 虚拟机报错 ( 向 VMWare 虚拟机中的 Ubuntu 系统拷贝文件时磁盘空间不足 ② | 删除交换空间 )

    文章目录 一.报错信息 二.解决方案 一.报错信息 在 [错误记录]VMware 虚拟机报错 ( 向 VMWare 虚拟机中的 Ubuntu 系统拷贝文件时磁盘空间不足 ) 博客中 , 给出了解决方案 ...

  4. 【错误记录】Ubuntu 修改 hosts 文件 ( 使用 gedit /etc/hosts 命令打开并修改 hosts 文件 )

    文章目录 一.报错信息 二.解决方案 一.报错信息 参考 [错误记录]git clone 报错 ( fatal: unable to access 'https-':gnutls_handshake( ...

  5. 【错误记录】未安装该应用 ( 在 Android 12 之后 组件设置 android:exported=“false“ 属性 )

    文章目录 一.报错信息 二.解决方案 一.报错信息 报错信息 : 点击应用图标后 , 应用并未启动 , 并弹出 " 未安装该应用 " 提示信息 ; 二.解决方案 排查了一下相关地方 ...

  6. 【错误记录】GitHub 网站和仓库无法访问 ( 域名重定向 | 检查 C:\Windows\System32\drivers\etc\hosts 配置文件中的 GitHub 地址域名配置 )

    文章目录 一.报错信息 二.解决方案 一.报错信息 在家里的电脑中 , 出现 无法访问 GitHub 网站 , 使用任何手段都无法访问 GitHub ; 二.解决方案 家里的电脑比较乱 , 使用了各种 ...

  7. 【错误记录】IntelliJ IDEA 编译 Groovy 报错 ( GroovyRuntimeException: This script or class could not be run. )

    文章目录 一.错误记录 二.问题分析 一.错误记录 运行 class Student1 {} Groovy 代码 , 会报错 ; 报错信息 : groovy.lang.GroovyRuntimeExc ...

  8. 【错误记录】GitHub 提交报错 ( OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 )

    文章目录 一.报错信息 二.解决方案 一.报错信息 GitHub 提交报错 : 16:37:19.781: [ClassLoader_Demo] git -c credential.helper= - ...

  9. 【错误记录】记录 Android 命令行执行 Java 程序中出现的错误 ( dx 打包 PC 可执行文件报错 | dalvik 命令执行 kotlin 编译的 dex 文件报错 )

    文章目录 前言 一.Android 命令行与 PC 可执行 JAR 文件不兼容 二.Android 命令行使用 dalvik 命令不能直接执行 Kotlin 编译的 dex 文件 前言 尝试在 And ...

  10. 【错误记录】Visual Studio 中配置 NDK 头文件路径 ( NDK 的三个头文件路径 | 与 CPU 架构相关 asm 头文件路径选择 )

    文章目录 一.报错信息 二.解决方案 1.NDK 的三个头文件路径 2.与 CPU 架构相关 asm 头文件路径选择 一.报错信息 参考 [Android 逆向]Android 进程注入工具开发 ( ...

最新文章

  1. 多个tab可以组成一个表单吗 js_11个表单设计小技巧
  2. 参加IBM Rational高峰论坛的会议笔记
  3. 【Android View绘制之旅】主脉络
  4. [读书笔记]高阶函数
  5. “彪悍的代码 不羁的创意”—— 网易云信全国高校MINI开发挑战赛战队招募启动...
  6. 大数据项目交付国标_在紧迫的期限内交付大型项目
  7. iPhone 12概念渲染图流出:乔布斯“遗志”将被继承?
  8. centos7 编译安装 python3.5
  9. 递增的整数序列链表的插入_你所不知道的序列容器
  10. 线程的sleep()方法和yield()方法有什么区别?
  11. 如何利用MATLAB进行数据拟合?
  12. 二维空间:点到直线距离的计算
  13. QQ跳转浏览器php代码,QQ微信域名预防封禁强制跳转至浏览器打开PHP源代码下载...
  14. 【软考-中级】系统集成项目管理工程师【总】
  15. c语言程序与化学有关的程序,化工热力学C语言程序.doc
  16. 画图神器-drawio(配合markdown使用更佳)
  17. 库卡机器人提示“无合适的mam文件“
  18. C语言函数讲义,C语言讲义——指针函数和函数指针
  19. 事理图谱-下一代知识图谱
  20. FLASH透明在360浏览器遨游浏览器等极速模式下失效解决办法

热门文章

  1. 【linux系统学习笔记】Ubuntu文本界面和图像界面的切换
  2. BoxBlur(方框模糊)
  3. 知识图谱中的结构信息建模
  4. python 绘图sns.distplot
  5. 页面置换算法(FIFO、LRU、LFU)c++实现
  6. ENVI学习总结(十四)——高光谱地物识别
  7. Server Tomcat v8.5 Server at localhost was unable to start within 45 seconds. If the server requires
  8. NER中的词汇增强方法(LatticeLSTM、CGN、FLAT、Simple-Lexicon)
  9. Flutter BuildOwner之dirty elements简析
  10. State Processor API:如何读取,写入和修改 Flink 应用程序的状态