kumofs �������Ă݂�

kumofs �������Ă݂��̂Ń������܂Ƃ߂Ă����B �L�q���e�̃x�[�X�� 2010.04.30 ���_�ł̎������e�Ɋ�Â��Ă���B

kumofs �Ƃ�

  • kumofs �͕��U�^�� key value store �ł���B
  • ���O�̗R���� �_ fast storage �ł���B
  • �f�[�^�ێ��T�[�o�͓��I�ɒlj��E���E���邱�Ƃ��ł���B
  • memcached �ƌ݊����̂���C���^�t�F�C�X�����B
    • set / get / delete ���ł���B
    • �ׂ����I�v�V���� (flags �Ƃ� expiration time �Ƃ�) �̓o�[�W�����ɂ���� �T�|�[�g���Ă����肢�Ȃ������肷��B
    • 0.4.0 �� CAS (Compare-And-Swap) ������T�|�[�g�����B
  • Ficia (�I�����C���ʐ^�Ǘ��T�[�r�X)�Ŏg�p����Ă���B
  • ���Ƃ�ڂŌË���V���ɂ���č��ꂽ�B
  • 2010.01.18 �ɃI�[�v���\�[�X�\�t�g�E�F�A�Ƃ��ă����[�X���ꂽ�B
  • ���C�Z���X�� Apache License 2.0 ���̗p���Ă���B
  • ���J������ github �ɒu����Ă���B
  • �X�V���� ��҂̃u���O �y�� ��҂� twitter �Ȃǂ��瓾����B
  • twitter hashtag �ɂ� #kumofs ���g���Ă���B
  • SoftwareDesign 2010 �N 02 �����ɓ��W������B
  • 2010.05.01 ���_�� version 0.3.5 �ł���B

�\��

kumofs �͎O��ނ̃v���O�����œ��삷��B

  manager ... �S�̂̓������s���Ǘ��T�[�o�B
  server  ... �f�[�^��ۑ�����T�[�o�B���v���P�[�V�������s���B
  gateway ... �A�v���P�[�V������ server �̋��n�����s���B

�����𕪒S���邱�ƂŃX�P�[�����镔�������m�ɂȂ��Ă���B

manager

manager �̓T�[�o�Q�̓������s���B �P�@�܂��͂Q�@ �œ��삷��B �Q�@����ꍇ�� master-slave �Ń��v���P�[�V�������s���B

manager �ł́A kumoctl �Ȃǂ� cli ��p���ď�Ԋm�F��T�[�o�� attach �Ȃǂ��s�����Ƃ��ł���B �u���E�U�Ƃ����� GUI �Ƃ����v��Ȃ��Ƃ��낪�ǂ��B ��ƃ��O���c�����肷�鎞�ɕ֗������A�L�����N�^�[��������Ώ�Ԋm�F���ł��� ���Ă����͎̂��ɃO�b�h���B

�f�t�H���g�ł̓|�[�g�ԍ� 19700 �� LISTEN ����B

server

server �̓f�[�^�̕ێ��ƃ��v���P�[�V�������s���B �P�@���炎�@�܂ŁB���I�ɒlj��E���E�ł���B

�f�[�^�ێ��p�̃o�b�N�G���h�� Tokyo Cabinet �̃n�b�V���f�[�^�x�[�X���g�p����B

�f�t�H���g�ł̓|�[�g�ԍ� 19800 �� 19900 �� LISTEN ����B

gateway

gateway �� �A�v���P�[�V������ server �̋��n��������B �A�v���P�[�V�����𓮂����T�[�o��œ������̂ŁA�䐔�Ƃ��Ă͂P�@���炎�@�ƂȂ�B

�A�v���P�[�V��������� localhost �œ����Ă��� memcached �T�[�o �ł��邩�̂悤�Ɍ�����(������)�B

�A�v���P�[�V������ kumofs �ɃA�N�Z�X����ɂ� memcached �v���g�R�����g�p����B

�����Ă݂�

�����@�ނ� �ȉ��̒ʂ�B

�{��
  ThinkPad x61s 15th Anniversary Edition

  % uname -rms
  FreeBSD 7.0-STABLE i386
  �x�[�X�V�X�e���� 2008.03.31 ��cvsup/buildworld
  ports �c���[��   2010.04.28 ��cvsup

  % dmesg | grep 'real memory'
  real memory  = 2120941568 (2022 MB)

�܂��͑S�@�\�����Ŋ撣���Ă݂�B

����

FreeBSD �ł� ports ���瓱���ł���B�J�e�S���� databases �ł���B �����e�i�� kuriyama ����ł���B

�o�[�W������ 2010.04.28 ���_�� 0.3.4 �ł��������A ���̃����������Ă���Œ��� 2010.05.01 �ɂȂ�A0.3.5 �ɏオ�����B (2010.05.20 �NjL:0.4.0 �ɏオ�����B) ���Ȃ胉�C�u�ɒǏ]����Ă���l�q�Ȃ̂ŁA��ǃr���h���l����K�v�͂Ȃ������B

�ˑ��֌W�͂R�B���ɂ�����B

  • �o�b�N�G���h�� databases/tokyocabinet
  • �V���A���C�Y�̂��߂�(�H) devel/msgpack
  • msgpack �� ruby �C���^�t�F�C�X devel/rubygem-msgpack
  • rubygem ���o�Ă���̂ŁAlang/ruby

ruby �͏㉺�ɔg�y����ˑ����傫�����A����ȊO�̈ˑ��֌W�̓V���v�����B ���ǂ��� FreeBSD �@�Ȃ� ruby �͓����Ă��邾�낤����A ���� ports/packages �Ƃ̑����Ƃ��o�b�e�B���O�Ƃ��̐S�z�͖��� �ƌ����Ă������낤�B

�C���X�g�[��

�C���X�g�[���͒ʏ�� ports �̎菇�ő��v���B

 # cd /usr/ports/databases/kumofs
 # make

�܂��� (�����Ă��Ȃ����) BUILD_DEPENDS �� port �������B tokyocabinet �̓C���X�g�[���I�v�V�����𕷂��Ă���B ���ɂ�����肪�Ȃ���΃f�t�H���g�ŗǂ��B ���Ȃ݂Ƀf�t�H���g�͈ȉ��̒ʂ�B

                [ ] DEBUG    Debugging support
                [ ] DEVEL    Development build
                [ ] PROFILE  Profiling build
                [ ] OFF64    Use to compile on 64-bit system
                [ ] FASTEST  Fastest run
                [ ] SWAB     Swapping byte-orders build
                [ ] UYIELD   Detecting race conditions
                [ ] ZLIB     Disable ZLIB compression
                [X] BZIP2    BZIP2 compression
                [ ] PTHREAD  Disable POSIX thread support

make ���I������C���X�g�[������B

 # make install
 (����)
 ----
       This port has installed the following startup scripts which may cause
       these network services to be started at boot time.
 /usr/local/etc/rc.d/kumofs-manager
 /usr/local/etc/rc.d/kumofs-gateway
 /usr/local/etc/rc.d/kumofs-server
 ----
 (����)
 ----
       For more information, and contact details about the security
       status of this software, see the following webpage:
 http://github.com/etolabo/kumofs
 ----
 # ls /usr/local/bin/kumo*
 /usr/local/bin/kumo-gateway     /usr/local/bin/kumolog
 /usr/local/bin/kumo-manager     /usr/local/bin/kumomergedb
 /usr/local/bin/kumo-server      /usr/local/bin/kumostat
 /usr/local/bin/kumoctl          /usr/local/bin/kumotop
 /usr/local/bin/kumohash

rc �X�N���v�g�� /usr/local/etc/rc.d/ �ɂR�‚ł���B pkg-plist ������΂킩��ʂ�A�C���X�g�[�������t�@�C���͑S�� �ukumo�v�̐ړ������t���Ă���̂ŁA�킩��₷���B �ł� k u m o ���ăL�[�{�[�h��͑S���E��Ȃ̂ŁA���\�ł��ɂ��������B

�N��

���񓮍�܂ł́A �{�ƃh�L�������g �́u�`���[�g���A���v�����Ȃ�����Ƃ悢�B �{�Ƃ̃h�L�������g�́A�{���ɒ��J�ɏ�����Ă���B

�N���̏��Ԃ�

  • kumofs-manager
  • kumofs-server
  • kumofs-gateway

�ł���B

ports ���񋟂��Ă���Ă��� rc �X�N���v�g�� manager ���Q�䂠��O��Ȃ̂ŁA �����ł͈��̎��@�őS���グ��蓮�N���̎菇�� �u���ׂẴv���Z�X��localhost�œ������v���Q�l�ɁA�኱���������ď����Ă����B

manager �̋N���͈ȉ��̒ʂ�B�����p�Ƃ������ƂŁA�V���O���\���ł���B

 # /usr/local/bin/kumo-manager \
   -l localhost -d /var/run/kumofs/manager.pid -o /var/log/kumofs/manager.log
 # netstat -na | grep 19700
 tcp4       0      0  *.19700                *.*                    LISTEN

server �̋N���͈ȉ��̒ʂ�B�����p�Ƃ������ƂŁA�R�{�N�����Ă݂��B �V���O���\���Ȃ̂ŁA�|�[�g�ԍ���ς��ċN������B���Ȃ݂Ƀf�t�H���g�͖��� 0 ���B

 # /usr/local/bin/kumo-server \
   -m localhost -l localhost:19801 -L 19901 \
   -d /var/run/kumofs/server1.pid -o /var/log/kumofs/server1.log \
   -s /var/db/kumofs1.tch
 # /usr/local/bin/kumo-server \
   -m localhost -l localhost:19802 -L 19902 \
   -d /var/run/kumofs/server2.pid -o /var/log/kumofs/server2.log \
   -s /var/db/kumofs2.tch
 # /usr/local/bin/kumo-server \
   -m localhost -l localhost:19803 -L 19903 \
   -d /var/run/kumofs/server3.pid -o /var/log/kumofs/server3.log \
   -s /var/db/kumofs3.tch
 # netstat -na | grep 1980
 tcp4       0      0  *.19803                *.*                    LISTEN
 tcp4       0      0  *.19802                *.*                    LISTEN
 tcp4       0      0  *.19801                *.*                    LISTEN

gateway �̋N���͈ȉ��̒ʂ�B

 # /usr/local/bin/kumo-gateway -t 11211 -F \
   -m localhost -d /var/run/kumofs/gateway.pid -o /var/log/kumofs/gateway.log
 # netstat -na | grep 11211
 tcp4       0      0  *.11211                *.*                    LISTEN

���҂͑������̂ŁA��Ԃ����Ă݂�B

 # 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:19801
   127.0.0.1:19802
   127.0.0.1:19803

attach ����Ă���T�[�o�͈�‚��Ȃ����A manager ���� server ���R�{�Ƃ��F������Ă��āA �����͂܂� attach ����Ă��Ȃ� �c�Ƃ�����Ԃł��邱�Ƃ��킩��B

�T�[�o�Q�� manager �z���ɂ����‚���B

 # kumoctl localhost attach
 nil
 # kumoctl localhost status
 hash space timestamp:
   Sat May 01 11:07:28 +0900 2010 clock 513
 attached node:
   127.0.0.1:19801  (active)
   127.0.0.1:19802  (active)
   127.0.0.1:19803  (active)
 not attached node:

server ���R�{�Ƃ� manager �ɒlj����ꂽ���Ƃ��킩��B

kumotop �ʼnғ��󋵂����Ă݂�B

 # kumotop -m localhost
               address     #Get     #Set     #Del     items                time
                          Get/s    Set/s    Del/s       QPS               clock
       127.0.0.1:19801        0        0        0         0 2010-05-01 11:09:13
                              0        0        0         0                 569
       127.0.0.1:19802        0        0        0         0 2010-05-01 11:09:13
                              0        0        0         0                 568
       127.0.0.1:19803        0        0        0         0 2010-05-01 11:09:13
                              0        0        0         0                 569

���̃f�[�^�������Ă��Ȃ��܂�����ȏ�Ԃ����A ���Ȃ��Ƃ������Ă���悤���B

�ڑ����Ă݂�B

 % telnet localhost 11211
 version
 VERSION kumofs-0.3.4

�ԓ�������ꂽ�B���삵�Ă���悤���B

���� store ���Ă݂�B

 % telnet localhost 11211
 set hoge 0 0 8
 HOGEHOGE
 STORED

kumotop �Ō��Ă݂�ƁA

               address     #Get     #Set     #Del     items                time
                          Get/s    Set/s    Del/s       QPS               clock
       127.0.0.1:19801        0        0        0         1 2010-05-01 11:20:58
                              0        0        0         0                 921
       127.0.0.1:19802        0        0        0         1 2010-05-01 11:20:58
                              0        0        0         0                 922
       127.0.0.1:19803        0        1        0         1 2010-05-01 11:20:58
                              0        0        0         0                 922

1 ���� set ������Aitem �͕��U�ۊ�(���v���P�[�V����)����Ă���悤�Ɍ�����B

����� get ���Ă݂�B

 % telnet localhost 11211
 get hoge
 VALUE hoge 0 8
 HOGEHOGE
 END

�����A�l�����o�����B�����Ă݂�B

 % telnet localhost 11211
 delete hoge
 DELETED

kumotop �Ō��Ă݂�ƁA�����ɂ͏����Ȃ��悤���B

               address     #Get     #Set     #Del     items                time
                          Get/s    Set/s    Del/s       QPS               clock
       127.0.0.1:19801        0        0        0         1 2010-05-01 11:27:25
                              0        0        0         0                1116
       127.0.0.1:19802        0        0        0         1 2010-05-01 11:27:24
                              0        0        0         0                1116
       127.0.0.1:19803        1        1        1         1 2010-05-01 11:27:25
                              0        0        0         0                1117

�Z�p�����ɂ��� kumo-server �� -gX �I�v�V�����Ŏw�肳��鎞�Ԃ��o�߂���� ������炵���B�f�t�H���g�l�� 3600 �Ȃ̂Łc�A�ꎞ�Ԃ��B

���������̂����o���Ă݂�B

 % telnet localhost 11211
 get hoge
 END

(�l�������Ȃ��̂�) �m���ɖ����Ȃ��Ă���悤���B

�N���C�A���g����ڑ�

kumofs �Ɍq���ɂ� memcached �Ōq���΂悢�B 3P (Perl�APHP�APython)�ARuby�AJava �Ȃǂ̑����̃v���O���~���O����� memcached �𑀍삷�邱�Ƃ��ł���悤���B

���������Ə����Ȃ玩���ɂ� Java �������₷���̂ŁAJava �Ŏ������Ă݂�B ���ǂ��͂��������󋵂ł� LL ���g���ăT�N���Ƃ��̂����D�C�C�񂾂낤���ǁB ���āAJava �̏ꍇ�A�����̃N���C�A���g���C�u������p����̂��悢�B

�L���ǂ��낪�Q�‚���A2010.04 ���_�ł� Memcached for java ���D���̂悤���B

Memcached for Java ���g���ăA�N�Z�X���Ă݂�B����ȃR�[�h�ł悢�B

    // �ڑ�
    SockIOPool pool = SockIOPool.getInstance();
    pool.setServers(new String[]{"localhost:11211"});
    pool.initialize();

    // �N���C�A���g�̃C���X�^���X�𐶐�
    MemCachedClient mcc = new MemCachedClient();

    // set
    boolean result = mcc.set("a", "alpha");
    System.out.println(result);

    // get
    String value = (String) mcc.get("a");
    System.out.println(value);

���点��ƁA

 true
 alpha

�ƕԂ��Ă���Bset �ɐ������A�l�����o�������Ƃ��킩��B

MemcachedClinet#set �̑������ɂ� Object ���w��ł���B String �łȂ��Ƃ��ASerializable �Ȃ��̂Ȃ� set ���邱�Ƃ��ł���B

Memcached client for Java �̔z�z���ɂ� javadoc ���\�[�X�� �����Ɗ܂܂�Ă���̂ŁAAscIIClient �� set �̂Ƃ����ǂނƂ悢���낤�B AscIIClient �� s �� c �͏������Ȃ̂� I �� I ���啶���Ȃ͓̂䂾�B Ascii ���Ⴞ�߂Ȃ̂��ȁB

�̏�

server �����A�E���Ă݂�B

 # kill `cat /var/run/kumofs/server3.pid`
 # kumotop -m localhost

               address     #Get     #Set     #Del     items                time
                          Get/s    Set/s    Del/s       QPS               clock
       127.0.0.1:19801        0        0        0         2 2010-05-01 14:57:36
                              0        0        0         0                7424
       127.0.0.1:19802        0        0        0         2 2010-05-01 14:57:36
                              0        0        0         0                7424
       127.0.0.1:19803Connection refused - connect(2)

���̏�Ԃł��l�͎擾�ł���B

 % telnet localhost 11211
 get a
 VALUE a 32 5
 alpha
 END

�Ƃ����킯�ŁA�u�_�͗����܂���v�������ł����B

��~

�����I���Ƃ������ƂŁA�݂Ȏ~�߂�B

��~�̏��Ԃ�

  • kumofs-gateway
  • kumofs-server �� kumofs-manager (�� ���̓�‚͏��s���ł悢)

�ł���B

�蓮�ŋN�������̂ŁApid �t�@�C���𗊂�Ɏ蓮�Œ�~����΂悢�B

 # kill `cat /var/run/kumofs/gateway.pid`
 # kill `cat /var/run/kumofs/server2.pid`
 # kill `cat /var/run/kumofs/server1.pid`
 # kill `cat /var/run/kumofs/manager.pid`

�~�߂鎞�Ɠ����\���� manager �� server ���N������ attach ����ƁA ���������g����B

�Q�l�T�C�g

��������B

�L�����������A�������傫���B���ۂɓ������Ă݂āA���́u�ȒP���v�������ł����B �h�L�������g�����Ղȓ��{��Œ��J�ɏ�����Ă��邱�Ƃ��d�v�ȃ|�C���g���B ���Ƃ́uKVS �̓K�p�̈悪�ǂ��ł��邩�v�Ƃ������Ƃ�������Ɨ�����������΁A ����������퓊���ł��������B

[$Revision: 1.2 $ $Date: 2011.05.21 07:43:52 $]
[EOF]