LoginSignup
50
50

More than 5 years have passed since last update.

既存のNoSQL型データベースより10倍高速をうたう「Aerospike」をAWS上に構築してみた

Posted at

はじめに

既存のNoSQL型データベースより10倍高速をうたう「Aerospike」、オープンソースで公開

Couchbase serverに惚れ込んでガッツリと使い込んできた僕としては、もちろんこの製品を意識しないわけがありません。
以前までは、有償ライセンスもしくは体験版ライセンスが必要だったAerospikeですが、この度サーバがGNU AGPLとして公開された事を機にAWS EC2(VPC)上にクラスタを構築してみる事にしました。
今回公開されたのは、AerospikeのCommunity Edition(CE)版バージョン3.3.5。


準備

とりあえず、対応するディストーションを準備しましょう、Debianやubuntu大好き人間なので、今回はubuntu 14.04 server PVを準備しました。

  • Redhat 6
  • Ubuntu 12.04+
  • Debian 6
  • Debian 7
  • Linux

ダウンロード

いつもの様にVPCの上にEC2を起動したら、sshでログインしましょう。
ログインしたら、とりあえずサイトからダウンロードしちゃってください。

Serverダウンロード先サイト

Aerospike Management Console CE ダウンロード先サイト

ダウンロードできたら、サクっとdpkgでインストールです。serverとtoolsどちらも入れてしまいましょう。

# tar zxvf aerospike-server-community-3.3.5-ubuntu12.04.tgz
aerospike-server-community-3.3.5-ubuntu12.04/
aerospike-server-community-3.3.5-ubuntu12.04/license.txt
aerospike-server-community-3.3.5-ubuntu12.04/aerospike-tools-3.2.13.ubuntu12.04.x86_64.deb
aerospike-server-community-3.3.5-ubuntu12.04/aerospike-server-community-3.3.5.ubuntu12.04.x86_64.deb
# cd aerospike-server-community-3.3.5-ubuntu12.04

# dpkg -i aerospike-server-community-3.3.5.ubuntu12.04.x86_64.deb
Selecting previously unselected package aerospike-server-community.
(Reading database ... 51050 files and directories currently installed.)
Preparing to unpack aerospike-server-community-3.3.5.ubuntu12.04.x86_64.deb ...
Unpacking aerospike-server-community (3.3.5-1) ...
Setting up aerospike-server-community (3.3.5-1) ...
Processing triggers for ureadahead (0.100.0-16) ...
# dpkg -i aerospike-tools-3.2.13.ubuntu12.04.x86_64.deb
Selecting previously unselected package aerospike-tools.
(Reading database ... 51101 files and directories currently installed.)
Preparing to unpack aerospike-tools-3.2.13.ubuntu12.04.x86_64.deb ...
Unpacking aerospike-tools (3.2.13) ...
Setting up aerospike-tools (3.2.13) ...
Installing /opt/aerospike
Writing /usr/local/lib/python2.7/dist-packages/aerospike.pth
Adding python path /opt/aerospike/lib/python
#

管理コンソールも忘れずに・・・依存関係から以下のパッケージが必要でした。

apt-get install gcc python-dev

依存関係のパッケージインストールが終わったら、管理コンソールも入れちゃいましょう。

# dpkg -i aerospike-amc-community-3.4.3.all.x86_64.deb
(Reading database ... 54955 files and directories currently installed.)
Preparing to unpack aerospike-amc-community-3.4.3.all.x86_64.deb ...
Successfully Uninstalled AMC
Unpacking aerospike-amc-community (3.4.3) over (3.4.3) ...
Setting up aerospike-amc-community (3.4.3) ...
amc/
amc/amc/
amc/amc/bin/
amc/amc/bin/amc_rpm.sh
....
amc/amc/config/
amc/amc/config/amc.cfg
amc/amc/config/gunicorn_config.py
amc/README
amc/install
/tmp/tmpgH2dhe/simple.c:1:6: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
 void foo(){}
      ^
Linking /opt/amc/server/setups/greenlet/greenlet-0.4.1/build/lib.linux-x86_64-2.7/greenlet.so to /opt/amc/server/setups/greenlet/greenlet-0.4.1/greenlet.so
Successfully installed AMC.
#

なんか、エラー出ているけど・・・気になりますが、管理コンソールなのであとから考える事にしました。

設定

/etc/aerospike.confは以下の様な感じで設定、本来Aerospikeはマルチキャストで起動したノードを自動検出し、ハートビートのやりとりを行います。
VPC上ではマルチキャスト通らないので、デフォルトのコンフィグを元に、mesh通信にして、初期起動したNode1とのハートビートの設定を行います。
この辺りはCircularとか、メッシュ構成をもう少し何か方法考えたい所ですが、後回しにします。

root@node1:/etc/aerospike# cat aerospike.conf
# Aerospike database configuration file.

# This stanza must come first.
service {
    user root
    group root
    paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.
    pidfile /var/run/aerospike/asd.pid
    service-threads 4
    transaction-queues 4
    transaction-threads-per-queue 4
    proto-fd-max 15000
}

logging {
    # Log file must be an absolute path.
    file /var/log/aerospike/aerospike.log {
        context any info
    }
}

