(Mac) VagrantでのCentOS6.4環境構築

MACにてVirtualBox + Vagrant での CentOS 6.4 環境をさくっと構築してみましたのでメモです。

簡単にゲストを起動してsshでログインするところまでいけました。

VirtualBoxインストール

 https://www.virtualbox.org/wiki/Downloads  →全てデフォルト

Vagrantインストール

 http://downloads.vagrantup.com/  →こちらも全てデフォルト

Vagrantインストールの確認

$ vagrant -v
Vagrant version 1.2.4

仮想マシンのBoxを追加(イメージを登録)  box一覧はこちらより。   http://www.vagrantbox.es/  今回はcentos 6.4

$ vagrant box add centos-6.4 http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box
Downloading or copying the box...
Extracting box...te: 763k/s, Estimated time remaining: --:--:--)
Successfully added box 'centos-6.4' with provider 'virtualbox'!

仮想マシンの初期化(カレントディレクトリに設定ファイル作成)

$ vagrant init centos-6.4
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 status
Current machine states:
default                   poweroff (virtualbox)

仮想マシンの起動

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'centos-6.4'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[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 VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- /vagrant

仮想マシンsshログイン

$ vagrant ssh
Welcome to your Vagrant-built virtual machine.

ゲスト操作

[vagrant@localhost ~]$ uname -a
Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[vagrant@localhost ~]$ cat /etc/redhat-release 
CentOS release 6.4 (Final)
[vagrant@localhost ~]$ su -
Password: vagrant
[root@localhost ~]#

仮想マシンサスペンド

$ vagrant suspend

仮想マシンを削除

$ vagrant halt

仮想マシンの強制終了と削除

$ vagrant destroy

VirtualBoxマネージャーよりVMの設定を確認するとメモリはデフォで480MB。

vagrantについては以下を読む  VAGRANT DOCS (GETTING STARTED)   http://docs.vagrantup.com/v2/getting-started/index.html

* 参考サイト http://www.ryuzee.com/contents/blog/4292