Saturday, June 11, 2011

Cassandra-Setup


       http://github.com/ericflo/twissandra                     
              
        
        
        basic one node cluster
        ======================

Requirements
------------
  * Java >= 1.6 (OpenJDK and Sun have been tested)


  * tar -zxvf apache-cassandra-$VERSION.tar.gz
  * cd apache-cassandra-$VERSION
  * sudo mkdir -p /var/log/cassandra
  * sudo chown -R `whoami` /var/log/cassandra
  * sudo mkdir -p /var/lib/cassandra
  * sudo chown -R `whoami` /var/lib/cassandra

Now that we're ready, let's start it up!

  * bin/cassandra -f


Now let's try to read and write some data using the command line client.

  * bin/cassandra-cli --host localhost --port 9160

To Create Tables
----------------

cassandra> set Keyspace1.Standard2['jsmith']['first'] = 'John'
  Value inserted.
  cassandra> set Keyspace1.Standard2['jsmith']['last'] = 'Smith'
  Value inserted.
  cassandra> set Keyspace1.Standard2['jsmith']['age'] = '42'
  Value inserted.
  cassandra> get Keyspace1.Standard2['jsmith']
    (column=age, value=42; timestamp=1249930062801)
    (column=first, value=John; timestamp=1249930053103)
    (column=last, value=Smith; timestamp=1249930058345)
  Returned 3 rows.
  cassandra>


                Configuring a Cassandra Cluster
                ===============================

Here is what I did to create a running Cassandra Cluster.

Stop individual Cassandra instances
Re-created data and log directories (I did this just to ensure a clean slate)
I added to my local hosts file two aliases for my servers (cass01 and cass02). This helped in the following step.
Three changes are needed to the default conf/storage-conf.xml file on my first server.
Change from localhost to cass01
Change from localhost to cass01
Change from 127.0.0.1 to cass01
On my second server I changed the and accordingly to cass02 and made cass01
Started Cassandra servers and tested successfully using the set …/get Keyspace1.Standard1['jsmith'] example. I was able to connect to both hosts via cassandra-cli and see the results created on just one node. I was able to create data on the second node and view on the first node.
A new command is available to describe your cluster.

$ bin/nodeprobe -host cass01 ring
Address       Status     Load          Range                                      Ring
                                       148029780173059661585165369000220362256
192.168.100.4 Up         0 bytes       59303445267720348277007645348152900920     |<--|
192.168.100.5 Up         0 bytes       148029780173059661585165369000220362256    |-->|
Now with my first introduction successful, time to start using and seeing the true power of using Cassandra.


Realtime Example
================

On nk114 [Master]
-----------------
vi  conf/storage-conf.xml

Test Cluster

      nk114
      nk75

nk114ListenAddress>

nk114ThriftAddress>


Steps to run
-------------
 bin/cassandra -f
 bin/cassandra-cli --host nk114 --port 9160

to check the cluster status
 ---------------------------
 bin/nodeprobe -host nk114 ring

On nk75 [Slave]
---------------
vi  conf/storage-conf.xml

Test Cluster

      nk75

nk75ListenAddress>

nk75ThriftAddress>


Steps to run
------------

 bin/cassandra -f
 bin/cassandra-cli --host nk114 --port 9160
                
 to check the cluster status
 ---------------------------
 bin/nodeprobe -host nk114 ring