Apache Cassandraを複数ノードで(その二)

| コメント(0) | トラックバック(0)

間が開いてしまいましたが引き続き複数ノードの話を書いていきたいと思います。
※この間、0.6はbetaからリリースにステータスが変わりました。
さっくり入れ替えてみましたが今のところ単純にバイナリ入れ替えで問題は出ていません。

cassandraを複数ノードで立ち上げる為、「storage-conf.xml」を以下の設定に変更しました。

簡単に解説をつけていきたいと思います。
複数ノード可に関連して変更した箇所は赤色で表示します。
青色はそれ以外の為の変更です。

<Storage>


<ClusterName>Intheforest Cluster</ClusterName> ----------------(1)
<AutoBootstrap>true</AutoBootstrap>----------------------------(2)


<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
</ReplicaPlacementStrategy>
<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>


<Seeds>
<Seed>192.168.1.104</Seed>-----------------------------(3)
<Seed>192.168.1.106</Seed>
<Seed>192.168.1.107</Seed>
</Seeds>


<RpcTimeoutInMillis>10000</RpcTimeoutInMillis>
<CommitLogRotationThresholdInMB>128</CommitLogRotationThresholdInMB>


<ListenAddress>node1</ListenAddress>-----------------------------(4)

<StoragePort>7000</StoragePort>


<ThriftAddress>0.0.0.0</ThriftAddress>-----------------------------(5)

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

 

(1):ClusterName:
クラスター識別用の名前。このクラスターネームが同じCassandraノードが存在した場合、対象ノードをクラスタの一員として認識します。同一ネットワークにあるクラスタ名が同じクラスタノード間でデータの共有を行います。

(2):AutoBootstrap:
起動時の同一クラスター内のデータ同期を行うかどうかの設定。trueに設定してあると起動時に自動的にデータの同期を開始します。トークンを指定していない場合はトークンもよしなにしてくれます。注)一番最初にクラスタを作成する際にすべてのノードのAutoBootstrapをtrueにしているとお互いにデータを取得しにいくのでノードが立ち上がりません。最初の一代目はマスターノードとしてfalseにするのが正しいようです。

(3):Seeds:
起動時に検索しに行くクラスターノードのIPアドレス。ringの形成には影響無いようです。複数指定可。

(4):ListenAddress:
外部とのやりとりを行うため外部から検索可能なIPに紐付けられている正引きできるホスト名。IPアドレスでも構わないのですがホスト名を指定する方が望ましいようです。デフォルトはループバックアドレスに紐付けられているlocalhost。今回は自分のホスト名を自分のアドレス「192.168.1.6」として「/etc/hosts」に書いて指定する方法を選択。正引きできればDNSでも可。

(5):ThriftAddress:
Thriftアプリケーションが外部から接続する際にその接続元を指定するアドレスを記述。デフォルトは自分自身以外からは受け付けない「localhost」。今回はどこからでも接続出来るように「0.0.0.0」を指定。

 

その他、データディレクトリとデータ構造は変更しています。このstorage-conf.xmlを用いて起動します。

起動環境は前回の手順を参照、複数ノードの起動手順としては次の通り

1.1ノード目の/etc/cassandra/storage-conf.xmlを書き換える。但し「AutoBootstrap」は「false」。

2.1ノード目を起動スクリプトで起動。

3.2ノード目の/etc/cassandra/storage-conf.xmlを書き換える。「AutoBootstrap」は「true」。

4.2ノード目を起動スクリプトで起動。

5.3ノード目の/etc/cassandra/storage-conf.xmlを書き換える。「AutoBootstrap」は「true」。

6.3 ノード目を起動スクリプトで起動。

7.4ノード目の/etc/cassandra/storage-conf.xmlを書き換える。「AutoBootstrap」は「true」。

8.4 ノード目を起動スクリプトで起動。

9.1ノード目のcassandraを停止。

10.1ノード目の「AutoBootstrap」を「true」に書き換える。

9.1 ノード目を起動スクリプトで起動。

これで無事同期が始まります。
しばらくすると下のようにリングが確認できるようになります。

$ nodetool --host 192.168.1.104 ring
Address Status Load Range Ring
123621947362397555094783433836216926846
192.168.1.106 Up 21.06 MB 4368941974377008489670679703283346037 |<--|
192.168.1.6 Up 10.33 MB 53716703941129153059732412441632990819 | |
192.168.1.104 Up 3.85 MB 72360816833403413813516172818645147903 | |
192.168.1.108 Up 10.54 MB 123621947362397555094783433836216926846 |-->|

トラックバック(0)

トラックバックURL: http://www.intheforest.jp/mtadmin/mt-tb.cgi/26

コメントする

ウェブページ