11
6

More than 5 years have passed since last update.

ScyllaDBのスタンドアロンクラスタ―を構築してみる

Last updated at Posted at 2018-09-09

ScyllaDBとは

ScyllaDB(スキュラDB)とは、Apache CassandraをJAVAからC++でリプレースし、Cassandraより10倍以上高速であり、その速さを利用してノード数を1/5~1/10に圧縮できる異次元のデータベースです(スケールアップファーストのクラスター設計思想)。Cassandraとは互換性があり、開発ではCassandraのドライバ―やCQL、各種コネクター、CLIなどをそのまま利用できます。

scylladb2.png

ここでは、簡単にScyllaDBが体験できるスタンドアロンクラスタ―の構築手順をご紹介します。

ScyllaDBのスタンドアロンクラスタ―の構築

環境は、クラウド上のVM、手許のVirtualBox上のVMでも構いません。筆者の環境は、下記の通りです。

  • Windows10
  • Virtual Box 5.1.30 r118389 (Qt5.6.2)
  • vagrant Vagrant 2.0.1
  • ubuntu16.04

インストールパッケージの入手

次のサイトに接続し、インストールパッケージとOSを選択してください。筆者は、Ubuntu16.04を選択しています。簡単なプロフィールの登録が必要です。プロフィールを提出すると、Email宛にダウンロードのリンクが送られて来ます。
https://www.scylladb.com/download/#binary

scylladb-getstarted-1.png

Emailからダウロードのリンクに接続してください。
scylladb-download-1.png

レポジトリキーの登録

ScyllaDBのホームページの内容を参照しながら進めてください。

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6B2BFD3660EF3F5B
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 17723034C56D4B19

レポジトリファイルの登録(Scylla2.2)

ScyllaDBのホームページの内容を参照しながら進めてください。

$ sudo curl -o /etc/apt/sources.list.d/scylla.list -L http://repositories.scylladb.com/scylla/repo/7fbed5de4418ca82ad7eb64d66bedb2c/ubuntu/scylladb-2.2-xenial.list

パッケージのインストール

Scyllaのホームページの内容を参照しながら進めてください。

$ sudo apt-get update
$ sudo apt-get install scylla -y

ScyllaDBのファイル配置

ScyllaDBの各種ファイルは、次のように配置されます。

$ ls /etc/scylla
$ ls /var/lib/scylla
$ ls /lib/systemd/system/scylla-server.service

さらに詳しいことは、次のURLを参照してください。

ScyllaDBのセットアップ

ScyllaDBは、環境のチェックやパラメーターの最適化を行うユーティリティを提供しています。これは、とてもありがたい存在です。コマンドラインからscylla_setupと実行すると、環境構成に関する質問が表示され、yesと入力すると実行し、noと入力するとスキップします。

商用環境でもない限り、殆ど該当しないものばかりです。但し、下記の項目は、yesにしてください。noでスキップしてしまうと、scylla-serverが起動しません。これは、ストレージのIOPSを測って最適なパラメーターを/etc/scylla.d/io.confの中に設定してくれます。

Answer yes to let iotune study what are your disks IO profile and adapt Scylla to it. Answer no to skip this action.
[YES/no]yes

もし、うっかりnoと入力してしまった場合は、次のようして再設定できます。

$ sudo scylla_io_setup

では、scylla_setupを実行します。

$ sudo scylla_setup
Skip any of the following steps by answering 'no'
Do you want to run kernel version check?
Answer yes to have this script verify that the currently installed kernel is qualified to run Scylla; answer no to skip this check.
[YES/no]yes
This is a supported kernel version.
Do you want to verify ScyllaDB packages installed?
Answer yes to have this script check that ScyllaDB is already installed; answer no to skip this check.
[YES/no]yes
Do you want to enable ScyllaDB services?
Answer yes to automatically start Scylla when the node boots; answer no to skip this step.
[YES/no]no
scylla_selinux_setup only supports Red Hat variants
Do you want to setup NTP?
Answer yes to enable time synchronization at boot time. This keeps time right on the node. Answer no to do nothing.
[YES/no]no
Do you want to setup RAID and XFS?
It is recommended to use RAID0 and XFS for Scylla data. If you select yes, you will be prompt to choose which unmounted disks to use for Scylla data. Selected disks will be formatted in the process.
[YES/no]no
Do you want to setup coredump?
Answer yes to enable core dumps; this allows to do post-mortem analysis of Scylla state after a crash. Answer no to do nothing.
[YES/no]no
Do you want to setup sysconfig?
Answer yes to do system wide configuration customized for Scylla. Answer no to do nothing.
[YES/no]no
Do you want to setup IO configuration?
Answer yes to let iotune study what are your disks IO profile and adapt Scylla to it. Answer no to skip this action.
[YES/no]yes
Generating evaluation file sized 10GB...10GB written in 66 seconds
Refining search for maximum. So far, 13436 IOPS
Maximum throughput: 13436 IOPS
IOtune timed out before it could finish. An estimate will be provided but accuracy may suffer
Recommended --max-io-requests: 396
Written the above values to /etc/scylla.d/io.conf
Do you want to install node exporter and export Prometheus data from the node?
Answer yes to install it; answer no to skip this installation.
Do you want to install node exporter and export Prometheus data from the node?
Answer yes to install it; answer no to skip this installation.
[YES/no]no
Do you want to setup CPU scaling governor?
Answer yes to set CPU scaling governor to performance at boot time. Answer no to do nothing.
[YES/no]no
Do you want to enable fstrim service?
Answer yes to run fstrim on your SSD. Answer no to do nothing.
[YES/no]no
ScyllaDB setup finished.

