LoginSignup
0
2

More than 5 years have passed since last update.

Apache Cassandra 1.1.0 をインストールする

Posted at

[!NOTE]
この記事は 2012/05/12 に seijimomoto.blogspot.com/2012/05/apache-cassandra-110.html へ投稿した内容を Qiita へ移行してきたものです

 CentOS 6.2 に Apache Cassandra 1.1.0 の動作に必要なJavaからインストールしていきます。JDK は RPM で取得できる OpenJDK 1.6 を使用し、Cassandra は 2012/04/24 にリリースされた 1.1.0 を使用します。

インストール

-- yum で OpenJDK 1.6 をインストール
[root@localhost ~]# yum install java-1.6.0-openjdk

-- kddilabs.jp のミラーから tarball を取得し、展開
[root@localhost ~]# cd /usr/local/
[root@localhost local]# curl -o apache-cassandra.tar.gz http://ftp.kddilabs.jp/infosystems/apache/cassandra/1.1.0/apache-cassandra-1.1.0-bin.tar.gz
[root@localhost local]# tar zxf apache-cassandra.tar.gz

-- ログ記録とデータストレージに使用するディレクトリを作成
[root@localhost local]# mkdir -p /var/log/cassandra
[root@localhost local]# chown -R `whoami` /var/log/cassandra/
[root@localhost local]# mkdir -p /var/lib/cassandra
[root@localhost local]# chown -R `whoami` /var/lib/cassandra/

インストールは完了です。続いて、初期設定のまま単独ノードを動作させます。

起動

## Apache Cassandraルートへ移動
[root@localhost ~]# cd apache-cassandra-1.1.0/

## Cassandraサーバーを起動
[root@localhost apache-cassandra-1.1.0]# ./bin/cassandra

  ... Binding thrift service to localhost/127.0.0.1:9160
  ... Using TFastFramedTransport with a max frame size of 15728640 bytes.
  ... Using synchronous/threadpool thrift server on localhost/127.0.0.1 : 9160
  ... Listening for thrift clients...

## サーバーへ、CLIクライアントから接続
[root@localhost apache-cassandra-1.1.0]# ./bin/cassandra-cli --host localhost --port 9160

  Connected to: "Test Cluster" on localhost/9160
  Welcome to Cassandra CLI version 1.1.0

[default@unknown]

次に、Apache Cassandra に付属されているツールを試してみます。

nodetool

## ring       - 接続されているノードを表示
[root@localhost apache-cassandra-1.1.0]# ./bin/nodetool --host localhost ring
  Address         DC          Rack        Status State   Load            Effective-Owership
  127.0.0.1       datacenter1 rack1       Up     Normal  176.05 MB       100.00%           

## info       - ノードの情報 (uptime, load, ...)を表示
[root@localhost apache-cassandra-1.1.0]# ./bin/nodetool --host localhost info
  Gossip active    : true
  Load             : 176.05 MB
  Uptime (seconds) : 482
  Heap Memory (MB) : 27.62 / 494.00
  Data Center      : datacenter1
  Rack             : rack1
  Key Cache        : size 528 (bytes), capacity 25165824 (bytes), 7 hits, 15 requests, 0.467 recent hit rate, 14400 save period in seconds
  Row Cache        : size 0 (bytes), capacity 0 (bytes), 0 hits, 0 requests, NaN recent hit rate, 0 save period in seconds
  ...

## cfstats    - Column Familiesの統計(読み/書きの遅延時間など)を表示
[root@localhost apache-cassandra-1.1.0]# ./bin/nodetool --host localhost cfstats
  Keyspace: system
          Read Count: 20
          Read Latency: 5.5248 ms.
          Write Count: 9
          Write Latency: 34.248555555555555 ms.
  ...

## gossipinfo - gossipのクラスタ情報を表示
[root@localhost apache-cassandra-1.1.0]# ./bin/nodetool --host localhost gossipinfo
  localhost/127.0.0.1
    SCHEMA:c1b6f30b-9661-3b04-9e49-19e7749cdb94
    STATUS:NORMAL,18330859637070913548380228998384159149
    LOAD:1.84588421E8
    RPC_ADDRESS:127.0.0.1
    RELEASE_VERSION:1.1.0

他にも tpstats, compactionstats, netstats などがあります。

stress

## ストレステストツール
[root@localhost apache-cassandra-1.1.0]# ./tools/bin/stress

  SLF4J: Class path contains multiple SLF4J bindings.
  SLF4J: Found binding in [jar:file:/usr/local/apache-cassandra-1.1.0/tools/lib/stress.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: Found binding in [jar:file:/usr/local/apache-cassandra-1.1.0/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  Created keyspaces. Sleeping 1s for propagation.
  total,interval_op_rate,interval_key_rate,avg_latency,elapsed_time
  3747,374,374,0.0708716306378436,10
  9153,540,540,0.00666629670736219,20
  15801,664,664,0.004817238267148014,30
  ...

stressの実行中は、メモリがみるみる消費されていく。

[default@unknown] show keyspaces;
  Keyspace: Keyspace1:
    Column Families:
      ColumnFamily: Counter1
      ...
      ColumnFamily: Standard1
      ...
      ColumnFamily: Super1 (Super)
      ...
      ColumnFamily: SuperCounter1 (Super)
      ...
  ...

[default@unknown] use Keyspace1; 
  Authenticated to keyspace: Keyspace1

[default@Keyspace1] list Standard1;
  Using default limit of 100
  -------------------
  RowKey: 30303132343830
  => (column=C0, value=63666364323038343935643536356566363665376466663966393837363464616366, timestamp=1337715287568000)
  => (column=C1, value=63346361343233386130623932333832306463633530396136663735383439626334, timestamp=1337715287568000)
  => (column=C2, value=63383165373238643964346332663633366630363766383963633134383632636338, timestamp=1337715287568000)
  => (column=C3, value=65636362633837653462356365326665323833303866643966326137626166336563, timestamp=1337715287568000)
  => (column=C4, value=61383766663637396132663365373164393138316136376237353432313232636138, timestamp=1337715287568000)
  -------------------
  ...

ストレステストを実行すると「Keyspace1」と「Counter1」「Standard1」「Super1」「SuperCounter1」という 4 つの Column Family が作成されます。

動作確認の終了

## CLIクライアントから、stressで作成された「Keyspace1」を削除
[default@unknown] drop keyspace Keyspace1;
  59adb24e-f3cd-3e02-97f0-5b395827453f
  Waiting for schema agreement...
  ... schemas agree across the cluster

## 起動しているCassandraサーバーを停止
[root@localhost apache-cassandra-1.1.0]# pgrep -u `whoami` -f cassandra | xargs kill -9

apache-cassandra-1.1.0のディレクトリ構成

[root@localhost apache-cassandra-1.1.0]# ls -1X ./
bin       # シェルスクリプト、バッチファイル(cassandra、cassandra-cliなど)
conf      # 設定ファイル(cassandra.yaml、log4j-server.propertiesなど)
interface # Thrift定義ファイル(cassandra.thrift)
javadoc   # apache-cassandra APIドキュメント(*.html)
lib       # Cassandra Javaライブラリ(*.jar)
pylib     # Cassandra Pythonライブラリ(*.py)
tools     # 付属しているツール(bin/stress、bin/stressdなど)
CHANGES.txt
LICENSE.txt
NEWS.txt
NOTICE.txt
README.txt

参考

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2