安装 Apache Cassandra 1.1.0

[!注意]
此文章乃2012/05/12投稿于seijimomoto.blogspot.com/2012/05/apache-cassandra-110.html,现移至Qiita的内容。

我们将使用在 CentOS 6.2 上安装 Apache Cassandra 1.1.0 所需的 Java。我们将使用可以通过RPM获取的 OpenJDK 1.6 来安装 JDK,而 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之外,还有其他选项,如。。。

压力

## ストレステストツール
[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
  ...

在运行压力测试期间,内存被迅速消耗。

[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)
  -------------------
  ...

执行压力测试将创建4个列族,分别为”Keyspace1″、”Counter1″、”Standard1″和”Super1″、”SuperCounter1″。

确认动作的结束

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

请你提供一种方案。

    Apache Cassandra プロジェクト
广告
将在 10 秒后关闭
bannerAds