搭建属于你的环境

安装环境有时也是头疼的事,换个电脑就得重装个,还会出现各种兼容问题,vagrant带来很大方便,还支持导出镜像,简直就是移动的系统。降低时间成本,兼容性强,好处多多。安装记录:

安装virtualbox

具体安装包请直接从官网下载:https://www.virtualbox.org/wiki/Downloads

安装 vagrant

下载:https://www.vagrantup.com/downloads.html

安装完成查看版本

$ vagrant -v

vagrant基本命令

vagrant init   #初始化vagrantfile
vagrant add box #添加box,自动生成vagrantfile
vagrant up #启动虚拟机
vagrant halt #关闭虚拟机
vagrant destory #销毁虚拟机
vagrant ssh #进入虚拟机
vagrant reload #重新加载vagrantfile文件
vagrant suspend #暂时挂起
vagrant status #查看虚拟机状态

vagrant 添加系统镜像box

box下载地址: http://www.vagrantbox.es/

$cd /website
$ mkdir -p vagrant/boxes
$ cd vagrant/boxes
$ vagrant add box centos7 centos7-64.box

新建虚拟机

$ cd /website/vagrant
$ vagrant init centos7
$ vagrant up
$ vagrant ssh

相关配置

修改vagrantfile配置

  config.vm.box = "centos7"
config.vm.hostname = "sun" #主机名
config.vm.network "private_network", ip: "192.168.22.20" #私有网络
config.vm.synced_folder "/website", "/home/www", :nfs => true #共享文件夹 开启nfs
#config.vm.network "forwarded_port", guest: 22, host: 2220 #端口映射

重新加载配置

$ vagrant reload

遇到问题

1)

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed! mount -o vers=3,udp 192.168.22.1:/website /home/www Stdout from the command: Stderr from the command: mount.nfs: access denied by server while mounting 192.168.22.1:/website

虽然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 ssh 进入虚拟机

2)共享文件夹挂载失败,mac nfs服务启动不了

tee: /etc/exports: Operation not permitted
tee: /etc/exports: Operation not permitted
tee: /etc/exports: Operation not permitted
The nfsd service does not appear to be running.

解决参考:https://github.com/hashicorp/vagrant/issues/10234

centos7虚拟机安装完成!

贴下有道云地址 http://note.youdao.com/noteshare?id=15da919d1a5f5635d71056cdf11f37af

vagrant 安装虚拟机的更多相关文章

  1. Vagrant安装Docker

    ======方法1=========== 一.vagrant安装centos 1.1 什么是vagrant: Vagrant是一个基于Ruby的工具,用于创建和部署虚拟化开发环境.它 使用Oracle ...

  2. Mac OS 使用 Vagrant 管理虚拟机(VirtualBox)

    Vagrant(官网.github)是一款构建虚拟开发环境的工具,支持 Window,Linux,Mac OS,Vagrant 中的 Boxes 概念类似于 Docker(实质是不同的),你可以把它看 ...

  3. Vagrant安装配置

    转载自:https://my.oschina.net/u/3424381/blog/888205 Vagrant安装配置 实际上Vagrant只是一个让你可以方便设置你想要的虚拟机的便携式工具,它底层 ...

  4. vagrant 安装笔记

    本文档的编写参考慕课网视频教程,感谢慕课网提供的免费教程 http://www.imooc.com/learn/805 搭建一个环境,不需要重复配置,直接利用vagrant复制就可以了 https:/ ...

  5. Vagrant 创建虚拟机

    Vagrant  创建虚拟机 1. 下载相关软件 虚拟机软件:vmware  virtualbox Vagrant 软件:vagrant cd /tmpwget http://download.vir ...

  6. Virtualbox/Vagrant安装

    它们分别是什么? VirtualBox: 号称是最强的免费虚拟机软件和VM类似. 不仅具有丰富的特色,而且性能也很优异. Vagrant: 是一个基于Ruby的工具,用于创建和部署虚拟化开发环境. 使 ...

  7. vagrant安装centos7

    1. 安装VirtualBox 去官网https://www.virtualbox.org/wiki/Downloads下载最新版的Virtualbox,然后双击安装,一直点击确认完成. 2. 安装V ...

  8. VirtualBox + vagrant 使用虚拟机

    1.VirtualBox下载地址 https://www.virtualbox.org/wiki/Downloads 2.vagrant下载地址 https://www.vagrantup.com/d ...

  9. Vagrant 安装Oracle19c RAC测试环境的简单学习

    1. 学习自网站: https://xiaoyu.blog.csdn.net/article/details/103135158 简单学习了下 能够将oracle RAC开起来了 但是 对后期的维护和 ...

随机推荐

  1. 那些H5用到的技术(5)——视差滚动效果

    前言原理使用方式结合swiper.js 前言 视差滚动(Parallax Scrolling)是指让多层背景以不同的速度移动,形成立体的运动效果,带来非常出色的视觉体验. 目前最火热的视差开源库为pa ...

  2. (转)【面试】【MySQL常见问题总结】【03】

    [常见面试问题总结目录>>>] [面试][MySQL常见问题总结][03] 2016-05-29 22:20 阅读(8244) 评论(2) [面试][MySQL常见问题总结][02] ...

  3. 【Lua】LWT后台用JSON与 ExtJS传递数据

    要完成目录树的构建,需要前台ExtJS构筑页面,后台处理逻辑,中间由JSON传递数据. 首先搭建后台环境: require "httpd" require "lfs&qu ...

  4. WPF实现无刷新动态切换多语言(国际化)

    1. 在WPF中国际化使用的是 .xaml文件的格式 如图:Resource Dictionary (WPF) 2. 创建默认的语言文件和其他语言文件 这里以英语为默认语言,新建一个 Resource ...

  5. 九度oj 1464 Hello World for U 2012年浙江大学计算机及软件工程研究生机试真题

    题目1464:Hello World for U 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:3872 解决:1082 题目描述: Given any string of N (> ...

  6. Iterator和ListIterator的区别 ---面试题

    Iterator和ListIterator的区别是什么? 下面列出了他们的区别: Iterator可用来遍历Set和List集合,但是ListIterator只能用来遍历List. Iterator对 ...

  7. 【Bigdecimal】

    ---恢复内容开始--- 大位数除法的时候注意1/3问题:异常:[Exception in thread "main" java.lang.ArithmeticException: ...

  8. [转]How can I install the VS2017 version of msbuild on a build server without installing the IDE?

    本文转自:http://stackoverflow.com/questions/42696948/how-can-i-install-the-vs2017-version-of-msbuild-on- ...

  9. js 常用脚本

    1.判断电话号码和手机号码 var tel = $("#tel").val(); if (isNotBlank($.trim(tel))) { //不为空的情况下判断符合手机号码标 ...

  10. A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following

    mvc 控制器调用分布视图出错,("A space or line break was encountered after the "@" character. Only ...