Vagrant Quick Start

Source: Internet
Author: User

Vagrant Quick Start
1. Vagrant function: Vagrant usesOracle's VirtualBox to build retriable, lightweight, and portable virtual machines dynamically ..

[Vagrant uses the Oracle VM VirtualBox to dynamically create and configure lightweight, reproducible, and portable Virtual Machine environments .]

2. Download Vagrant:

Http://downloads.vagrantup.com/tags/v1.0.5

3. Install Vagrant:

3.1. download and install the Oracle VM VirtualBox. For example, in windows, the virtualbox-4.2.0-80737-win.exe is installed.

Https://www.virtualbox.org/wiki/Downloads

3.2. download and install the latest Vagrant version:

Http://downloads.vagrantup.com/

[Note] in Windows and Mac OS X,vagrantThe command should be automatically added to the Environment VariablePATHBut in other operating systems, you must manually add/opt/vagrant/binTo Environment VariablesPATH。

How to Use vagrant to install a Hadoop cluster on a virtual machine

Efficient Puppet module Management in Vagrant

Use Vagrant and Fabric for Integration Testing

Build a development environment using Vagrant

Configure the Vagrant environment in Windows

4. Vagrant command

After Vagrant is installed, we can use the vagrant command from the command line to perform operations. Common vagrant commands are as follows:

Vagrant box add <name> <url>
Vagrant box list
Vagrant box remove <name>
Vagrant box repackage <name>
Vagrant init [box-name] [box-url]
Vagrant up [vm-name] [-- [no-] provision] [-h]
Vagrant destroy [vm-name]
Vagrant suspend [vm-name]
Vagrant reload [vm-name]
Vagrant resume [vm-name]
Vagrant halt [vm-name]
Vagrant status [vm-name]
Vagrant package [vm-name] [-- base name] [-- output name. box] [-- include one, two, three] [-- vagrantfile file]
Vagrant provision [vm-name]
Vagrant ssh [vm-name] [-c command] [-- extra ssh args]
Vagrant ssh-config [vm-name] [-- host name]

5. Vagrantfile

In any Vagrant project, there is a Vagrantfile. Just like makefile, Vagrantfile is used to configure the information of the virtual machine created by vagrant. Below is a basic Vagrantfile:

       Vagrant::Config.run do |config|           # Setup the box           config.vm.box = "my_box"       end
6. Create the first Vagrant virtual environment and project:

(1) create a project directory and run the vagrant init command. This command will generate the initial Vagrantfile

$ mkdir vagrant_guide$ cd vagrant_guide$ vagrant init

(2) Add a Base Box:

Instead of creating a virtual machine from scratch, Vagrant imports the base image of a virtual machine and builds it on this basis. These images are called Box.

Vagrant supports adding boxes from a local file system or HTTP URL

$ Vagrant box add basehttp: // files.vagrantup.com/lucid32.box

$ Vagrant box add base D: \ lucid32.box

(3) configure the Project to use this Box: Modify Vagrantfile to the following content:

Vagrant: Config. run do | config |
Config. vm. box = "base"
End

(4) Start A Virtual Machine

$ Vagrant up

(5) Stop the VM

$ Vagrant destroy

(6) SSH Configuration

Vagrant provides an SSH connection to a virtual machine. You only need to execute the following command:

$ Vagrant ssh

In Windows, you can use PUTTY to configure the following information to connect to the virtual machine:

Hostname: localhost

Port: 2222

Connection Type: SSH

User Name: vagrant

Password: vagrant

(7) access the Project just created.

Vagrant connects your application to the virtual machine through the shared folder of VirtualBox. The default shared folder guard is/vagrant. To view the created Project, you only need to execute:

Vagrant @ lucid32 :~ $ Ls/vagrant
Index.html Vagrantfile

(8) Provisioning:

Usually, the Box only performs the most basic settings, instead of setting all the environments in place at a time. Vagrant usually uses chef or Puppet for further environment setup.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.