Motomichi Works Blog

モトミチワークスブログです。その日学習したことについて書いている日記みたいなものです。

vagrantその0001 あまり覚えていないけど、2013年のときのことを一通り確認して、2014年12月28日現在の最新バージョンでvagrant upまでやる

参考にさせて頂いたサイト

Vagrant 入門 - Windows 上に Linux の仮想マシンを簡単に用意する - 僕は発展途上技術者

あまり覚えてないけど2013年4月のこと

僕は当時ブログをやっていなかった。

evernoteに残していたメモによると2013年4月にVagrant 入門 - Windows 上に Linux の仮想マシンを簡単に用意する - 僕は発展途上技術者の手順に沿って、VirtualBoxvagrantを試していたみたい。

メモに残っていないけど、windows7で試してvagrant upを実行したときにエラーが出たのを記憶している。

土日を費やして検索しても、当時の自分では解決できずに諦めたのも記憶している。

最近知ったんだけど、windowsではbiosで「仮想化技術を使用する」設定に変更しないといけない機種が多いとか。

たぶんそれだ。

VirtualBoxvagrant のバージョンは覚えていないし、問題のwindows端末はもう壊れてしまっている。

2013年11月のこと

メモが詳細に残っていた。

とりあえず細かくここには書かないけど、このときmac osx lion でrailsの環境構築とかphpの環境構築に挑戦してた。

phpの環境構築は上手くできずに諦めていたみたい。

railsの環境構築はというと、なんとかスタートページ?までは表示できてたけど、そこまでにかなりtry and errorをして疲れ果てたのと、当時sassとかを学習する必要が出てきたのでrailsはそこでやめてしまっていた。

guestマシンのファイアウォール設定を変更する事で当時ハマっていた記憶がある。

なんでブラウザでlocalhostのwebページが表示できないんだろう?原因はどこだろう?と上手く問題の切り分けもできなかった。

iptablesというファイルがあるとか、それを編集するのだということを当時初めて知った。

当時yumというものがあるとか知らなかったので、せっかくcentos6.4のboxとか使っても、apacheとかphpとかvimのインストール方法がわかっていなかった。

カーソルの動かし方すらもよくわからないviで恐る恐るiptablesを編集した。

まぁそんなこんなで、railsの環境構築をしたり、hostマシンのファイルをguestマシンに同期する方法を知ったり、Port Forwardingとかやらないといけないものだと思い込んで苦労して設定したりしたのが2013年11月だった。

決して使いこなせているわけではなかったし、たいして理解していたわけでもなかったけれど、沢山のブログを検索して、見よう見まねでなんとか動かしたことは、2014年になって役に立った。

vagrantに関してはそんな2013年だった。

当時インストールしたバージョン

上記のインストーラーがmacの中に残っているので、VirtualBoxは3つのうちのどれかだと思う。

なんか一応動くけど、黄色い文字で警告文が出る。みたいな状態になり、VirtualBoxをインストールしなおした記憶はある。

最終的にどれだったのかはわからない。

2014年12月28日現在にvagrant upしてみたらなんかエラーが出た

vagrant box list

したら

centos64box (virtualbox)
lucid32     (virtualbox)

centosubuntu

改めて

vagrant init centos64box
vagrant up

してみたら

Bringing machine 'default' up with 'virtualbox' provider...
[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 machine to boot. This may take a few minutes...
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.

If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.

と出た。

なんだこれは。

起動に失敗した。
バーチャルボックスがパワーオフなので、適切な状態にして再試行してください。

バーチャルボックスのGUIを開くと、わかりやすいエラーメッセージが出ているかもしれないので、GUIを使ってみるとよさそう。

みたいなことか?
なんかこれ2013年にも見たことある気がするな。

VirtualBoxGUIで起動しようとしてみたら

Kernel driver not installed (rc=-1908)

Make sure the kernel module has been loaded successfully.

とか

仮想マシン"cakephp_default_1419693760"のセッションを開けませんでした。

The virtual machine 'cakephp_default_1419693760' has terminated unexpectedly during startup with exit code 1.

終了コード : NS_ERROR_FAILURE (0x80004005)
コンポーネント: Machine
インターフェース: IMachine {22781af3-1c96-4126-9edf-67a020e0e858}

とか出た。

VirtualBox-4.3.20-96996-OSX.dmgをインストールして、vagrant upしてみる

2014年12月28日現在の最新バージョンVirtualBox-4.3.20-96996-OSX.dmgを改めてダウンロードして、インストールしてみた。

インストールが完了して、vagrant upしたら、

Bringing machine 'default' up with 'virtualbox' provider...
[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 machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
cause things such as shared folders to not work properly. If you see
shared folder errors, please update the guest additions within the
virtual machine and reload your VM.

Guest Additions Version: 4.2.12
VirtualBox Version: 4.3
[default] Mounting shared folders...
[default] -- /vagrant

あ、出た。黄色い文字。

VirtualBox-4.2.12-84980-OSX.dmgで再インストール

VirtualBox-4.2.12-84980-OSX.dmgで再インストールしてみたら、vagrant upができなくなった。

エラーすら出ず、なんかWaiting for machine to boot. This may take a few minutes...で止まっちゃうようになった。

最新版のvagrant_1.7.1.dmg MAC OS X版をダウンロードしてみる

vagrantの1.7.1を上書きインストールして、

vagrant init centos64box
vagrant up

したら、今度は

default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...

が永遠に続く感じになった。

もう一度VirtualBox-4.3.20-96996-OSX.dmgでインストール

2014年12月28日時点で最新のVirtualBox-4.3.20-96996-OSX.dmgで上書きインストールしなおして、

vagrant up

しなおしたらうまくいった。

まとめ

2014年12月28日現在

がちゃんと動くの組み合わせっぽい。

ただ、職場のwindows7ではVirtualBox-4.3.12で動いているのでそうなんだろうと思う。

職場の環境は以下