其它工具 Vagrant

laofo · 发布于 2013年2月25日 · 286 次阅读

Vagrant uses Oracle’s VirtualBox to build configurable, lightweight, and portable virtual machines dynamically. The first couple of pages serve to introduce you to Vagrant and what it has to offer while the rest of the guide is a technical walkthrough for building a fully functional web development environment. The getting started guide concludes by explaining how to package the newly created vagrant environment so other developers can get up and running in just a couple commands.

Get VirtualBox Vagrant depends on Oracle’s VirtualBox to create all of its virtual environments. VirtualBox is a general-purpose full virtualizer for x86 hardware. Targeted at server, desktop and embedded use, it is a professional-quality virtualization solution that is also open source software. VirtualBox runs on Windows, Mac OS X, Linux, and Solaris.

Here is a link directly to the download page.

Vagrant currently supports VirtualBox 4.0.x, 4.1.x and 4.2.x.

Install Vagrant To install Vagrant, download the appropriate package or installer from the downloads page, and install it using standard operating system procedures. On Windows and Mac OS X, the vagrant command should automatically be placed on your PATH. On other systems, you must add /opt/vagrant/bin to your PATH.

If a Vagrant package is not available for your platform, you can also install using RubyGems via a gem install vagrant. But note that the packages are the preferred and best supported method of installation.

Your First Vagrant Virtual Environment $ vagrant box add lucid32 http://files.vagrantup.com/lucid32.box $ vagrant init lucid32 $ vagrant up While the rest of the getting started guide will focus on explaining how to build a fully functional virtual machine to serve Rails applications, you should get used to the above snippet of code. After the initial setup of any Vagrant environment, the above is all any developer will need to create their development environment! Note that the above snippet does actually create a fully functional 512MB virtual machine running Ubuntu in the background, although the machine doesn’t do much in this state.

共收到 3 条回复
laofo · #1 · 2013年2月25日

Why Vagrant? Web developers use virtual environments every day with their web applications. From EC2 and Rackspace Cloud to specialized solutions such as EngineYard and Heroku, virtualization is the tool of choice for easy deployment and infrastructure management. Vagrant aims to take those very same principles and put them to work in the heart of the application lifecycle. By providing easy to configure, lightweight, reproducible, and portable virtual machines targeted at development environments, Vagrant helps maximize the productivity and flexibility of you and your team.

Vagrant is a development tool which stands on the shoulders of giants, using tried and proven technologies to achieve its magic. Vagrant uses Oracle’s VirtualBox to create its virtual machines and then uses Chef or Puppet to provision them.

Benefits of Using Vagrant For Solo Developers Maintaining consistent development environments over multiple projects is simply an unfeasible task for a modern web developer. Each project depends on its own libraries, message queue systems, databases, frameworks, and more, each with their own versions. In addition to the dependencies, running all these on a single home machine and remembering to turn it all off at the end of the day or when working on other projects is also unfeasible. Vagrant gives you the tools to build unique development environments for each project once and then easily tear them down and rebuild them only when they’re needed so you can save time and frustration.

For Teams Each member of a team ideally has identical development environments: same dependencies, same versions, same configurations, same everything. But this is simply not true today. With database agnostic ORMs, multiple web server options, and fast-moving libraries, one team member may be using MySQL with one version of a library while another team member may be using PostgreSQL with another version of the same library. Or perhaps one team member’s configuration for their server is slightly different. These are all real cases which are bound to cause real issues at some point down the road. Vagrant gives teams the ability to enforce a consistent and portable virtual development environment that is easy to create and quick to setup.

For Companies If you’ve ever maintained a large web application, one of the hardest parts is onboarding new resources. Message queues, caching, database servers and other infrastructure pieces mean a lot of installation and a lot more configuration (see case-in-point: insanity). Vagrant gives you the tools to build a development environment once and then easily distribute it to new members of your development team so you can get them to work and saving time, money and frustration

laofo · #2 · 2013年2月25日

Vagrant 起步指南

作者:Windy Ocean 转自:http://dev.jiatingjiaoyu.net/?p=5531

Vagrant – Getting Started.

