kumofsは、memcache互換のプロトコルをサポートする分散型KVS。
なぜかまだだれもdebを公開していなかったようなので、作り方を調べてみました。
基本手順
今時のデビアン系では、普通に「./configure && make && make install」で入るソフトウェアであれば、実質2コマンドでdeb化出来るようです。
- ソースを落として、「ソフトウェア名-バージョン」の名のディレクトリに展開
- dh_makeする
- debuildする
依存ライブラリを入れる
1 | sudo aptitude install build-essential ruby ruby-dev rubygems libtokyocabinet-dev |
aptで入るのはこれぐらいだと思われる。http://hatotech.org/kumatch/archives/2010/03/04/ubuntu_kumofs.html http://d.hatena.ne.jp/irasya/20100120/1263936307 等参照
deb作成に必要なパッケージを入れる
1 | sudo aptitude install dpkg-dev dh-make debhelper devscripts lintian |
先に、GPG公開鍵を作っておく
http://gnupg.hclippr.com/gnupg%E3%81%AE%E4%BD%BF%E3%81%84%E6%96%B9/ のとおりの手順で作成しときましょう。乱数生成が大変ですが、頑張って。
1 2 | sudo aptitude install gnupg gpg --gen-key |
参考:https://wiki.ubuntulinux.jp/UbuntuPackagingGuideJa/basic-scratch
gpg鍵を設定していない場合は、debuildからエラーが表示されるでしょう。gpg鍵を設定してもいいですが、debuildに-us -ucオプションを与えることで、署名をしないことも可能です。ただし、署名をしない限りUbuntuにパッケージをアップロードすることはできません。
つーことです。
まず、依存するライブラリであるMessagePackのdebを作成
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | $ tar xzf msgpack_0.5.2.tar.gz $ cd msgpack-0.5.2/ $ dh_make -e udzura@udzura.jp -c apache -f ../msgpack-0.5.2.tar.gz Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch or cdbs? [s/i/m/l/k/n/b] #=> i Maintainer name : Udzura Kondo Email-Address : udzura@udzura.jp Date : Tue, 20 Jul 2010 19:35:28 +0900 Package Name : msgpack Version : 0.5.2 License : apache Using dpatch : no Using quilt : no Type of Package : unknown Hit <enter> to confirm: Done. Please edit the files in the debian/ subdirectory now. msgpack uses a configure script, so you probably don't have to edit the Makefiles. |
メンテナがあなたになってしまいますが、まあ気にせずに。
バージョン0.5.2では make check でどうしても通りません(gtest.hを入れても通りません…)。いったん、make checkをしないように、 Makefile.in の617行目の以下をコメントアウト。
617 | check: check-recursive |
これで、
1 | $ debuild |
終了後、親のフォルダに無事にdebファイルが生成されます。
kumofsをdeb化
まず、先ほど生成したてのdebをインストールしないとビルドできません。
1 2 3 4 | $ cd .. $ sudo dpkg -i msgpack_0.5.2-1_all.deb # 一緒にこちらも $ sudo gem install msgpack |
あとの手順は一緒です。
1 2 3 4 | $ tar xzf kumofs-0.4.10.tar.gz $ cd kumofs-0.4.10/ $ dh_make -e udzura@udzura.jp -c apache -f ../kumofs-0.4.10.tar.gz $ debuild |
動くの?
まっさらなUbuntuサーバ(OpenSSH ServerのみONでインストール)に入れてみましょう。
あらかじめSFTPか何かでdebを送り込みます。
今回、全然依存とか考えずにdebuildしたので、手動で依存するっぽいパッケージを入れます。
1 | $ sudo aptitude install ruby ruby-dev rubygems libtokyocabinet8 |
あれ、これだけ?
deb本体を入れてみます。
1 2 3 4 | $ sudo dpkg -i msgpack_0.5.2-1_all.deb # このあと $ sudo gem install msgpack $ sudo dpkg -i kumofs_0.4.10-1_all.deb |
試運転します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | u-kondo@ubuntu-test01:~$ kumo-manager --usage usage: kumo-manager -l <addr[:port=19700]> -p <addr[:port=19700]> -p <addr[:port=19700]> --partner master-slave replication partner -a --auto-replace enable auto replacing -Rs <number=4> --replace-delay delay time of auto replacing in sec. -k <number=2> --keepalive-interval keepalive interval in seconds -Ys <number=10> --connect-timeout connect timeout time in seconds -Yn <number=4> --connect-retry-limit connect retry limit -Ci <number=2> --clock-interval clock interval in seconds -TW <number=2> --write-threads number of threads for asynchronous writing -TR <number=8> --read-threads number of threads for asynchronous reading -o <path.log> --log output logs to the file -g <path.mpac> --binary-log enable binary log -v --verbose -d <path.pid> --daemon v0.4.10 revision 0d4cb3a6797ce91ec8c1ee23fce6a3a1894ee618 Wed Jul 14 19:07:35 2010 +0900 error: unexpected argument: --usage u-kondo@ubuntu-test01:~$ sudo kumo-manager -v -l localhost & [1] 4255 u-kondo@ubuntu-test01:~$ 2010-07-20 18:53:11 ./manager/init.h:43: start manager 127.0.0.1:19700 u-kondo@ubuntu-test01:~$ u-kondo@ubuntu-test01:~$ sudo kumo-server -v -l localhost -m localhost -s /var/kumodb.tch & [2] 4270 u-kondo@ubuntu-test01:~$ 2010-07-20 18:53:20 ./server/init.h:45: start server 127.0.0.1:19800 u-kondo@ubuntu-test01:~$ 2010-07-20 18:53:22 ../rpc/client_tmpl.h:157: connecting to 127.0.0.1:19700 2010-07-20 18:53:22 ../rpc/client_tmpl.h:187: connect success 127.0.0.1:19700 fd(10) 2010-07-20 18:53:22 manager/framework.cc:69: new node 1 127.0.0.1:19800 2010-07-20 18:53:22 server/framework.cc:74: new node 0 127.0.0.1:19700 2010-07-20 18:53:22 manager/mod_replace.cc:35: server connected 127.0.0.1:19800 u-kondo@ubuntu-test01:~$ u-kondo@ubuntu-test01:~$ u-kondo@ubuntu-test01:~$ kumoctl localhost status hash space timestamp: Thu Jan 01 09:00:00 +0900 1970 clock 0 attached node: not attached node: 127.0.0.1:19800 u-kondo@ubuntu-test01:~$ u-kondo@ubuntu-test01:~$ u-kondo@ubuntu-test01:~$ kumoctl localhost attach 2010-07-20 18:53:35 manager/mod_replace.cc:161: update hash space at time(5495924397745111052) 2010-07-20 18:53:35 manager/mod_replace.cc:173: new server: 127.0.0.1:19800 2010-07-20 18:53:35 manager/mod_replace.cc:254: start replace copy; full=0 2010-07-20 18:53:35 manager/mod_replace.cc:272: active node: 1 nil 2010-07-20 18:53:35 server/mod_replace.cc:189: start replace copy for time(5495924397745111052) 2010-07-20 18:53:35 server/mod_replace.cc:214: dst active node: 127.0.0.1:19800 2010-07-20 18:53:35 server/mod_replace.cc:218: empty hash space. skip replacing. 2010-07-20 18:53:35 server/mod_replace.cc:386: finish replace copy for time(5495924397745111052) 2010-07-20 18:53:35 manager/mod_replace.cc:365: start replace delete time(5495924397745111052) 2010-07-20 18:53:35 server/mod_replace.cc:437: start replace delete for time(5495924397745111052) 2010-07-20 18:53:35 server/mod_replace.cc:459: finish replace for time(5495924397745111052) 2010-07-20 18:53:35 manager/mod_replace.cc:401: replace finished time(5495924397745111052) u-kondo@ubuntu-test01:~$ u-kondo@ubuntu-test01:~$ u-kondo@ubuntu-test01:~$ kumoctl localhost status hash space timestamp: Tue Jul 20 18:53:35 +0900 2010 clock 12 attached node: 127.0.0.1:19800 (active) not attached node: u-kondo@ubuntu-test01:~$ u-kondo@ubuntu-test01:~$ u-kondo@ubuntu-test01:~$ sudo kumo-gateway -v -m localhost -t 11211 & [3] 4289 u-kondo@ubuntu-test01:~$ 2010-07-20 18:53:47 ../rpc/client_tmpl.h:157: connecting to 127.0.0.1:19700 2010-07-20 18:53:47 ../rpc/client_tmpl.h:187: connect success 127.0.0.1:19700 fd(7) u-kondo@ubuntu-test01:~$ u-kondo@ubuntu-test01:~$ |
動いているようですが、、、
ホストOSからtelnetで繋いでみましょう。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | $ telnet 192.168.122.71 11211 Trying 192.168.122.71... Connected to 192.168.122.71. Escape character is '^]'. get foo VALUE foo 0 5 12345 END set hogehoge 0 0 20 hogehogehogehogehoge STORED get hogehoge VALUE hogehoge 0 20 hogehogehogehogehoge END exit Connection closed by foreign host. |
kumofs側へ。
1 2 3 | u-kondo@ubuntu-test01:~$ kumohash -m localhost assign foo db0f3feab5c7ee0b foo 0: 127.0.0.1:19800 |
ちゃんと動いているようです!
スクラッチビルドよりはるかに手順が少なくなりました。
今後
元々の目的は「沢山のサーバにいれてためしたいのに、いちいちスクラッチビルドするのは面倒。。。」と思って適当でもdeb化して社内にでも配布仕様と思っていたのですが。
- もっとまともに依存関係を書く
- libmsgpack-ruby的なdebも作る。RubyのGemだとどう作るんだろう?
- PPAに公開する方法を調べる
以上を頑張れば、僕のPPAにkumofsリポジトリを公開したりすることもできますね。