vagrant的学习 之 基础学习


本文根据慕课网的视频教程练习,感谢慕课网!

慕课的参考文档地址:https://github.com/apanly/mooc/tree/master/vagrant


(1)下载安装虚拟机VirtualBox(我安装的版本是5.2.4)。


(2)下载Ubuntu镜像(我安装的是教程指定的ubuntu-14.04-amd64.box)。


(3)下载安装vagrant软件(安装后会提示需要重启电脑)。


(4)打开Xshell软件:

  输入:vagrant -v,查看vagrant版本。

  输入:vagrant box list 查看当前已有的镜像。

  输入:vagrant box add 命名镜像名字  镜像位置

  (vagrant box add  ubuntu1404 E:\ubuntu-14.04-amd64.box)

  再次输入:vagrant box list 就可以看到刚添加的镜像。


(5)初始化创建一个虚拟机配置:

在D盘创建一个study目录:

[c:\~]$ d:
[D:\]$ mkdir study

  输入:vagrant init  镜像名称 ,初始化创建一个虚拟机配置文件(执行后会自动生成一个Vagrantfile文件)。

    vagrant init ubuntu1404


(6)启动虚拟机:

  输入:vagrant up ,启动虚拟机。

  但是报错:  

The version of powershell currently installed on this host is less than
the required minimum version. Please upgrade the installed version of
powershell to the minimum required version and run the command again.

提示powershell版本过低,windows7默认的powershell是2.0,需要升级,

搜到这个网址:http://www.pstips.net/powershell-introduction-and-install.html
然后下载:4.0版本,http://www.microsoft.com/en-us/download/details.aspx?id=40855

选择Windows6.1-KB2819745-x64-MultiPkg.msu下载安装。

安装后需要重启电脑,然后再次执行:vagrant up,这是后虚拟机运行起来了,但是结果出有点错误信息:

Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was: mount -t vboxsf -o uid=,gid= vagrant /vagrant The error output from the command was: mount: unknown filesystem type 'vboxsf'

搜到的结果,参考原文:https://www.cnblogs.com/fengchi/p/6549784.html

解释是:共享目录无法使用,虚拟机已经在运行了。

以下的方案都需要进入虚拟机里面执行。

默认登录账号和密码都是:vagrant。

ubuntu系统处理方案

sudo apt-get update

sudo apt-get install virtualbox-guest-utils

(备注:第二条命令比较慢,然后再使用 vagrant up 就没有错误了)

centos系统处理方案(mac版)

sudo yum update
sudo yum install gcc
sudo yum install kernel-devel exit #退出虚拟机
vagrant halt # 关闭虚拟机
加载 VBoxGuestAdditions.iso 镜像并挂载
该镜像位于VirtualBox安装文件夹下,可以全文件搜索
sudo find / -name VBoxGuestAdditions.iso 
将CD进行挂载
mount /dev/cdrom /cdrom #(该cdrom是我在/目录下创建的文件夹)
进入cdrom并运行相关程序。
cd /cdrom;
sh ./VBoxLinuxAdditions.run
等待程序安装完毕,VirtualBox增强功能软件就在系统中安装完毕

重启虚拟机

vagrant up

(7)登录虚拟机:

使用:vagrant ssh 可以登录到虚拟机:

[D:\study]$ vagrant ssh
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.--generic x86_64) * Documentation: https://help.ubuntu.com/
New release '16.04.5 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

没有登陆成功,也没有报错,只是提示ubuntu有新版本。

暂时未找到为什么没有登录成功的问题,放弃直接使用VirtualBox操作。


(8)修改软件下载源,提升下载速度:

【备注:这里发现虚拟机命令行无法与电脑进行复制粘贴,想到的方法是使用Xshell工具,

需要配置静态ip,配置网络可以参考我的另一篇博客:https://www.cnblogs.com/gyfluck/p/9553993.html

1、复制备份原软件源列表:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2、打开sources.list:

sudo vim /etc/apt/sources.list

3、清空内容,复制 视频中的 软件源列表,到sources.list中。

清空内容:

按Esc键切换到命令行模式

:,$d

新内容:

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

更新源:

sudo apt-get update

会看到在用aliyun的源,遇到一些错误信息:

Get: http://mirrors.aliyun.com trusty/universe Translation-en [4,089 kB]
Ign http://mirrors.aliyun.com trusty/main Translation-en_US
Ign http://mirrors.aliyun.com trusty/multiverse Translation-en_US
Ign http://mirrors.aliyun.com trusty/restricted Translation-en_US
Ign http://mirrors.aliyun.com trusty/universe Translation-en_US
Fetched 35.2 MB in 1min 22s ( kB/s)
W: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/trusty-backports/InRelease Unable to find expected entry 'multiversei/binary-amd64/Packages' in Release file (Wrong sources.list entry or malformed file) E: Some index files failed to download. They have been ignored, or old ones used instead.

