Installing CassandraDB on ubuntu

CassandraDB is a powerfull Java based NoSQL Database, i'ts open source so we can download and installed, by default there are not cassandra packages at Unbuntu repositories, this post shows how to install Cassandra on your Ubuntu box.

Installed the jdk

Oracle java1.6 is required in order to cassandra work properly, you will have to install it by hand because Ubuntu default jdk is openjdk, more information about installed oracle jdk can be viewd at this post.

Adding and configuring the debian repository

  1. Edit /etc/apt/sources.list and add the cassandra repository deb http://debian.datastax.com/community stable main .
  2. Add datasax repository key to your trusted repo keys $ curl -L http://debian.datastax.com/debian/repo_key | sudo apt-key add -
  3. Update repo and install CassandraDB and drivers sudo apt-get update && sudo apt-get install python-cql=1.0.10-1 dsc=1.0.10 cassandra=1.0.10
  4. Cassandra will start by default after installition, to stop it sudo service cassandra stop

Upgrading to Cassandra last version

$sudo apt-get upgrade cassandra

Testing the connection

We can connect to cassandra usign cqlsh command:
    $ cqlsh 
    Connected to Test Cluster at localhost:9160.
    [cqlsh 2.0.0 | Cassandra 1.0.10 | CQL spec 2.0.0 | Thrift protocol 19.20.0]
    Use HELP for help.
    cqlsh> help

    Documented commands (type help ):
    ========================================
    ASSUME  DESC  DESCRIBE  EXIT  HELP  SELECT  SHOW  USE

    Miscellaneous help topics:
    ==========================
    DROP_INDEX                 CREATE                       DELETE_WHERE       
    ALTER_DROP                 DROP_KEYSPACE                UPDATE_USING       
    SELECT_EXPR                ALTER_ALTER                  UPDATE_WHERE       
    UUID_INPUT                 TYPES                        TIMESTAMP_OUTPUT   
    DELETE_COLUMNS             SELECT_COLUMNFAMILY          CONSISTENCYLEVEL   
    ALTER_ADD                  CREATE_COLUMNFAMILY_OPTIONS  CREATE_INDEX       
    ALTER_WITH                 BEGIN                        CREATE_KEYSPACE    
    APPLY                      UPDATE_SET                   ASCII_OUTPUT       
    DELETE_USING               UPDATE_COUNTERS              DROP               
    CREATE_COLUMNFAMILY_TYPES  TRUNCATE                     TIMESTAMP_INPUT    
    DROP_COLUMNFAMILY          INSERT                       ALTER              
    BLOB_INPUT                 TEXT_OUTPUT                  CREATE_COLUMNFAMILY
    SELECT_WHERE               UPDATE                       DELETE             
    BOOLEAN_INPUT              SELECT_LIMIT               

    cqlsh> SHOW 
    ASSUMPTIONS  HOST         VERSION      
    cqlsh> SHOW HOST 
    Connected to Test Cluster at localhost:9160.
    cqlsh> 

troubleshooting

  1. First time that i attempted start cassandra, did not work, the log messages said "the stack size specified is too small, Specify at least 160k" so i edited /etc/cassandra/cassandra-env.sh search the line JVM_OPTS and change the value for something over 160k, at my case i changed to 256 JVM_OPTS="$JVM_OPTS -Xss256k"