network {
    service {
        address any
        port 3000
    }

    heartbeat {
#       mode multicast
#       address 239.1.99.222
#       port 9918

        # To use unicast-mesh heartbeats, comment out the 3 lines above and
        # use the following 4 lines instead.
        mode mesh
        port 3002
        mesh-address 一番最初に起動するノードのIP
        mesh-port 3002

        interval 150
        timeout 10
    }

    fabric {
        port 3001
    }

    info {
        port 3003
    }
}

namespace test {
    replication-factor 2
    memory-size 4G
    default-ttl 30d # 30 days, use 0 to never expire/evict.

    storage-engine memory
}

#namespace bar {
#   replication-factor 2
#   memory-size 4G
#   default-ttl 30d # 30 days, use 0 to never expire/evict.

#   storage-engine memory

    # To use file storage backing, comment out the line above and use the
    # following lines instead.
#   storage-engine device {
#       file /opt/aerospike/data/bar.dat
#       filesize 16G
#       data-in-memory true # Store data in memory in addition to file.
#   }
#}

Node1の試験起動

初回起動時にはカーネルパラメーターを調整するみたいですね。

# /etc/init.d/aerospike start
 * Start aerospike:  asd
kernel.shmall too low, setting to 4G pages
kernel.shmall = 4294967296
kernel.shmmax too low, setting to 1GB
kernel.shmmax = 1073741824
[ OK ]

rc.dへの登録

うまく起動できたら、自動起動するようにしましょう、各ディストロに合わせて、適宜行ってください。

# update-rc.d aerospike defaults
update-rc.d: warning: /etc/init.d/aerospike missing LSB keyword 'default-stop'

 Adding system startup for /etc/init.d/aerospike ...
   /etc/rc0.d/K20aerospike -> ../init.d/aerospike
   /etc/rc1.d/K20aerospike -> ../init.d/aerospike
   /etc/rc6.d/K20aerospike -> ../init.d/aerospike
   /etc/rc2.d/S20aerospike -> ../init.d/aerospike
   /etc/rc3.d/S20aerospike -> ../init.d/aerospike
   /etc/rc4.d/S20aerospike -> ../init.d/aerospike
   /etc/rc5.d/S20aerospike -> ../init.d/aerospike

Security Groupsの調整

コンフィグで使っているポートはサブネットの中で相互に通信できるように許可しておきましょう。今回は以下のポートをオープンしました。

  • TCP 3000
  • TCP 3001
  • TCP 3002
  • TCP 3003

Node2以降の起動

Node2以降の起動は楽なものです、以下の手順での作業になります。

  1. スナップショットを取る
  2. とったスナップショットイメージからの起動を台数分繰り返す

クラスタステータスの確認

各インスタンスの起動が終わったら、ちゃんとジョインしているか動作の確認をしてみましょう。
いずれかのNodeから、以下のコマンドでステータスを確認します。

root@ip-192-168-200-21:/etc/aerospike# asmonitor -e info

Enter help for help

4 hosts in cluster: 192.168.200.21:3000,192.168.200.7:3000,192.168.200.8:3000,192.168.200.9:3000
===NODES===
2014-06-26 13:30:27.204616
Sorting by IP, in Ascending order:
ip:port           Build   Cluster      Cluster   Free   Free   Migrates              Node         Principal   Replicated    Sys
                      .      Size   Visibility   Disk    Mem          .                ID                ID      Objects   Free
                      .         .            .    pct    pct          .                 .                 .            .    Mem
192.168.200.21    3.3.5         4         true      0    100      (0,0)   BB9214F0B829406   BB9E706DC091A06      0.000 M     97
192.168.200.7     3.3.5         4         true      0    100      (0,0)   BB99952456C0B06   BB9E706DC091A06      0.000 M     97
192.168.200.8     3.3.5         4         true      0    100      (0,0)   BB9D9E98DAE9706   BB9E706DC091A06      0.000 M     97
192.168.200.9     3.3.5         4         true      0    100      (0,0)   BB9E706DC091A06   BB9E706DC091A06      0.000 M     97
Number of nodes displayed: 4


 ===NAMESPACE===
Total (unique) objects in cluster for test : 0.000 M
Note: Total (unique) objects is an under estimate if migrations are in progress.


ip/namespace           Avail   Evicted   Objects     Repl     Stop   Used   Used     Used   Used    hwm   hwm
                         Pct   Objects         .   Factor   Writes   Disk   Disk      Mem    Mem   Disk   Mem
                           .         .         .        .        .      .      %        .      %      .     .
192.168.200.7/test       n/a         0   0.000 M        2    false    n/a    n/a   0.00 B      0     50    60
192.168.200.8/test       n/a         0   0.000 M        2    false    n/a    n/a   0.00 B      0     50    60
192.168.200.21/test      n/a         0   0.000 M        2    false    n/a    n/a   0.00 B      0     50    60
192.168.200.9/test       n/a         0   0.000 M        2    false    n/a    n/a   0.00 B      0     50    60
Number of rows displayed: 4
root@ip-192-168-200-21:/etc/aerospike#

終わりに

ひとまずガーッと構築だけしちゃったので、次はマネジメントコンソールと実際のパフォーマンステストを行ってみたいと思います。

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