Cassandra クラスタ構築

2017/12/13

Cassandraクラスタ構築

Cassandraクラスタ構築に関して記述する。
※ Cassandraのバージョンは3系である。

Cassandra データ構造
Cassandra データ処理
Cassandra シングルノード構築

クラスタ

シングルノードのCassandraを構築できていれば、クラスタの構築はそこまで手間ではない。



Cassandraの設定

listen addressとrpc addressの設定が必須となる。
また、GossipingPropertyFileSnitchでのsnitchとなる。
Seedとなるノードを決めて、そのNodeのIPアドレスを設定する。

全ノードで共通の設定は以下。

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
# 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}"

---

DataCenterとRackの設定

仮想Rackの設定。
すべてのノードを同じデータセンターとラックで設定する。
冗長化したい場合は、複数のデータセンターで構築したほうが良い。

今回は、1データセンターと1ラックでの構築とする。

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の起動

Cassandraをクラスタで起動するとき、Seedノードから起動する必要があり、SeedでないノードはSeedノードへのコンタクトで起動する。

Seedノードの起動。

1
$ sudo systemctl start cassandra

Seedでないノードの起動。

1
$ sudo systemctl start cassandra

Cassandraのステータス確認

Cassandraのクラスタステータスを確認する。

1
2
3
4
5
6
7
8
9
10
$ 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
UN {IP address} 200.59 KiB 256 100.0% lgojru90-9kxd-k0kj-dsds-09khb0rfrkic rack1
UN {IP address} 320.59 KiB 256 100.0% jgjigio0-0jdj-hyg6-nhft-mnhyr467sl08 rack1