/Introduction to Cassandra

Introduction to Cassandra

Welcome back ! to NoSQL DB  most of Software engineers know what is MongoDB – CouchDB
What is Cassandra ?
Cassandra is Apache project working in large platforms such as facebook
you can download it from here
1- Edit Configuration file from here
conf/cassandra.yaml
The distribution’s sample configuration conf/cassandra.yaml contains reasonable defaults for single node operation, but you will need to make sure that the paths exist fordata_file_directoriescommitlog_directory, and saved_caches_directory.

Verify storage_port and rpc_port are not conflict with other service on your computer. By default, Cassandra uses 7000 for storage_port, and 9160 for rpc_port. The storage_port must be identical between Cassandra nodes in a cluster. Cassandra client applications will use rpc_port to connect to Cassandra.
It will be a good idea to change cluster_name to avoid unnecessary conflict with existing clusters.
initial_token. You can leave it blank, but I recommend you to set it to 0 if you are configuring your first node.

 2- Edit log4j-server.properties
# Edit the next line to point to your logs directory
log4j.appender.R.File=/var/log/cassandra/system.log

 3- Edit cassandra-env.sh
Cassandra has JMX (Java Management Extensions) interface, and the JMX_PORT is defined in conf/cassandra-env.sh. Edit following line if you need.

# Specifies the default port over which Cassandra will be available for
# JMX connections.
JMX_PORT="7199"
By default, Cassandra will allocate memory based on physical memory your system has. For example it will allocate 1GB heap on 2GB system, and 2GB heap on 8GB system. If you want to specify Cassandra heap size, remove leading pound sign(#) on the following lines and specify memory size for them.

#MAX_HEAP_SIZE="4G"
#HEAP_NEWSIZE="800M"
If you are not familiar with Java GC, 1/4 of MAX_HEAP_SIZE may be a good start point for HEAP_NEWSIZE.
Cassandra will need more than few GB heap for production use, but you can run it with smaller footprint for test drive. If you want to assign 128MB as max, edit the lines as following.

MAX_HEAP_SIZE="128M"
HEAP_NEWSIZE="32M"
 Start up cassandra
And now for the moment of truth, start up Cassandra by invoking bin/cassandra -f from the command line1. The service should start in the foreground and log gratuitously to standard-out. Assuming you don’t see messages with scary words like “error”, or “fatal”, or anything that looks like a Java stack trace, then chances are you’ve succeeded.
Press “Control-C” to stop Cassandra.
If you start up Cassandra without “-f” option, it will run in background, so you need to kill the process to stop.

 
bin/cassandra-cli is a interactive command line interface for Cassandra. You can define schema, store and fetch data with the tool. Run following command to connect to your Cassandra instance.

bin/cassandra-cli -h host -p rpc_port
example:
% bin/cassandra-cli -h 127.0.0.1 -p 9160

 

Product Development @ Asknative - interested in Open Source Technologies and applications performance , social networks