Skip to content

Setup testing environment

YUKI "Piro" Hiroshi edited this page May 29, 2014 · 1 revision

vagrantでUbuntu 13.10ベースの実験環境を用意する。

Vagrant自体をインストールする(まだ入っていなければ)。

% wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.5.3_x86_64.deb
% sudo dpkg -i vagrant_1.5.3_x86_64.deb

実験環境としての仮想マシンのセットアップ(Ubuntu 13.10)

% vagrant box add ubuntu13.10 http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box
% mkdir testserver
% cd testserver
% vagrant init ubuntu13.10

設定を書き換えて、ノードが3つ起動するようにする。

% vi Vagrantfile
% cat Vagrantfile
Vagrant::Config.run do |config|
  0.upto(2).each do |index|
    config.vm.define :"node#{index}" do |node_config|
      node_config.vm.box = "ubuntu13.10"
      node_config.vm.network :hostonly, "192.168.100.#{50 + index}"
      node_config.vm.host_name = "node#{index}"
    end
  end
end

設定ができたか確認する。

% vagrant up
% vagrant ssh node0
% exit
% vagrant ssh node1
% exit
% vagrant ssh node2
% exit

Vagrantfileがあるディレクトリ以外からもsshできるようにするには、.ssh/configに設定を書き込んでおく。

% vagrant ssh-config node0 >> ~/.ssh/config
% vagrant ssh-config node1 >> ~/.ssh/config
% vagrant ssh-config node2 >> ~/.ssh/config
% ssh node0
% exit

一旦VMを終了して、メモリの割り当てを増やす。

% vagrant halt

VirtualBoxの画面からVMの設定を開いて、メモリの割り当てを2GB以上にする。その後、VMを起動し直す。

% vagrant up

Clone this wiki locally