Tuesday, February 5, 2013

Apache Cassandra CQL in windows

How to run Apache Cassandra CQL in windows

Step 1: Install Apache Cassandra.

Step 2: Install Python.

Step 3: Add the Python executable path in the windows path variable, otherwise configure in the environment variable.
            Open command prompt :
            c:\> path =%path%;<python exe path>

Step 4: In the command prompt,navigate to cassandra\bin folder. (C:\cassandra\bin>)

Step 5: Execute the below command to start the CQL.
            python cqlsh localhost 9160.

Hope this helps someone.

Friday, February 1, 2013

Cassandra Authentication and Authorization

Cassandra Authentication and authorization

By default, authentication is not enabled in Cassandra and anybody can access Cassandra.

Cassandra has a simple authentication & authorization mechanism by extending the below java interfaces.


In the source distribution(not in binary distribution) IAuthenticator and IAuthority interfaces are implemented in the SimpleAuthenticator project and it can be easily configurable with Cassandra. 

If you want to have your own authentication and authorization implementation you’re freely allowed to do it by extending the below interfaces.


The below steps are used to enable authentication in Cassandra.

1)       Configure cassandra.yaml
2)       Configure access.properties
3)       Configure password.properties and
4)       Cassandra.bat file in bin directory.

Step 1: Configure Cassandra.yaml :
            Find org.apache.cassandra.auth.AllowAllAuthenticator and it should be replaced with

Find org.apache.cassandra.auth.AllowAllAuthorizer and it should be replaced with org.apache.cassandra.auth.SimpleAuthorizer
Step 2: Configure access.properties
            Configure the required user names,keyspace names, column family names with their                              permission level.           
            You can configure the authorization upto column family level in Cassandra.
            Configure keyspace permissions:
            murali.<rw>=admin,Cassandra # <rw> means read and write.
            Murali.<ro>=user1 #<ro> mean read only permission.
            By default all the users will have read permission for all the keyspaces. 

            Configure column family permissions:

Step 3: Configure password.properties 
            Add the required user and password in this file.
cassandra = cassandra 

Step 4: Modifying JAVA_OPTS in Cassandra.bat file.
            Add the below lines to the JAVA_OPTS.

Friday, January 11, 2013

Apache Cassandra : Starting with Command Line Interface

Starting with Apache Cassandra Command Line Interface

Command Line Interface (CLI) can be used to interact with Apache Cassandra server and execute the some execution that be done by using Client code.
Now, I’ll walk you thru some basic operations with Apache Cassandra Command Line Interface (CLI).

Step 1: Start the Apache Cassandra Server by running <Cassandra_home>\bin\Cassandra.bat file.

Step 2: Start the Command Line Interface from <Cassandra_home>\bin\cassandra-cli.bat

Step 3: Connect you Cassandra CLI with Cassandra Server.
Command: connect localhost/9160;

Step 4: Displaying existing Keyspaces.
Command : show keyspaces;
Description: It will display all the existing keyspaces in the connected Cassandra server.

Step 5: Creating new keyspace;
Command : Create keyspace <keyspacename>;
Ex: create keyspace MuraliKeySpace;

Step 6: Use existing keyspace;
Command : use <keyspacename>;
Ex: use MuraliKeySpace;
Once you connected to any keyspace, the default@unknown will be changed to
default@<KeySpaceName>. Now, it is changed to default@MuraliKeySpace.

Step 7: Creating column family.
Command: create column family <ColumnFamilyName>;
Ex: create column family users;

Saturday, January 5, 2013

Apache Cassandra on Windows 7

How to install Apache Cassandra on Windows 7 Systems

First download the Apache Cassandra from the following url.

      Make sure that you’ve JAVA installed in your machine. If not , please install it.

      Extract the tar.gz using 7-zip or any other application.

   Once it is extracted as apache-cassandra-1.2.0-bin.tar, extract it again using 7-zip.

   Extraction in progress….

   Once the extraction is completed, you will see the following folders.

   Now go to bin directory and execute the cassandra.bat file using command prompt. Always run the command window with Run As administrator mode.You’ll get the below screen if everything worked fine. Before running cassandra.bat, make sure you’ve JAVA_HOME variable is created.

    Open another command window. Execute the cassandra-cli.bat file. This is a Command Line Interface to interact with Cassandra. Once it is connected successfully with Cassandra server, you’ll get the below screen.

     To verify the connection, just execute describe cluster; command.

    Type exit; to come out from Cassandra cli console.

Friday, January 4, 2013

Apache Cassandra

What is Apache Cassandra?
               Apache Cassandra is an open source distributed database system is designed to store and manage huge amount of data across servers. It is highly scalable and consistent. Cassandra is a scalable NoSQL database. It can maintain structured, semi-structured and un-structured data with no single point of failure.
              Originally Cassandra created for Facebook. Cassandra consists of distributed system techniques from Amazon Dynamo and the data model from Google’s BigTable. Cassandra was open source in Feb 2008 by Facebook. Cassandra first started as an incubation project at Apache in January of 2009.  

Below are some of the basic concepts in Apache Cassandra:

Cluster: The machines in a logical Cassandra instance
Keyspace: A container for ColumnFamilies. In simple words, it is very similar to RDBMS database.
ColumnFamilies: Container for columns.
Column: It is a triplet which contains name, value and a timestamp.
SuperColumns: Can be thought as columns that themselves have subcolumns.

Cassandra download link: Cassandra is java based open source application. You can download Cassandra from the following location.

Cassandra Source code: You can download Cassandra source code from the following location.