kumofs ã KVM ä¸ã® Debian(lenny) ã«ã¤ã³ã¹ãã¼ã«ãã¦åããã¾ã§
KVM on Debian(lenny) ã使ã£ããµã¼ããæ§ç¯ãã¦ã¿ã¾ãï¼
ã·ã¹ãã ã¤ã³ã¹ãã¼ã«
æå㯠virt-manager ãªã©ã§ VM ãä½æï¼ãã¹ãå㯠kumofs ã§æ¨æºã·ã¹ãã ã®ã¿ã«ï¼
ä¸æºå
ã¾ãã¯åºæ¬ã»ãããã¤ã³ã¹ãã¼ã«
$ su - # aptitude install sudo vim lv openssh-server # update-alternatives --config editor There are 4 alternatives which provide `editor'. Selection Alternative ----------------------------------------------- 1 /bin/ed *+ 2 /bin/nano 3 /usr/bin/vim.tiny 4 /usr/bin/vim.basic Press enter to keep the default[*], or type selection number: 4 Using '/usr/bin/vim.basic' to provide 'editor'. # visudo # addgroup wheel # adduser user wheel # logout
日本語ドキュメントãè¦ãã¨ä¸è¨ãå¿ è¦ãããã®ã§ã¤ã³ã¹ãã¼ã«ãã¾ãï¼
- linux >= 2.6.18
- g++ >= 4.1
- ruby >= 1.8.6
- Tokyo Cabinet >= 1.4.10
- MessagePack for C++ >= 0.3.1
- MessagePack for Ruby >= 0.3.1
- libcrypto (openssl)
- zlib
ã¾ã㯠Ruby 㨠C++ ãªã©ï¼
$ sudo aptitude install ruby1.8 ruby rubygems rubygems1.8 libcrypto++-dev zlib1g-dev build-essential
次㫠TokyoCabinet
$ mkdir tmp; cd tmp $ wget http://1978th.net/tokyocabinet/tokyocabinet-1.4.41.tar.gz $ tar zxvf tokyocabinet-1.4.41.tar.gz $ cd tokyocabinet-1.4.41/ $ ./configure $ sudo aptitude install libbz2-dev # TokyoCabinet ã«å¿ è¦ãªã®ã§è¿½å $ ./configure $ make $ sudo make install $ sudo vim /etc/ld.so.conf.d/local.conf /usr/local/lib $ sudo ldconfig
ãã㦠MessagePack ãï¼
$ cd ../ $ wget "http://sourceforge.jp/frs/redir.php?m=jaist&f=%2Fmsgpack%2F45459%2Fmsgpack-0.4.0.tar.gz" $ tar zxvf msgpack-0.4.0.tar.gz $ cd msgpack-0.4.0/ $ ./configure $ make $ sudo make install $ sudo gem install msgpack --no-ri --no-rdoc $ sudo aptitude install ruby1.8-dev ruby-dev # æ¡å¼µã©ã¤ãã©ãªãªã®ã§è¿½å ã§å¿ è¦ $ sudo gem install msgpack --no-ri --no-rdoc
æå¾ã« kumofs ãã¤ã³ã¹ãã¼ã«
$ cd ../ $ wget http://cloud.github.com/downloads/etolabo/kumofs/kumofs-0.3.0.tar.gz $ tar zxvf kumofs-0.3.0.tar.gz $ cd kumofs-0.3.0/ $ ./configure $ sudo aptitude install libssl-dev # ãã¡ããå¿ è¦ã ã£ãæ¨¡æ§ $ ./configure $ make $ sudo make install
ããã§ã¤ã³ã¹ãã¼ã«ã¯å®äºï¼çµå± Debian(lenny) ã«å¿ è¦ãªããã±ã¼ã¸ã¯ä¸è¨ã®éãï¼
- build-essential
- ruby1.8
- ruby
- ruby1.8-dev
- ruby-dev
- rubygems
- rubygems1.8
- libcrypto++-dev
- zlib1g-dev
- libbz2-dev
- libssl-dev
$ sudo aptitude install build-essential ruby1.8 ruby ruby1.8-dev ruby-dev rubygems rubygems1.8 libcrypto++-dev zlib1g-dev libbz2-dev libssl-dev
è¤æ°å°ã®ç¨æ
ãµã³ãã«ã§ã¯3å°æ§æã ã£ãã®ã§ï¼ããããã¨2ã¤ä½æãã¾ãï¼(kumofs / kumofs2 / kumofs3)ï¼ã¾ãå ã»ã©ä½æãã kumofs ã shutdown ãã¾ãï¼
$ sudo poweroff
次㫠KVM ãã¹ããã virt-clone ãã¾ãï¼MAC ã¢ãã¬ã¹ã¯ä¸ä½ã¢ãã¬ã¹ã被ããªãé©å½ãªã®ã«ï¼
$ sudo virt-clone --original kumofs --name kumofs2 --file kumofs2.img --mac 52:54:00:93:23:43 $ sudo virt-clone --original kumofs --name kumofs3 --file kumofs3.img --mac 52:54:00:93:29:12
ãã¦ãã®ã¾ã¾ã§ã¯ MAC ã¢ãã¬ã¹ãå¤ãã£ãããã«ãããã¯ã¼ã¯ããã¤ã¹ã追å ããã¦ãã¾ãã¾ãï¼ãã㧠console ã«å ¥ã£ã¦å¿ è¦ãªé¨åãç´æ¥å¤æ´ãã¾ãï¼
- /etc/udev/rules.d/70-persistent-net.rules ãã MAC ã¢ãã¬ã¹ãæ¸ããã¦ããè¡ãåé¤
- æãã2è¡ãã
- /etc/network/interface ã® address ã®é
ç®ãå¤æ´
- åºå®ã¢ãã¬ã¹ã®å ´å
- /etc/hostname ã®å¤æ´
- /etc/hosts ã®å¤æ´
192.168.123.10 kumofs 192.168.123.11 kumofs2 192.168.123.12 kumofs3
- åèµ·å
- hostname / ifconfig ã§å¤æ´ããã¦ãããã¨ã確èªï¼
- poweroff
ã¨ããæãã§2å°(kumofs2 / kumofs3)å®è¡ãã¾ãï¼æå¾ã® /etc/hosts ã®è¨å®ã kumofs ã«ããã¦å®äº
å®é¨éå§
ããããå®é¨éå§ï¼ããã¥ã¡ã³ãã«ããæ§æã¨ã®å¯¾å¿ã¯ä»¥ä¸ã®ããã«ãã¾ãï¼
- srv1 -> kumofs
- srv2 -> kumofs2
- srv3 -> kumofs3
- cli -> kumofs
kumo-manager ã®èµ·å
kumofs$ kumo-manager -v -l kumofs -p kumofs2 kumofs2$ kumo-manager -v -l kumofs2 -p kumofs
kumo-server ã®èµ·å
kumofs$ kumo-server -v -l kumofs -m kumofs -p kumofs2 -s /tmp/kumodb.tch kumofs2$ kumo-server -v -l kumofs2 -m kumofs -p kumofs2 -s /tmp/kumodb.tch kumofs3$ kumo-server -v -l kumofs3 -m kumofs -p kumofs2 -s /tmp/kumodb.tch
kumo-server ã®ç»é²
kumofs$ kumoctl kumofs status hash space timestamp: Thu Jan 01 09:00:00 +0900 1970 clock 0 attached node: not attached node: 192.168.123.10:19800 192.168.123.11:19800 192.168.123.12:19800 kumofs$ kumoctl kumofs attach nil
ããã§ã¶ãã¨ãã°ãæµãã¾ãï¼ã¡ãã£ã¨æ¥½ããï¼ããã«ãã¦ã nil ã¨è¡¨ç¤ºãããã¨ã¯ï¼ããã Ruby ãªã®ãï¼
ã¾ããhash space timestampãã®ã¨ããã 1970 å¹´ã¨ãã«ãªã£ã¦ããã®ã¯ï¼Time ã¯ã©ã¹ã®åºåºãªã®ã§ï¼ã¾ã å¤ãåå¾ã§ãã¦ãªãã£ã¦ãã¨ããªï¼å度 status ãè¦ãã¨ï¼
kumofs$ kumoctl kumofs status hash space timestamp: Tue Jan 19 11:09:32 +0900 2010 clock 230 attached node: 192.168.11.180:19800 (active) 192.168.11.181:19800 (active) 192.168.11.182:19800 (active) not attached node:
追å ããã¦ï¼æå»ãæ£å¸¸ã«ãªã£ã¦ã¾ããï¼
kumo-gateway ã®èµ·å
kumofs$ kumo-gateway -v -m kumofs -p kumofs -t 11211
memcache-client äºæã ãããªã®ã§ï¼telnet ã§ã¢ã¯ã»ã¹ãã¦ã¿ã¾ãï¼
kumofs$ telnet localhost 11211 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. set hoge 0 0 3 Foo STORED set bar 0 0 22 This is a sample text. STORED END Connection closed by foreign host. kumofs$ kumohash -m kumofs assigh hoge 0: 192.168.123.10:19800 1: 192.168.123.11:19800 2: 192.168.123.12:19800
kumohash ã®èª¬æã«ã¯ï¼ããããã¼ã¿ãã©ã®kumo-serverã«ä¿åããã¦ããã調ã¹ããã¨ãã£ãã®ã§ããï¼å ¨é¨åºã¦ãã¦ãã¾ãã¾ãï¼3å°ããããããã¡åæ£ãããªãï¼ã¾ãã¯ãã¼ã®æ°ãå°ãªãï¼
大éã®ãã¼ã¿æå ¥
ãªãããããªã®ã§å®é¨
#!/usr/bin/env ruby 1000000.times do |i| str = "" (rand(100)+1).times do |j| str += (65 + rand(26)).chr end puts "set var#{i} 0 0 #{str.length}" puts str end
kumofs$ ruby test.rb | telnet localhost 11211 (snip) STORED STORED STORED STORED test.rb:8:in `write': Broken pipe (Errno::EPIPE) from test.rb:8:in `puts' from test.rb:8 from test.rb:3:in `times' from test.rb:3
æ¢ã¾ã£ãã®ã§ä½ãï¼ã¨æã£ã¦ kumo-gateway ã®æ¹ãè¦ãã¨
ã»ã°ã¡ã³ãã¼ã·ã§ã³éåã§ã
telnet ãªã®ã§ä½ãããã®ãããã¡ãããµããã¨ãã§ããããï¼ãããããã¾ããã§ããï¼
ã¾ã¨ã
ã³ãã³ãã Ruby ã§æ¸ããã¦ãããããã®ã§ããããããã®ã¨ï¼åãããåæ£åæãªã®ãè¯ãæãã§ããï¼ãã ã»ããã¢ããã¯ã¨ãããï¼èµ·åã«æç¶ããå¿ è¦ã ã¨è¨ãã®ãï¼å®ç¨¼åããã¨ãã®å¤§ããªéå£ããªã¨æãã¾ããï¼å ¨ã¦åå¥ã«èµ·åã§ãã¦ï¼ããããã kumo-server / kumo-manager / kumo-gateway ã®èµ·åãé¢ç¥ãã¦èªåçã«æ¥ç¶ããããã«ãªãã°ï¼ãã使ãåæãå¢ãæãããã¾ãã*1ï¼
*1:ã¾ãä»®æ³ç°å¢ã ã¨ãããã¹ã¯ãªããã§ãã®é åºãå¶å¾¡ã§ããããªã®ã§ããï¼