読者です 読者をやめる 読者になる 読者になる

ログってなんぼ

日々のメモです

VagrantとVirtualboxでCentOS6.4のVMを起動する

VirtualBox

Downloads – Oracle VM VirtualBox はてなブックマーク - Downloads – Oracle VM VirtualBox

Vagrant

Vagrant - Download Archives はてなブックマーク - Vagrant - Download Archives

OSのイメージ

このへんとかにリンクが色々ありました A list of base boxes for Vagrant - Vagrantbox.es はてなブックマーク - A list of base boxes for Vagrant - Vagrantbox.es

とりあえずここからCentOSのVMを持ってくることにします。

Vagrant Boxの取得と初期化

$ vagrant box add centos6.4.x86_64 https://github.com/2creatives/vagrant-centos/releases/download/v0.1.0/centos64-x86_64-20131030.box

Downloading box from URL: https://github.com/2creatives/vagrant-centos/releases/download/v0.1.0/centos64-x86_64-20131030.box
Extracting box...te: 1203k/s, Estimated time remaining: --:--:--)

$ vagrant init centos6.4.x86_64
A Vagrantfile has been placed in this directory. You are now
ready to vagrant up your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
vagrantup.com for more information on using Vagrant.

vagrant init コマンドで出来たファイルにはVMの設定が色々書いてあった

# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network :private_network, ip: "192.168.33.10"

IPアドレスなどを変更したいときはこの辺を編集?

とりあえず今回はこのまま起動してみる

起動してみる

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'centos6.4.x86_64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Mounting shared folders...
[default] -- /vagrant

sshしてみる

$ vagrant ssh
Last login: Fri Jan 17 05:50:09 2014 from 10.0.2.2
[vagrant@vagrant-centos64 ~]$ cat /etc/redhat-release
CentOS release 6.4 (Final)

OK。

Virtualboxを確認

Screenshot 2014 01 17 14 51 45

VMが追加されて起動中になっています。