-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add translated version of new tutorial
- Loading branch information
Showing
2 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
210 changes: 210 additions & 0 deletions
210
ja/tutorial/1.0.6/virtual-machines-for-experiments/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
--- | ||
title: "Droongaチュートリアル: 実験用の仮想マシンを用意する手順" | ||
layout: ja | ||
--- | ||
|
||
{% comment %} | ||
############################################## | ||
THIS FILE IS AUTOMATICALLY GENERATED FROM | ||
"_po/ja/tutorial/1.0.6/virtual-machines-for-experiments/index.po" | ||
DO NOT EDIT THIS FILE MANUALLY! | ||
############################################## | ||
{% endcomment %} | ||
|
||
|
||
* TOC | ||
{:toc} | ||
|
||
## チュートリアルのゴール | ||
|
||
実験用に複数(3台)の仮想マシンを用意する手順を学ぶこと。 | ||
|
||
## なぜ仮想マシンが必要なのか? | ||
|
||
Droongaは分散型のデータ処理システムなので、クラスタを構成するには複数の台のコンピュータを用意する必要があります。 | ||
安全のためにも(そしてより良い性能を得るためにも)、Droongaノードにはそれ用のコンピュータを用意することが望ましいです。 | ||
|
||
有効なレプリケーションのためには、2台以上のコンピュータが必要です。 | ||
また、クラスタ構成の管理を試してみるには、3台以上のコンピュータが必要となります。 | ||
|
||
しかしながら、仮に、単に検証や開発をしたい場合でも、複数の仮想マシンのインスタンスをVPSサービスで利用するにはお金がかかります。 | ||
そのような用途では、あなたの手持ちのコンピュータ上でプライベートな仮想マシンを使うのがおすすめです。 | ||
|
||
幸いなことに、[Vagrant][]を使うと仮想マシンを簡単に管理することができます。 | ||
このチュートリアルでは、Vagrantを使って*3台の仮想マシンを用意する手順*を解説します。 | ||
|
||
## ホストマシンを用意する | ||
|
||
まず最初に、仮想マシンのホストとなるPCを用意する必要があります。 | ||
仮想マシンは多くのRAMを要求するため、ホストマシンにはできれば8GB以上のメモリがあることが望ましいです。 | ||
|
||
(ただ、単なる実験のためであれば、3GB程度のメモリがあればどうにかなります。 | ||
Droongaシステムを構成するコンポーネントをインストールする時には、[Rroonga][]のネイティブ拡張をビルドするために最低でも2GB程度のメモリが必要になります。 | ||
しかし一度ビルドが終わってしまえば、その後は各Droongaノードには512MBかその程度のメモリがあれば十分に動作します。) | ||
|
||
## 仮想マシンを用意する手順 | ||
|
||
### VirtualBoxをインストールする | ||
|
||
Vagrantには、仮想マシンを実行するためのバックエンドが必要です。ここでは推奨環境の[VirtualBox][]をインストールすることにします。 | ||
例えば、ホストマシンが[Ubuntu][]で動作するPCなのであれば、VirtualBoxは以下のように`apt`コマンドでインストールできます: | ||
|
||
~~~ | ||
$ sudo apt-get install virtualbox | ||
~~~ | ||
|
||
### Vagrantをインストールする | ||
|
||
[VagrantのWebサイト][Vagrant]にある手順に従って、Vagrantをインストールします。 | ||
例えば、ホストマシンがx64のUbuntu PCなのであれば、以下の要領です: | ||
|
||
~~~ | ||
$ sudo apt-get install virtualbox | ||
$ wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.5_x86_64.deb | ||
$ sudo dpkg -i vagrant_1.6.5_x86_64.deb | ||
~~~ | ||
|
||
### boxの種類を決めて、Vagrantfileを用意する | ||
|
||
[Vagrant Cloud][]のサイトから、実験に使うためのboxを選びます。 | ||
例えば[Ubuntu Trusty (x64)のbox](https://vagrantcloud.com/ubuntu/boxes/trusty64)を使うのであれば、以下のようにします: | ||
|
||
~~~ | ||
$ mkdir droonga-ubuntu-trusty | ||
$ cd droonga-ubuntu-trusty | ||
$ vagrant init ubuntu/trusty64 | ||
~~~ | ||
|
||
この操作で、設定ファイルの`Vagrantfile`が自動生成されます。 | ||
しかし、このファイルはDroongaクラスタの実験のために、以下のように完全に書き換えてしまいます: | ||
|
||
`Vagrantfile`: | ||
|
||
~~~ | ||
n_machines = 3 | ||
box = "ubuntu/trusty64" | ||
VAGRANTFILE_API_VERSION = "2" | ||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
n_machines.times do |index| | ||
config.vm.define :"node#{index}" do |node_config| | ||
node_config.vm.box = box | ||
node_config.vm.network(:private_network, | ||
:ip => "192.168.100.#{50 + index}") | ||
node_config.vm.host_name = "node#{index}" | ||
node_config.vm.provider("virtualbox") do |virtual_box| | ||
virtual_box.memory = 2048 | ||
end | ||
end | ||
end | ||
end | ||
~~~ | ||
|
||
注:この`Vagrantfile`では、3つの仮想マシンを2GB(2048MB)のメモリを伴って定義しています。 | ||
ですので、ホストマシンは6GB以上のメモリを搭載している必要があります。 | ||
もしホストマシンのメモリがそこまで多くないのであれば、この時点では`512`(512MB)などの適当な値を設定しておいて下さい。 | ||
|
||
### 仮想マシンを起動する | ||
|
||
仮想マシンは、`vagrant up`というコマンドで起動できます: | ||
|
||
~~~ | ||
$ vagrant up | ||
Bringing machine 'node0' up with 'virtualbox' provider... | ||
Bringing machine 'node1' up with 'virtualbox' provider... | ||
Bringing machine 'node2' up with 'virtualbox' provider... | ||
... | ||
~~~ | ||
|
||
これにより、Vagrantは自動的に仮想マシンのイメージを[Vagrant Cloud][]のWebサイトからダウンロードし、それが終わり次第仮想マシンを起動します。 | ||
用意が完了すると、仮想ネットワーク上のIPアドレスとして`192.168.100.50`、`192.168.100.51`、`192.168.100.52`をそれぞれ持つ3台の仮想マシンが動作している状態になります。 | ||
|
||
仮想マシンが正しく動いていることを確認しましょう。 | ||
仮想マシンには`vagrant ssh`コマンドを使って以下のようにログインできます: | ||
|
||
~~~ | ||
$ vagrant ssh node0 | ||
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-36-generic x86_64) | ||
... | ||
vagrant@node0:~$ exit | ||
~~~ | ||
|
||
|
||
### 仮想マシンをSSHクライアントに登録する | ||
|
||
仮想マシンにログインするためには、通常の`ssh`コマンドではなく、`vagrant ssh`コマンドを使わなくてはなりません。 | ||
また、その前には`Vagrantfile`があるディレクトリに`cd`する必要もあります。 | ||
これは少々面倒です。 | ||
|
||
ですので、SSHクライアントのローカル設定ファイルに、以下のようにして仮想マシンのための設定を追加しておきましょう: | ||
|
||
~~~ | ||
$ vagrant ssh-config node0 >> ~/.ssh/config | ||
$ vagrant ssh-config node1 >> ~/.ssh/config | ||
$ vagrant ssh-config node2 >> ~/.ssh/config | ||
~~~ | ||
|
||
これで、`vagrant ssh`コマンドを使わずとも、仮想マシンの名前を指定してログインできるようになります: | ||
|
||
~~~ | ||
$ ssh node0 | ||
~~~ | ||
|
||
### 仮想マシン同士で互いのホスト名を名前解決できるように設定する | ||
|
||
ネームサーバがないので、各仮想マシンはお互いのホスト名を名前解決する事ができません。 | ||
そのため、現時点ではそれぞれのIPアドレスを直接書く必要があります。 | ||
これは非常に面倒です。 | ||
|
||
なので、各仮想マシンのhostsファイルを以下のように編集しておきましょう: | ||
|
||
`/etc/hosts`: | ||
|
||
~~~ | ||
127.0.0.1 localhost | ||
192.168.100.50 node0 | ||
192.168.100.51 node1 | ||
192.168.100.52 node2 | ||
~~~ | ||
|
||
これで、各マシンはお互いにホスト名を指定して通信できるようになります。 | ||
|
||
### 仮想マシンの終了 | ||
|
||
仮想マシンは、`vagrant halt`コマンドでまとめて終了できます: | ||
|
||
~~~ | ||
$ vagrant halt | ||
~~~ | ||
|
||
これで、Vagrantがすべての仮想マシンを完全に終了させてくれます。 | ||
|
||
### 付録: ホストマシンのRAMがそれほど多くない場合 | ||
|
||
ホストマシンのメモリが小さい(例えば3GB未満)と、2GBのメモリを持った状態の仮想マシンは複数起動できません。 | ||
しかしながら、仮想マシンのメモリを小さく設定すると(例えば512MB)、Droongaのサービスをインストールできません。 | ||
|
||
このような場合、以下の手順でDroongaのサービスを各仮想マシンに1台ずつインストールできます: | ||
|
||
1. `vagrant halt`ですべての仮想マシンを終了する。 | ||
2. `virtualbox`でVirtualBoxのコンソールを開く。 | ||
3. 1台の仮想マシンのプロパティを開き、メモリの大きさを2GB(2048MB)に設定し直す。 | ||
4. VirtualBoxのコンソールからその仮想マシンを起動する。 | ||
5. 仮想マシンにログインし、Droongaのサービスをインストールする。 | ||
6. 仮想マシンを終了する。 | ||
7. 仮想マシンのプロパティを開き、メモリの大きさを元に戻す。 | ||
8. 3から7の手順を他の仮想マシンにも繰り返す。 | ||
|
||
## まとめ | ||
|
||
このチュートリアルでは、Droongaノード用に3台の仮想マシンを用意する手順を学びました。 | ||
|
||
これで、[「使ってみる」のチュートリアル](../groonga/)を複数ノードで実践できます。 | ||
|
||
[Vagrant]: https://www.vagrantup.com/ | ||
[Vagrant Cloud]: https://vagrantcloud.com/ | ||
[VirtualBox]: https://www.virtualbox.org/ | ||
[Rroonga]: https://github.com/ranguba/rroonga | ||
[Ubuntu]: http://www.ubuntu.com/ | ||
[Droonga]: https://droonga.org/ | ||
[Groonga]: http://groonga.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
layout: redirect-to-current-version | ||
unversioned_path: /tutorial/ | ||
--- | ||
|
||
{% comment %} | ||
############################################## | ||
THIS FILE IS AUTOMATICALLY GENERATED FROM | ||
"_po/ja/tutorial/virtual-machines-for-experiments/index.po" | ||
DO NOT EDIT THIS FILE MANUALLY! | ||
############################################## | ||
{% endcomment %} | ||
|