Cassandra シングルノード構築

2017/12/12

Cassandra シングルノード構築

Cassandra3系のシングルノード構築について記述する。

About cassandra data structure architecture
About cassandra data flow architecture

Javaのインストール

CassandraはJavaで実装された製品なので、Javaのインストールは当然必要。
Java9では動かないようなので、8ですすめる。

1
$ sudo yum install -y java

Cassandraのセットアップ

Apache Cassandra

yum.repoの設定を行う。

1
2
3
4
5
6
[cassandra]
name=Apache Cassandra
baseurl=https://www.apache.org/dist/cassandra/redhat/311x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.apache.org/dist/cassandra/KEYS

Cassandraのインストール

インストールする。

1
$ sudo yum install -y cassandra

デーモンを再読み込みする。

1
$ sudo systemctl daemon-reload

Cassandraの設定

listen adressとrpc addressを設定する。
今回はシングルノードの構築なので、snitchはSimpleSnitchとする。

もし、Cassandraクラスタを構築する場合はGossipingPropertyFileSnitchにする必要がある。

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

# Apache cassadnra
$ sudo vim /etc/cassandra/default.conf/cassandra.yaml

< listen_address: 127.0.0.1
< rpc_address: 127.0.0.1
< endpoint_snitch: SimpleSnitch
<
< seed_provider:
< # Addresses of hosts that are deemed contact points.
< # Cassandra nodes use this list of hosts to find each other and learn
< # the topology of the ring. You must change this if you are running
< # multiple nodes!
< - class_name: org.apache.cassandra.locator.SimpleSeedProvider
< parameters:
< # seeds is actually a comma-delimited list of addresses.
< # Ex: "<ip1>,<ip2>,<ip3>"
< - seeds: "127.0.0.1"

---

> listen_address: {My IP address}
> rpc_address: {My IP address}
> endpoint_snitch: GossipingPropertyFileSnitch
>
> seed_provider:
> # Addresses of hosts that are deemed contact points.
> # Cassandra nodes use this list of hosts to find each other and learn
> # the topology of the ring. You must change this if you are running
> # multiple nodes!
> - class_name: org.apache.cassandra.locator.SimpleSeedProvider
> parameters:
> # seeds is actually a comma-delimited list of addresses.
> # Ex: "<ip1>,<ip2>,<ip3>"
> - seeds: "{Seed IP address}"

---

listen_address

デフォルトは、localhostとなっている。
CassandraがバインドするノードのIPアドレスまたはホスト名となる。
また、listen_interfaceと同じ意味である。

rpc_address

デフォルトは、localhostとなっている。
Cassandraが複数のノードへ接続する際に必要になる自分のIPアドレスである。
クラスタ構成になると、rpc_addressが設定されていないのclient接続ができない状態となる。

endpoint_snitch

デフォルトは、org.apache.cassandra.locator.SimpleSnitch。

  • SimpleSnitch

    • シングルデータセンターでのCassandra構築の場合に利用する。
  • GossipingPropertyFileSnitch

    • 本番環境ではこちらのSnitchを推奨。また、複数のデータセンターでのCassandra構築の場合ゴシップ通信をする必要があるため、こちらのSnitchにする必要がある。

その他の設定

DataStax about cassandra.yml document

DC・Rack設定

複数データセンターや複数のラックで構築する際には、該当するノードに定義することで設定できる。
今回はシングルノードのため、ラックは変更せずに、データセンター名だけを変える。

1
2
3
4
5
6
7
8
9
10
11
12
13
$ sudo vim /etc/cassandra/default.conf/cassandra-rackdc.properties

---

< dc=DC1
< rack=RAC1

---

< dc=cassandra01
< rack=RAC1

---

Cassandraの起動

起動する。

1
2
$ sudo systemctl start cassandra
$ sudo systemctl enable cassandra

Cassandraのステータスを確認

Nodeの起動状態を確認する。

1
2
3
4
5
6
7
8
$ nodetool status

Datacenter: cassandra01
=====================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN {IP address} 282.59 KiB 256 100.0% a1c9c548-1ed2-453d-aee3-927fb0ab8279 rack1

Status

UP or DOWN が返却される。

State

ノードの状態。

Address

ノードのIPアドレス。

Load

Snapshotの容量。
コンパクションによるデータ削除やTTLによるデータ削除等の値を確認できる。

Tokens

ノードの一意なトークン。

Owns

ノードのレプリケーション状態。

Host ID

ノードの一意なネットワークID。

Rack

Rack情報。

CQL

Cassandra Query Language DataStax document