purazumakoiの[はてなブログ]

技術メモから最近はライフログも増えてきてます。

「トラブルログ」CentOS6にvirtualbox+Vagrantをインストール

virtualboxインストール

https://www.virtualbox.org/wiki/Downloads
普通にDLしてGUIからインストール

Vagrantインストール

GUIでVagrantをインストールしようとしたらなんかうまく行かなかったっぽいのでコマンドから
gemでインストールgemはこの時にいれました。
Centos6にRuby 1.9.3をRPMパッケージ化してインストール - purazumakoiの[はてなブログ]
LinuxのバージョンはCentos6.2


via
Vagrantを使ってみた - mikanmarusanの日記

追記:↓ちなみにこのバージョンだと上手くいかないのであとで消しました。
# gem install vagrant
# vagrant -v
Vagrant version 1.0.7

最初GUIで入れようとしたやつがどうも残ってたみたいで
/root/.vagrant.d
を消せってエラーがでましたとさ。

ゲストOSインストール

ローカルにbox落としてから、追加
# mkdir ~/vagrant
# cd ~/vagrant
# wget http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box
# vagrant box add centos64_64 CentOS-6.4-x86_64-v20130427.box

ネットワーク設定

# vi Vagrantfile

↓これに変更
config.vm.network :hostonly, "192.168.33.20"


とやってみたけど
vagrant box add base CentOS-6.4-x86_64-v20130427.box
を実行した段階で

Failed to untar the box file. This is usually because you're
attempting to add a box that isn't a valid box file. Please
double check that the box file is properly packaged.

↓と同じ現象かしら


とういうことで

# gem uninstall vagrant


Centos6にvagrant_1.2.7をインストール
# cd ~/
# wget http://files.vagrantup.com/packages/7ec0ee1d00a916f80b109a298bab08e391945243/vagrant_1.2.7_x86_64.rpm
# rpm -ivh vagrant_1.2.7_x86_64.rpm

↓参照:どうも1.2.5からエラーが出るらしい
VagrantをバージョンアップしたらCentOSがはぶられてた - $web->{note};

ちくしょう!
仕方がないので
/opt/vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/hosts/fedora/host.rb
を上の記事があるので直す

@@ -36,7 +36,9 @@
release_file = Pathname.new("/etc/redhat-release")
begin
release_file.open("r") do |f|

  • version_number = /Fedora.*release ([0-9]+)/.match(f.gets)[1].to_i
  1. contents = f.gets
  2. next unless contents =~ /^Fedora/
  3. version_number = /Fedora.*release ([0-9]+)/.match(contents)[1].to_i

if version_number >= 16
# "service nfs-server" will redirect properly to systemctl
# when "service nfs-server restart" is called.

# vagrant -v
Vagrant version 1.2.7

よし、動いたっぽい



追記:
ゲストOSにCentOSの64bitを入れるとなんか、仮想化技術のVT-Dを有効とかなんたらで怒られたので
もしそうならとりあえず32bitがいいかも