尝试构建ScyllaDB的独立集群

ScyllaDB 是什么?

ScyllaDB(斯庫拉DB)是一个以C++替代Apache Cassandra的数据库,比Cassandra快了10倍以上。利用其快速性能,可以将节点数压缩到原来的1/5至1/10(以扩展优先的集群设计思想)。ScyllaDB与Cassandra兼容,在开发中可以直接使用Cassandra的驱动程序、CQL、各种连接器和CLI等。

scylladb2.png
    https://www.scylladb.com/open-source/

在这里,我们将介绍如何轻松构建一个能够体验ScyllaDB的独立集群。

构建ScyllaDB的独立集群。

环境可以是云上的虚拟机,也可以是本地的VirtualBox上的虚拟机。笔者的环境如下:

    • Windows10

 

    • Virtual Box 5.1.30 r118389 (Qt5.6.2)

 

    • vagrant Vagrant 2.0.1

 

    ubuntu16.04

获取安装包

请连接到以下网站,并选择安装包和操作系统。作者已选择Ubuntu16.04。注册一个简单的个人资料是必需的。提交个人资料后,将会通过电子邮件发送下载链接。
https://www.scylladb.com/download/#binary

scylladb-getstarted-1.png
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

注册库文件(Scylla 2.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”则跳过。

除非在商业环境中,否则几乎没有什么相关的东西。但是,请将下面的项目标记为“是”。如果跳过并选择“否”,Scylla服务器将无法启动。它会测量存储的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

If you accidentally entered “no” by mistake, you can reset it as follows. (如果您不小心误输入了”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查询语言)。除此之外,还可以使用能够连接到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的先扩展后升级的架构非常关注,它能够消除在集群搭建和运维中的节点数量烦恼。下面我们将在另一个地方介绍它。

广告
将在 10 秒后关闭
bannerAds