/etc/scylla.d/io.confの内容が気になる方は、見てみましょう。
scylladbのデータ格納先(/var/lib/scylla/data)に対してIOPSを測定し、最適なmax-io-requests値を設定しています。

$ cat  /etc/scylla.d/io.conf
SEASTAR_IO="--max-io-requests=396

面倒くさいなあ~と思う方もいらっしゃるかも知れません。しかし、scylla_setupのパラメーター最適化の機能は有難い存在です。

ScyllaDBの起動

ScyllaDBを起動します。

$ sudo systemctl start scylla-server

$ sudo systemctl status scylla-server

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

nodetoolを実行してクラスタ―のステータスを確認してみます。Cassandraの経験者は、「え~、同じではないか」と思うかも知れません。実際に同じです。ScyllaDBは、CassandraをJavaからC++にリプレースしています。流用できるものは新たに開発もしてなければ、機能的に同じものをわざわざ名称を変えたりもしていません。

$ nodetool status
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns    Host ID                               Rack
UN  127.0.0.1  477.29 KB  256          ?       660e0b94-d481-43b1-8a5d-125d7b1ddc35  rack1

Note: Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless 

ScyllaDBへの接続

ScyllaDBは、CQL(Cassandra Query Language)が使えます。他にも、Cassandraへ接続できるドライバ―やAPI、サードパーティのコネクターなどは、すべて使えます。

$ cqlsh
Connected to  at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.0.8 | CQL spec 3.3.1 | Native protocol v4]
Use HELP for help.
cqlsh>
cqlsh> help

Documented shell commands:
===========================
CAPTURE  CLS          COPY  DESCRIBE  EXPAND  LOGIN   SERIAL  SOURCE   UNICODE
CLEAR    CONSISTENCY  DESC  EXIT      HELP    PAGING  SHOW    TRACING

CQL help topics:
================
AGGREGATES               CREATE_KEYSPACE           DROP_TRIGGER      TEXT
ALTER_KEYSPACE           CREATE_MATERIALIZED_VIEW  DROP_TYPE         TIME
ALTER_MATERIALIZED_VIEW  CREATE_ROLE               DROP_USER         TIMESTAMP
ALTER_TABLE              CREATE_TABLE              FUNCTIONS         TRUNCATE
ALTER_TYPE               CREATE_TRIGGER            GRANT             TYPES
ALTER_USER               CREATE_TYPE               INSERT            UPDATE
APPLY                    CREATE_USER               INSERT_JSON       USE
ASCII                    DATE                      INT               UUID
BATCH                    DELETE                    JSON
BEGIN                    DROP_AGGREGATE            KEYWORDS
BLOB                     DROP_COLUMNFAMILY         LIST_PERMISSIONS
BOOLEAN                  DROP_FUNCTION             LIST_ROLES
COUNTER                  DROP_INDEX                LIST_USERS
CREATE_AGGREGATE         DROP_KEYSPACE             PERMISSIONS
CREATE_COLUMNFAMILY      DROP_MATERIALIZED_VIEW    REVOKE
CREATE_FUNCTION          DROP_ROLE                 SELECT
CREATE_INDEX             DROP_TABLE                SELECT_JSON

cqlsh> exit;

さらに、CQLを試すなら、こちら参照してください。
http://cassandra.apache.org/doc/latest/cql/index.html

まとめ

ScyllaDBのスタンドアロンクラスタ―の構築は如何でしょうか。体感としては、Cassandraと殆ど差がありません。筆者は、クラスタ―の構築や運用においてノード数という悩みの種を一掃してくれるScyllaDBのスケールアップファーストのアーキテクチャーに注目しています。それは、別の場を借りてご紹介します。

11
6
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
11
6