2013年6月29日土曜日

VirtualBox 4.2.14 with Vagrant 1.2.2

VirtualBox, Vagrantをセットアップしましたが、vagrant upで失敗してしまいました。
使用したRPMは、2013/6/29現在の最新版です。
  • VirtualBox-4.2-4.2.14_86644_el6-1.x86_64.rpm
  • vagrant_1.2.2_x86_64.rpm
vagrant up実行時のメッセージは、次になります。
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise32'...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["import", "/home/hide/.vagrant.d/boxes/precise32/virtualbox/box.ovf"]

Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting /home/hide/.vagrant.d/boxes/precise32/virtualbox/box.ovf...
OK.
0%...
Progress object failure: NS_ERROR_CALL_FAILED
$
原因を調べてみると、VirtualBoxのTicket #11895に該当するようで、すでにリポジトリ上では修正されているようです。
しかし、対応版のRPMはまだリリースされていないようですので、チケットにあるワークアラウンドを試してみることにしました。

コメントによると、manifest fileを作成すればいいようで、Webページが紹介されています。
という事で、precise32 BOXのマニフェストファイルを作成してみます。
$ cd ~/.vagrant.d/boxes/precise32/virtualbox
$ openssl sha1 *.vmdk *.ovf > box.mf
$ ls
Vagrantfile  box-disk1.vmdk  box.mf  box.ovf  metadata.json
$
で、先ほど試していたプロジェクトディレクトリに移動して、vagrant upを再度実行してみます。
$ cd -
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise32'...
[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] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
$
うまく行きました!
早速、ログインしてみます。
$ vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)

 * Documentation:  https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:22:31 2012 from 10.0.2.2
vagrant@precise32:~$
vagrant@precise32:~$ uname -a
Linux precise32 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 i686 i686 i386 GNU/Linux
vagrant@precise32:~$
vagrant@precise32:~$ df -h
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/precise32-root   79G  2.0G   73G   3% /
udev                        178M  4.0K  178M   1% /dev
tmpfs                        74M  272K   74M   1% /run
none                        5.0M     0  5.0M   0% /run/lock
none                        185M     0  185M   0% /run/shm
/dev/sda1                   228M   24M  192M  12% /boot
/vagrant                    138G   12G  127G   9% /vagrant
vagrant@precise32:~$
おお!なかなか面白い仕組みです。

Vagrant on CentOS

以前から気になっていたVagrantをCentOS 6.4 (64bit)にインストールしました。

VagrantVirtualBoxともに2013/6/29現在の最新版の次のRPMを使用しました。
  • VirtualBox-4.2-4.2.14_86644_el6-1.x86_64.rpm
  • vagrant_1.2.2_x86_64.rpm
Vagrant、VirtualBoxともにRPMで提供されているので、インストールは特に問題なく終了。

早速Vagrantを使ってみます。
まずは、Getting Startedの記述に沿って、開発元が提供しているイメージを使用して仮想マシンを作ってみることにします。

プロジェクト用のディレクトリ作成と初期化
$ mkdir vagrant_getting_started
$ cd vagrant_getting_started
$ vagrant init
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.
$
BOXのインストール
BOXとは、仮想マシンの雛形のようなもの(?)のようです。
一度設定すると再利用できるようです。
$ vagrant box add precise32 http://files.vagrantup.com/precise32.box
Downloading or copying the box...
Extracting box...te: 1161k/s, Estimated time remaining: 0:00:01)
Successfully added box 'precise32' with provider 'virtualbox'!
$
どうも、~/.vagrant.d配下に色々置かれるようです。
Vagrantfileのconfig.vm.box = "base"の記述を次のように編集します。
]$ diff -uw Vagrantfile.original Vagrantfile
--- Vagrantfile.original        2013-06-29 12:07:25.388634683 +0900
+++ Vagrantfile 2013-06-29 12:31:21.501632951 +0900
@@ -7,7 +7,7 @@
   # please see the online documentation at vagrantup.com.

   # Every Vagrant virtual environment requires a box to build off of.
-  config.vm.box = "base"
+  config.vm.box = "precise32"

   # The url from where the 'config.vm.box' box will be fetched if it
   # doesn't already exist on the user's system.