暂时忽略。




vagrant的学习 之 基础学习的更多相关文章

  1. [AngularJS学习笔记] 基础学习01

    2016-06-06开始学习AngularJS AngularJS是会extend HTML的 ng-directives 先学习了四个 ng-app:定义AngularJS Application的 ...

  2. 前端学习:html基础学习一

    1.HTML的语法(主要内容HTML语法格式.文档注释.代码格式) HTML的特点 1.可以设置文本的格式,比如标题.字号.文本颜色.段落等等 2.可以创建列表(例如打开百度,我们可以看到这样的列表) ...

  3. JavaScript 学习笔记(基础学习)

    一:来自W3School工具的学习 1:document.getElementById(id) : 访问某个标签的元素,然后对它进行操作 .innerHTML 对其内容进行修改 2:document. ...

  4. Python学习---线程基础学习

    线程基础 什么是线程(thread) 线程是CPU调度能够进行运算调度的最小单位.它被包含在进程之中,是进程中的实际运作单位.一条线程指的是进程中一个单一顺序的控制流[换言之,线程就是一堆指令集合], ...

  5. 视频学习_css基础学习

    块状元素 block element 容器元素  设置高宽 width height  可以容纳 文本 内脸 和其他块状 霸道  独占一行 特例:form  只容纳 块状元素 常见元素 http:// ...

  6. 前端学习:html基础学习五

    9.HTML表单设计(主要内容<form><input><select>标记) 表单标记 <form>...</form> <form ...

  7. 前端学习:html基础学习四

    7.HTML表格(主要内容<table><caption><tr><th><td>标记) <table>标记 基本格式 < ...

  8. 前端学习:html基础学习三

    5.图像标记(主要内容<img>标记) <img>标记的使用方法 <img src="路径/文件名.图片格式" width="属性值&quo ...

  9. 前端学习:html基础学习二

    3.文档设置标记上-格式标记(主要内容标记<br><p><center><pre><li><ul><ol><d ...

随机推荐

  1. Netflix正式开源其API网关Zuul 2--转

    微信公众号:聊聊架构 5 月 21 日,Netflix 在其官方博客上宣布正式开源微服务网关组件 Zuul 2.Netflix 公司是微服务界的楷模,他们有大规模生产级微服务的成功应用案例,也开源了相 ...

  2. rest_framework基于generics.CreateAPIView创建用户

    最近在写新版的devops3.0,被generics.CreateAPIView创建用户密码序列化的问题折磨的欲仙欲死.反复看源码测试,得出下面的流程,这也是做generics.CreateAPIVi ...

  3. Thinkphp3.23 连接MSSQL方法

    Thinkphp 3.23要连接MSSQL,必须配置下,以下是主要的步骤. 1.要安装Microsoft Drivers for PHP for SQL Server驱动 下载驱动以前,要查看一下ph ...

  4. R in action读书笔记(10)-第八章:回归-- 异常观测值 改进措施

    8.4 异常观测值 8.4.1 离群点 car包也提供了一种离群点的统计检验方法.outlierTest()函数可以求得最大标准化残差绝对值Bonferroni调整后的p值: > library ...

  5. uoj #15. 【NOIP2014】生活大爆炸版石头剪刀布

    石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头.如果两个人出拳一 样,则不分胜负.在<生活大爆炸>第二季第 8 集中出现了一种石头剪刀布的升级版游戏. 升级版游戏在传统的石头剪 ...

  6. Linux下 SpringBoot jar项目后台运行、查看、停用

    运行java jar: nohup java -jar **-0.0.1-SNAPSHOT.jar & 查看进程: 采用top或者ps aux命令.一般 如果后台是springboot,jar ...

  7. 08C#事件

    C#事件 1.2      事件 事件是C#语言内置的语法,可以定义和处理事件,为使用组件编程提供了良好的基础. 1.16.1       事件驱动 Windows操作系统把用户的动作都看作消息,C# ...

  8. 问题:执行[root@node01 hadoop-2.6.0-cdh5.14.0]# sbin/start-dfs.sh 后,namenode未启动

    执行[root@node01 hadoop-2.6.0-cdh5.14.0]# sbin/start-dfs.sh 后,namenode未启动. 解决步骤: 查看/export/servers/had ...

  9. Autorelease pools 官方文档

    翻译自: http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAu ...

  10. LG-P1311选择客栈

    题目 暴力十分好想但你写不出来qwq 正解十分好写但你想不出来qaq 我们先读题,发现k其实没什么用 同时暴力枚举两个客栈的话会超时,所以只能同时枚举一个.我们枚举第二个客栈,然后用第二个客栈反推出前 ...