Apache Cassandra を複数ノー
ドで立ち上げる
株式会社ムロドー
とみたかずたか
全回アジェンダ
• cassandra を複数で立ち上げる
• コンシステンシーとは
• 複数ノードで異なる設定
• キースペース複数
• 巨大なデータを入れてみる
• ノードのスプリットブレイン
アジェンダ
• cassandra を複数で立ち上げる
▫ cassandra の設定
▫ cassandra の管理ツール
▫ node の新規追加
▫ node の削除
▫データの確認
▫ LVS 配下の複数 node の Cassandra で負荷分散
cassandra を複数で立ち上げる
• 複数ノード用の storage-conf.xml
<Storage>
<ClusterName>Intheforest Cluster</ClusterName> <AutoBootstrap>true</AutoBootstrap>
<Keyspaces>
<Keyspace Name="TimeStampSimpleTrees">
<ColumnFamily Name="SimpleTrees" CompareWith="BytesType" /> <ColumnFamily Name="SimpleTree-node"
ColumnType="Super" CompareWith="BytesType"
CompareSubcolumnsWith="BytesType" />
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStr ategy>
<ReplicationFactor>1</ReplicationFactor>
<EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
</Keyspace> </Keyspaces>
<Authenticator>org.apache.cassandra.auth.AllowAllAuthenticator</Authenticator> <Partitioner>org.apache.cassandra.dht.RandomPartitioner</Partitioner>
<InitialToken></InitialToken>
<CommitLogDirectory>/db/cassandra/commitlog</CommitLogDirectory> <DataFileDirectories>
<DataFileDirectory>/db/cassandra/data</DataFileDirectory> </DataFileDirectories>
<!-- 以下次ページ -->
ClusterName :
AutoBootstrap
:
クラスターの一意名
ここで指定した名称で同期対象か判断する。
ノード起動時のクラスター間の同期設定
(false/true )
ここが true になっていると起動時に同じク
ラスター名のクラスタからデータの同期を始
める。
※ 最初にクラスターを作成する際に全てのノード で true になっているとクラスターの作成ができな い。キースペースは任意
ReplicationFactor はとりあえず 1 のま
ま。 ※ デフォルトの Consistency Level
クエリにて変更可
ディレクトリは変更しています
がデフォルトで問題なし。
<Seeds>
<Seed>192.168.1.104</Seed> </Seeds>
<RpcTimeoutInMillis>10000</RpcTimeoutInMillis>
<CommitLogRotationThresholdInMB>128</CommitLogRotationThresholdInMB> <ListenAddress>psychodoga</ListenAddress>
<StoragePort>7000</StoragePort> <ControlPort>7001</ControlPort> <ThriftAddress>0.0.0.0</ThriftAddress> <ThriftPort>9160</ThriftPort>
<ThriftFramedTransport>false</ThriftFramedTransport> <DiskAccessMode>auto</DiskAccessMode>
<RowWarningThresholdInMB>512</RowWarningThresholdInMB> <SlicedBufferSizeInKB>64</SlicedBufferSizeInKB>
<FlushDataBufferSizeInMB>32</FlushDataBufferSizeInMB> <FlushIndexBufferSizeInMB>8</FlushIndexBufferSizeInMB> <ColumnIndexSizeInKB>64</ColumnIndexSizeInKB>
<MemtableThroughputInMB>64</MemtableThroughputInMB>
<BinaryMemtableThroughputInMB>256</BinaryMemtableThroughputInMB> <MemtableOperationsInMillions>0.3</MemtableOperationsInMillions> <MemtableFlushAfterMinutes>60</MemtableFlushAfterMinutes> <ConcurrentReads>8</ConcurrentReads>
<ConcurrentWrites>32</ConcurrentWrites> <CommitLogSync>periodic</CommitLogSync>
<CommitLogSyncPeriodInMS>10000</CommitLogSyncPeriodInMS> <GCGraceSeconds>864000</GCGraceSeconds>
</Storage>
Seeds : クラスターの検索先 IP
ここで指定した IP からで同期対象を確認す
る。
ListenAddress
:
ノード間のデータ通信用アドレス
ホスト名を指定するほうが正しいらし
い。 クラスターの場合、外部から接続でき
るインターフェース上にあること。
ThriftAddress : 外部から接続可能にするため「 0.0.0.0 」に変更
。
削除フラグを付けたデータを GC 可能にする機関
デフォルト 10 日間
cassandra の管理ツール
• Nodetool
• JMX
nodetool
• 機能いっぱい、表示内容読み方解り辛い
pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.107 ring
Address Status Load Range Ring 123664156429521535567280044549661800749 192.168.1.106 Up 18.84 MB 4368941974377008489670679703283346037 |<--| 192.168.1.6 Up 9.24 MB 53716703941129153059732412441632990819 | | 192.168.1.104 Up 3.44 MB 72360816833403413813516172818645147903 | | 192.168.1.107 Up 9.43 MB 123664156429521535567280044549661800749 |-->|
機能:
ring,info,cleanup,compact,cfstats,tpstats,flush,
repair,decommission,move,loadbalance,removetoken,
setcachecapacity,getcompactionthreshold,setcompacti
onthreshold, streams
ring:cassandra ノードリングを表示
pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.6 info 53716703941129153059732412441632990819
Load : 9.25 MB Generation No : 1270659807 Uptime (seconds) : 46053
Heap Memory (MB) : 107.23 / 989.88
info: 各ノードの状態表示
pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.107 ring
Address Status Load Range Ring
110785774623317105103012902995836871213 192.168.1.106 Up 28.24 MB
4368941974377008489670679703283346037 |<--| 192.168.1.6 Up 9.24 MB
53716703941129153059732412441632990819 | | 192.168.1.104 Up 3.44 MB
72360816833403413813516172818645147903 | | 192.168.1.107 Up 16.53 MB
110785774623317105103012902995836871213 |-->|
pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.107 decommission pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.107 ring
Address Status Load Range Ring
72360816833403413813516172818645147903 192.168.1.106 Up 18.97 MB
4368941974377008489670679703283346037 |<--| 192.168.1.6 Up 9.25 MB
53716703941129153059732412441632990819 | | 192.168.1.104 Up 3.46 MB
72360816833403413813516172818645147903 |-->|
decommission : ノードの削除
pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.106 cleanup pompadour@zaku2-F-2:~$
cleanup:remove データの削除 ( ガベージコレクト開始 )
pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.107 ring
Address Status Load Range Ring 123664156429521535567280044549661800749 192.168.1.106 Up 18.84 MB 4368941974377008489670679703283346037 |<--| 192.168.1.6 Up 9.24 MB 53716703941129153059732412441632990819 | | 192.168.1.104 Up 3.44 MB 72360816833403413813516172818645147903 | | 192.168.1.107 Up 9.43 MB 123664156429521535567280044549661800749 |-->|
pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.107 loadbalance TimeStampSimpleTrees SimpleTrees
pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.107 ring
Address Status Load Range Ring 110785774623317105103012902995836871213 192.168.1.106 Up 28.24 MB 4368941974377008489670679703283346037 |<--| 192.168.1.6 Up 9.24 MB 53716703941129153059732412441632990819 | | 192.168.1.104 Up 3.44 MB 72360816833403413813516172818645147903 | | 192.168.1.107 Up 16.53 MB 110785774623317105103012902995836871213 |-->|
loadbalance : データの再配置
JMX
• JAVA 基本 JVM 監視ツール
JDK に基本的についてくる便利な監視ツール。独自 Bean も追加で
きて二度美味しい。でもやっぱり見方が解らない。
ノード追加
• 設定をして cassandra デーモンを起動するだけ
AutoBootstrap を true にして立ち上げれば勝手に同期してくれま
す。
Nodetool の ring に表示されるようになったら使用 OK
pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.107 ring
Address Status Load Range Ring
110785774623317105103012902995836871213 192.168.1.106 Up 28.24 MB
4368941974377008489670679703283346037 |<--| 192.168.1.6 Up 9.24 MB
53716703941129153059732412441632990819 | | 192.168.1.104 Up 3.44 MB
72360816833403413813516172818645147903 | | 192.168.1.107 Up 16.53 MB
110785774623317105103012902995836871213 |-->|
ノード削除
• nodetool で対象 node を decommission
Decommission した後は煮るなり焼くなり好きにどうぞ。
※ 現在 decommission したノードを ring に復帰する方法が不明
。
pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.107 ringAddress Status Load Range Ring
110785774623317105103012902995836871213 192.168.1.106 Up 28.24 MB
4368941974377008489670679703283346037 |<--| 192.168.1.6 Up 9.24 MB
53716703941129153059732412441632990819 | | 192.168.1.104 Up 3.44 MB
72360816833403413813516172818645147903 | | 192.168.1.107 Up 16.53 MB
110785774623317105103012902995836871213 |-->|
pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.107 decommission pompadour@zaku2-F-2:~$ nodetool --host 192.168.1.107 ring
Address Status Load Range Ring
72360816833403413813516172818645147903 192.168.1.106 Up 18.97 MB
4368941974377008489670679703283346037 |<--| 192.168.1.6 Up 9.25 MB
53716703941129153059732412441632990819 | | 192.168.1.104 Up 3.46 MB
72360816833403413813516172818645147903 |-->|