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. Ref 和 Out 区别(演练代码)

    一.代码 今天就总结Ref和Out 的总结,这东西,也是经常面试过程中,笔试经常考的,比如:请简述Ref和Out 的区别,或者通过一段代码让你计算这过程的结果.... Out代码实例::: stati ...

  2. t-sql的楼梯:超越基本级别6:使用案例表达式和IIF函数

    t-sql的楼梯:超越基本级别6:使用案例表达式和IIF函数 源自:Stairway to T-SQL: Beyond The Basics Level 6: Using the CASE Expre ...

  3. Vue 拦截器的使用

    拦截器 可以全局进行拦截器设置.拦截器在发送请求前或响应返回时做一些特殊的处理. 拦截器的注册 Vue.http.interceptors.push({ request: function ( req ...

  4. 1、QQ装机部落---腾讯软件

    亲,赚钱快人一步,我给你推荐QQ装机部落!大品牌,口碑好,知名软件,绿色无毒,每天结算,回报高!到这里注册:http://zjbl.qq.com/#/?invid=476058088 返利网邀请码立即 ...

  5. 学习嵌入式开发板的Android平台体系结构和源码结构

    本文转自迅为论坛资料:http://www.topeetboard.com 推荐学习嵌入式开发板平台:iTOP-4412开发板 下面这张图出自Google官方,展示了Android系统的主要组成部分. ...

  6. ALTER SCHEMA - 修改一个模式的定义

    SYNOPSIS ALTER SCHEMA name RENAME TO newname DESCRIPTION 描述 ALTER SCHEMA 修改一个模式的定义. 现在它唯一的功能就是重命名模式. ...

  7. Vue beaforeCreate时获取data中的数据

    异步获取即:通过    $this.$nextTick或者settimeout,这连dom都可以拿出来 beforeCreate() { this.$nextTick(function() { con ...

  8. anchor_target_layer中的bounding regression

    在anchor_target层,这两行是计算bounding regression代码: bbox_targets = np.zeros((len(inds_inside), 4), dtype=np ...

  9. 认识单文件组件.vue 文件

    vuejs 自定义了一种.vue文件,可以把html, css, js 写到一个文件中,从而实现了对一个组件的封装, 一个.vue 文件就是一个单独的组件.由于.vue文件是自定义的,浏览器不认识,所 ...

  10. Android反编译初步

    网上关于Android反编译的帖子很多,反编译的步骤也是很详细,本文Android反编译参考博客:https://www.cnblogs.com/dhcn/p/7120891.html 而反编译中最主 ...