Friday, May 4, 2012

Key Value Store - install cassandra

I recently got an opportunity to monitor Key-Value Store, cassandra.  Though I know how to monitor RDBMS, such as MySQL or PostgreSQL, I know little about cassandra. I'm going to install cassandra and introduce of  monitoring cassandra with cassandra-cli. In addition, as I need to monitor cassandra multinode cluster, I'll show you about creating it and monitor it with nagios-plugins which I wrote.

Installation

  • install java(JDK)
    get the binary file here and transfer it.
# sh jdk-6u31-linux-x64-rpm.bin
  • install cassandra
# wget http://ftp.jaist.ac.jp/pub/apache//cassandra/1.0.8/apache-cassandra-1.0.8-bin.tar.gz
# tar -C /usr/local/ -zxf apache-cassandra-1.0.8-bin.tar.gz
# ln -s /usr/local/apache-cassandra-1.0.8 /usr/local/apache-cassandra
  • setup PATH
# vi /etc/profile
...
if [ "$EUID" = "0" ]; then
      pathmunge /usr/local/apache-cassandra/bin       : Add the directive
...
fi
# . /etc/profile

Verification

  • start up cassandra daemon behind
# cassandra
  • connect cassandra Using cassandra-cli
# cassandra-cli -h 127.0.0.1 -p 9160
Connected to: "Test Cluster" on 127.0.0.1/9160
Welcome to Cassandra CLI version 1.0.8

Type 'help;' or '?' for help.
Type 'quit;' or 'exit;' to quit.
[default@unknown]
  • verify open port
# netstat -lnpt | grep java
tcp        0      0 127.0.0.1:9160              0.0.0.0:*                   LISTEN      2124/java
tcp        0      0 0.0.0.0:34742               0.0.0.0:*                   LISTEN      2124/java
tcp        0      0 127.0.0.1:7000              0.0.0.0:*                   LISTEN      2124/java
tcp        0      0 0.0.0.0:47484               0.0.0.0:*                   LISTEN      2124/java
tcp        0      0 0.0.0.0:7199                0.0.0.0:*                   LISTEN      2124/java
  • Create keyspace
[default@unknown] create keyspace DEMO;
2bbaee00-7442-11e1-0000-242d50cf1fbc
Waiting for schema agreement...
... schemas agree across the cluster

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

[default@DEMO] create column family Users;
327382c0-7442-11e1-0000-242d50cf1fbc
Waiting for schema agreement...
... schemas agree across the cluster

[default@DEMO] set Users[utf8('1234')][utf8('name')] = utf8('scott');
Value inserted.
Elapsed time: 33 msec(s).

[default@DEMO] set Users[utf8('1234')][utf8('password')] = utf8('tiger');
Value inserted.
Elapsed time: 4 msec(s).

[default@DEMO] get Users[utf8('1234')];
=> (column=6e616d65, value=scott, timestamp=1332436350273000)
=> (column=70617373776f7264, value=tiger, timestamp=1332436354369000)
Returned 2 results.
Elapsed time: 36 msec(s).

[default@DEMO] assume Users keys as utf8;
Assumption for column family 'Users' added successfully.

[default@DEMO] assume Users comparator as utf8;
Assumption for column family 'Users' added successfully.

[default@DEMO] assume Users validator as utf8;
Assumption for column family 'Users' added successfully.

[default@DEMO] get Users['1234'];
=> (column=name, value=scott, timestamp=1332436350273000)
=> (column=password, value=tiger, timestamp=1332436354369000)
Returned 2 results.
Elapsed time: 2 msec(s).

 Let's create cassandra multinode cluster next time.

No comments:

Post a Comment