ここまでで、下準備はおしまいです。
いよいよ、仮想マシンをブートさせます。
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise32'...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["import", "/home/hide/.vagrant.d/boxes/precise32/virtualbox/box.ovf"]

Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting /home/hide/.vagrant.d/boxes/precise32/virtualbox/box.ovf...
OK.
0%...
Progress object failure: NS_ERROR_CALL_FAILED
うーん、失敗したようです。
少し調べる必要がありそうです。

2013年6月26日水曜日

rbenv on CentOS

Rubyで試してみたい事が出来たので、rbenvを使ってみることにしました。

複数バージョンのRubyを使い分ける仕組みとしては、RVMもあるようですがrbenvを使うことにしました。
環境は、CentOS 6.4 (x86_64)です。

rbenvの標準では、~/.rbenv配下にrubyがインストールされるようです。
ホームディレクトリ配下に色々インストールされるのは、ちょっと嫌だったので/usr/local配下にインストールすることにしました。

まず、git cloneでrbenvを取得します。
# /usr/local
# git clone https://github.com/sstephenson/rbenv.git rbenv
次に、README.mdの記述に従いPATH/usr/local/rbenv/binを追加します。
検索順序がなんとなく嫌な感じですが、まずはREADME.mdに記述に沿って設定していくことにします。

~/.bash_profileに次の記述を追加します。

export PATH=/usr/local/rbenv/bin:$PATH
export RBENV_ROOT=/usr/local/rbenv
eval "$(rbenv init -)"

以上で、rbenvのインストールは終了です。
次に、Rubyのインストールに使用するプラグインruby-buildをインストールします。
これもgit cloneで取得します。
# git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins
/ruby-build
Rubyのインストールは、次のように行います。
まず、インストールできるバージョンのリストを次のコマンドで取得します。
# rbenv install -l
今回は、1.8.7-p371, 193-p429, 2.0.0-p195をインストールします。
# rbenv install 1.8.7-p371
Downloading ruby-1.8.7-p371.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p371.tar.gz
Installing ruby-1.8.7-p371...
Installed ruby-1.8.7-p371 to /usr/local/rbenv/versions/1.8.7-p371

Downloading rubygems-1.6.2.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/0c95a9869914ba1a45bf71d3b8048420
Installing rubygems-1.6.2...
Installed rubygems-1.6.2 to /usr/local/rbenv/versions/1.8.7-p371

# rbenv install 1.9.3-p429
Downloading yaml-0.1.4.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/36c852831d02cf90508c29852361d01b
Installing yaml-0.1.4...
Installed yaml-0.1.4 to /usr/local/rbenv/versions/1.9.3-p429

Downloading ruby-1.9.3-p429.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p429.tar.gz
Installing ruby-1.9.3-p429...
Installed ruby-1.9.3-p429 to /usr/local/rbenv/versions/1.9.3-p429

# rbenv install 2.0.0-p195
Downloading ruby-2.0.0-p195.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz
Installing ruby-2.0.0-p195...
Installed ruby-2.0.0-p195 to /usr/local/rbenv/versions/2.0.0-p195
以上で、Rubyのインストールはおしまいです。
取りあえず、グローバル設定のバージョンを1.9.3p429にしてみます。
# rbenv global 1.9.3-p429
# rbenv versions
  1.8.7-p371
* 1.9.3-p429 (set by /usr/local/rbenv/version)
  2.0.0-p195
# rbenv version
1.9.3-p429 (set by /usr/local/rbenv/version)
# ruby -v
ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-linux]
# which ruby
/usr/local/rbenv/shims/ruby
特に嵌ることなくインストールできました。便利ですね。

2013年6月8日土曜日

iPad mini(Wi-Fi + Cellularモデル)購入

iPad miniは要らないかなと考えていたのですが、MVNO通信サービスが最近良くなってきたので買っちゃいました。

SIMフリー版iPad mini (Wi-Fi + Cellularモデル)をexpansysで購入しました。
以前利用したときは1週間くらい掛かった気がするのですが、今回は2日で届きました。
同時に申し込んだIIJmio 高速モバイル/D は、iPad miniから2日遅れで届きました。(国内発送が香港発送に負けるとは)

IIJmio 高速モバイル/D のSIMは、本体に挿してAPNの設定をするだけでLTE接続が出来ました。
ただ、インターネット共有は、本体の設定では有効に出来ないようで、IIJmio 高速モバイル/D iOS APN構成プロファイルにあるプロファイルを使用する必要がありました。(iOS 6.1.3)

私の使い方だとiPhoneよりiPad miniの方が使い勝手がいいようです。