25
23

More than 5 years have passed since last update.

dockerで5台構成のRiakをサクッと試す

Last updated at Posted at 2013-09-22

Running a Riak service - Docker Documentationの一番最後のNext Stepsのところだけ試したメモです。

Why Your Riak Cluster Should Have At Least Five Nodes | Bashoによると開発環境では3台構成でもよいけど、プロダクション環境では最低5台構成が良いらしいです。

なるべくプロダクションと同じ構成で普段から挙動を見ておきたいと考えるならば、開発環境も5台構成で試しておきたいところです。

でもVirtualBoxで5つもVM作るのはMacBook Airではきついですよね。dockerなら5台構成でも簡単です。

dockerの環境はMacOSX - OSX, Vagrant, VirtualBoxでdockerを試す - Qiita [キータ]の手順で予めセットアップ済みとします。

あとはhectcastro/docker-riakの手順通り実行します。

セットアップ

$ sudo apt-get install -y git curl make sshpass
$ git clone https://github.com/hectcastro/docker-riak.git
$ cd docker-riak
$ make
$ make riak-container

Riak起動

vagrant@precise64:~/docker-riak$ make start-cluster
./bin/start-cluster.sh
Started [riak1] and assigned it the IP [33.33.33.10]
Started [riak2] and assigned it the IP [33.33.33.20]
Requesting that [riak2] join the cluster..
Success: staged join request for 'riak@33.33.33.20' to 'riak@33.33.33.10'
Started [riak3] and assigned it the IP [33.33.33.30]
Requesting that [riak3] join the cluster..
Success: staged join request for 'riak@33.33.33.30' to 'riak@33.33.33.10'
Started [riak4] and assigned it the IP [33.33.33.40]
Requesting that [riak4] join the cluster..
Success: staged join request for 'riak@33.33.33.40' to 'riak@33.33.33.10'
Started [riak5] and assigned it the IP [33.33.33.50]
Requesting that [riak5] join the cluster..
Success: staged join request for 'riak@33.33.33.50' to 'riak@33.33.33.10'
=============================== Staged Changes ================================
Action         Details(s)
-------------------------------------------------------------------------------
join           'riak@33.33.33.20'
join           'riak@33.33.33.30'
join           'riak@33.33.33.40'
join           'riak@33.33.33.50'
-------------------------------------------------------------------------------


NOTE: Applying these changes will result in 1 cluster transition

###############################################################################
                         After cluster transition 1/1
###############################################################################

================================= Membership ==================================
Status     Ring    Pending    Node
-------------------------------------------------------------------------------
valid     100.0%     20.3%    'riak@33.33.33.10'
valid       0.0%     20.3%    'riak@33.33.33.20'
valid       0.0%     20.3%    'riak@33.33.33.30'
valid       0.0%     20.3%    'riak@33.33.33.40'
valid       0.0%     18.8%    'riak@33.33.33.50'
-------------------------------------------------------------------------------
Valid:5 / Leaving:0 / Exiting:0 / Joining:0 / Down:0

Transfers resulting from cluster changes: 51
  12 transfers from 'riak@33.33.33.10' to 'riak@33.33.33.50'
  13 transfers from 'riak@33.33.33.10' to 'riak@33.33.33.40'
  13 transfers from 'riak@33.33.33.10' to 'riak@33.33.33.30'
  13 transfers from 'riak@33.33.33.10' to 'riak@33.33.33.20'

Commit these cluster changes? (y/n): y
Cluster changes committed
vagrant@precise64:~/docker-riak$

起動状態をdocker psで確認します。

vagrant@precise64:~/docker-riak$ sudo docker ps
ID                  IMAGE                    COMMAND                CREATED             STATUS              PORTS
124ab8d89f5d        hectcastro/riak:latest   /usr/bin/supervisord   11 seconds ago      Up 11 seconds       49184->8087, 49185->8098, 49186->22   
d83f8daf6c5e        hectcastro/riak:latest   /usr/bin/supervisord   16 seconds ago      Up 15 seconds       49181->8087, 49182->8098, 49183->22   
400c498b644c        hectcastro/riak:latest   /usr/bin/supervisord   19 seconds ago      Up 19 seconds       49178->8087, 49179->8098, 49180->22   
603b0e6c4892        hectcastro/riak:latest   /usr/bin/supervisord   23 seconds ago      Up 23 seconds       49175->8087, 49176->8098, 49177->22   
f073cb8850c8        hectcastro/riak:latest   /usr/bin/supervisord   27 seconds ago      Up 26 seconds       49172->8087, 49173->8098, 49174->22

値の設定と取得のテスト

Basic Riak API Operationsを参考に試してみました。

まず、値の設定を試します。

vagrant@precise64:~/docker-riak$ curl -v -d 'this is a test' \
> -H "Content-Type: text/plain" \
> http://33.33.33.10:8098/riak/test/doc
* About to connect() to 33.33.33.10 port 8098 (#0)
*   Trying 33.33.33.10... connected
> POST /riak/test/doc HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: 33.33.33.10:8098
> Accept: */*
> Content-Type: text/plain
> Content-Length: 14
> 
* upload completely sent off: 14out of 14 bytes
< HTTP/1.1 204 No Content
< Vary: Accept-Encoding
< Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
< Date: Sun, 22 Sep 2013 16:00:01 GMT
< Content-Type: text/plain
< Content-Length: 0
< 
* Connection #0 to host 33.33.33.10 left intact
* Closing connection #0
vagrant@precise64:~/docker-riak$

値を取得してみます。値の最後に改行がないのでプロンプトと繋がっていますが、正しく取得できています。

vagrant@precise64:~/docker-riak$ curl http://33.33.33.10:8098/riak/test/doc
this is a testvagrant@precise64:~/docker-riak$

値を削除して消えたことを確認。

vagrant@precise64:~/docker-riak$ curl -v -X DELETE http://33.33.33test/doc/riak/ 
* About to connect() to 33.33.33.50 port 8098 (#0)
*   Trying 33.33.33.50... connected
> DELETE /riak/test/doc HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: 33.33.33.50:8098
> Accept: */*
> 
< HTTP/1.1 204 No Content
< Vary: Accept-Encoding
< Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
< Date: Sun, 22 Sep 2013 16:01:18 GMT
< Content-Type: text/plain
< Content-Length: 0
< 
* Connection #0 to host 33.33.33.50 left intact
* Closing connection #0
vagrant@precise64:~/docker-riak$ curl http://33.33.33.10:8098/riak/test/doc
not found
vagrant@precise64:~/docker-riak$
25
23
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
23