概览 获取 VirtualBox 安装 Vagrant 第一个 Vagrant 虚拟环境 为什么要使用 Vagrant? 使用 Vagrant 的好处 对于独立开发者 对于开发团队 对于公司 介绍 Vagrant 可执行文件 Vagrantfile 建立项目 建立 Vagrant 项目 建立 Web 项目


Vagrant 使用 Oracle 的 VirtualBox 动态建立可配置和可移植的轻量级虚拟机。本指南的前面部分简单介绍了 Vagrant 及其提供的功能,后面部分则演示了如何一步步建立一个功能完整的 Web 开发环境。本指南的结尾部分讲解了如何将新建立的 Vagrant 环境打包,这样其他开发者通过运行几条简单的指令就可以使用它了。

获取 VirtualBox

Vagrant 使用 Oracle 的 VirtualBox 建立虚拟环境。VirtualBox 是一个针对 x86 硬件的全功能通用虚拟器。它是一个专业品质的虚拟解决方案,可以用于服务器、桌面以及嵌入式用途,同时它也是一个开源软件。VirtualBox 可以在 Windows、Mac OS X、Linux 和 Solaris 上运行。

通过这个下载页面可以直接下载 VirtualBox。[译注:http://www.virtualbox.org 似乎已不能访问,最后通过国内软件下载站下载]

Vagrant 当前支持 VirtualBox 4.0.x 和 4.1.x 版本。

安装 Vagrant

下载软件后使用标准系统过程进行安装。在 Windows 和 Mac OS X 系统上,命令 vagrant 将被自动加入系统的 PATH。对于其他操作系统,必须自行把 /opt/vagrant/bin 加入 PATH。

如果没有对应平台的 Vagrant 安装包,还可以使用 gem install vagrant 通过 RubyGems 进行安装。推荐优先使用安装包,它们是得到最好支持的安装方法。

第一个 Vagrant 虚拟环境

上面的两个步骤没有严格的顺序——可以在已经存在的项目文件夹里初始化 Vagrant。

laofo · #3 · 2013年2月25日

Vagrant => 程序员的Virtual Machine

作者:venmos 转自:http://venmos.com/blog/2012/09/22/vagrant/

我们在上班时都是在一个封闭的环境中(办公室),用着一致的计算机(统一安装部署开发环境),望着一样的人(万年不变的对面的脸)做着一样的事,虽然如此很无趣,但是甚少出现莫名其妙的BUG. 而我们在下班后,可能会参与到各种五花八门的开源项目中.我们要与一些素未谋面,甚至都不知道叫什么的人在一起协作.他们用着与你不同的操作系统,可能是Linux,也可能是Windows;他们用着与你不用的编辑器,可能是Vim,也可能是IDE;他们有的人可能只参与Ruby的项目,也可能有的Ruby::Python::C的都参加.这样很有乐趣,因为他们与我身处不同的环境之中,我每天都可以从他们那里以他们的视角学习到许多不同的东西.不过也会带来麻烦,因为环境不同就会更加容易出现莫名其妙的BUG,增大了调试的难度. 所以尽可能的保持测试环境的一致性,又尽可能的减少对原有环境的影响,就变成了一件非常重要的事情.曾经我们使用VirtualBox或者VMware来解决这个问题,而现在我们有了更先进的武器 => Vagrant . Vagrant是用Ruby语言开发的专门用于构建虚拟化开发环境的工具,Vagrant封装了虚拟镜像,Virtualbox接口以及大量的成熟的配置工具,从而帮助我们快速的创建,配置可重复使用与大量分发的虚拟开发环境.更重要的是Vagrant是跨平台的,Mac:Linux:Windows. Vagrant使用Gem进行分发,同时需要VirtualBox API,所以在安装Vagrant之前我们需要先安装以下组件:

最后,我们可能需要复用或者分发搭建好的虚拟环境,这在vagrant中非常简单,只需要来这么一条命令:vagrant package --output boxname.box,vagrant就会开始自动打包box文件. 以上只是简单来介绍vagrant的几个简单的使用示例,vagrant还能应用到更加复杂的环境部署之中,比如实现自动化应用环境的开发,创建,部署,甚至将环境的集成纳入构建流水线之中.更多详细的配置范例可以查阅vagrant的官方Documentation.

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册