LoginSignup
8
8

More than 5 years have passed since last update.

Riak2をインストールしてみる

Last updated at Posted at 2013-12-01

Basho社が開発するRiak。
現在はバージョン2の開発が進められており、近いうちに正式版がリリースされるだろう。
今回は開発バージョンである2.0.0pre7をインストールする。

erlangのインストール

Riakはelrangで作られているので、まずはビルドのためerlangをインストールする。
Riakをビルドするため、erlnagのバージョンはR15B03-1を用いる。
http://erlang-users.jp/ にErlangのソースや情報が集まっているので参考にする。

[vagrant@localhost ~]$ wget http://download.basho.co.jp.cs-ap-e1.ycloud.jp/otp/download/otp_src_R15B03-1.tar.gz
[vagrant@localhost ~]$ tar zxvf otp_src_R15B03-1.tar.gz
[vagrant@localhost ~]$ cd otp_src_R15B03-1
[vagrant@localhost otp_src_R15B03]$ ./configure --enable-m64-build --disable-hipe --enable-dtrace
[vagrant@localhost otp_src_R15B03]$ make
[vagrant@localhost otp_src_R15B03]$ sudo make install

configureした時に以下のように不足ライブラリが警告されるかもしれない。

*********************************************************************
**********************  APPLICATIONS DISABLED  **********************
*********************************************************************

jinterface     : No Java compiler found
odbc           : ODBC library - link check failed

*********************************************************************
*********************************************************************
**********************  APPLICATIONS INFORMATION  *******************
*********************************************************************

wx             : wxWidgets not found, wx will NOT be usable

*********************************************************************
*********************************************************************
**********************  DOCUMENTATION INFORMATION  ******************
*********************************************************************

documentation  :
                 xsltproc is missing.
                 fop is missing.
                 The documentation can not be built.

*********************************************************************

pam-develはriak本体に必須なので同じくインストール。
javaはRiak2.0の新機能Yokozunaに必須。

[vagrant@localhost ~]$ sudo yum install unixODBC-devel.x86_64 java-1.7.0-openjdk-devel.x86_64 pam-devel.x86_64

riakのビルド

最新のpreタグが付いたコミットを持ってきて、rebarというBasho製ビルドツールでコンパイルする

[vagrant@localhost ~]$ git clone https://github.com/basho/riak.git
[vagrant@localhost ~]$ cd riak
[vagrant@localhost riak]$ git checkout riak-2.0.0pre7
[vagrant@localhost riak]$ make rel

riakの基本操作(コマンド編)

起動前に、ファイルディスクリプタ上限値を4096とか大きな値にしておく。

[vagrant@localhost riak]$ ulimit -n 4096
[vagrant@localhost riak]$ rel/riak/bin/riak start
[vagrant@localhost riak]$ rel/riak/bin/riak ping
pong
[vagrant@localhost riak]$ rel/riak/bin/riak stop
ok

riakの基本操作(rest編)

RiakにはwebmachineというHTTPサーバが入っているので、RESTでアクセスできる。
さっきの死活監視はこう。

[vagrant@localhost riak]$ curl -v http://127.0.0.1:8098/ping
* About to connect() to 127.0.0.1 port 8098 (#0)
*   Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 8098 (#0)
> GET /ping HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 127.0.0.1:8098
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: MochiWeb/1.1 WebMachine/1.10.5 (jokes are better explained)
< Date: Sun, 01 Dec 2013 11:06:31 GMT
< Content-Type: text/html
< Content-Length: 2
<
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0
OK

riakの基本操作(クライアントライブラリ編)

Erlangシェルに入り、Riakのクライアントライブラリからアクセスする。
内部ではProtocol Bufferを使っている。

[vagrant@localhost ~]$ git clone git://github.com/basho/riak-erlang-client.git
[vagrant@localhost ~]$ cd riak-erlang-client/
[vagrant@localhost riak-erlang-client]$ make

クライアントライブラリをロードパスに加えてErlangシェルに入って操作を行う。

[vagrant@localhost riak-erlang-client]$ erl -pa ebin/ deps/*/ebin
Erlang R15B03 (erts-5.9.3.1) [source] [64-bit] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9.3.1  (abort with ^G)
1> {ok, Pid} = riakc_pb_socket:start_link("127.0.0.1", 8087).
{ok,<0.33.0>}
2> riakc_pb_socket:ping(Pid).
pong

ちなみにerlangシェルは2回C-cを押すと出ることができる。

8
8
0

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
8
8