ROMA 動かしてみた

下準備

ruby1.9 と eventmachine が必要
rvm でサクっと環境作って git から持ってくる

$ rvm 1.9.1 
$ gem install eventmachine
$ git clone git://github.com/roma/roma.git
$ cd roma/ruby/server

ここまでで準備完了

サーバ起動してみる

$ bin/mkroute localhost_11211 localhost_11212 --enabled_repeathost
$ bin/romad localhost -p 11211 -d --enabled_repeathost
991
$  bin/romad localhost -p 11212 -d --enabled_repeathost
1018

起動完了

接続してみる

$ telnet localhost 11211
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

で,実際に値を入れてみる

set foo 0 0 3
bar
STORED

入れた値を取得する

get foo     
VALUE foo 0 3
bar
END

おぉ,取れてる!!

もういっこからも取れるか見てみる

$ telnet localhost 11212
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
get foo
VALUE foo 0 3
bar
END

ちゃんと取れてる!!
すごい!!

一個無理矢理落してみる(障害想定)

$ ps aux | grep romad
yoshiori  1079   0.2  0.5  2461676   9600   ??  Ss    9:38PM   0:03.81 ruby bin/romad localhost -p 11212 -d --enabled_repeathost
yoshiori  1086   0.1  0.5  2461676   9624   ??  Ss    9:38PM   0:03.80 ruby bin/romad localhost -p 11211 -d --enabled_repeathost
yoshiori  1225   0.0  0.0  2425520    108 s001  R+    9:54PM   0:00.00 grep romad
$ kill 1079
$ ps aux | grep romad
yoshiori  1086   0.1  0.5  2461676   9632   ??  Ss    9:38PM   0:03.84 ruby bin/romad localhost -p 11211 -d --enabled_repeathost

で,もう一個のサーバに値入力

yoshiori@yoshiori-macbook $ telnet localhost 11211
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
set bar 0 0 4
hoge
STORED


で,さっき落したサーバを復旧させてデータ取得してみる

$ bin/romad localhost -p 11212 -d --enabled_repeathost
1280
$ telnet localhost 11212
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
get bar
VALUE bar 0 4
hoge
END


おぉ!!
ちゃんと同期された!!

終了

バルス!!!

balse
Are you sure?(yes/no)
yes
{"localhost_11211"=>"BYE"}
Connection closed by foreign host.