Wednesday, February 4, 2015

Installing Cassandra on Windows

In this tutorial you will learn how to install cassandra database and Cqlsh on windows xp/vista/7/8. I face some problems when iam installing cassandra on my windows machine so i decided to share my experience and some important information to install cassandra. I think it will more usefull to those who want to install the cassandra database. Please follow the below steps carefully.



Step1: First download Cassandra from the official website [ http://cassandra.apache.org/download/ ]. The current version is 2.0.6. The downloaded file is in the form of tar.gz extension so extract it. I used winrar software to extract it. After that create a folder name as cassandra in C drive or any other drive then copy and paste the extracted files to that folder. For ex:- C:cassandra

Step2:Install the java software if you have already install the java then no need to install, simply open the command prompt type the java -version and check the version of java.

Note: If you are using cassandra 2.0.1 or above 2.0.1 version it is mandatory to use the java 1.7 or above. If you are using earlier version of cassandra java 1.6 is enough.

Step3: Set the path of java and cassandra in system variables. Simply go to computer properties and select the advanced system settings then click on the environment variables next click on system variables new button then give variable name and variable value.  
  
          For ex:- Java_Home= C:Program Files (x86)Javajdk1.7.0;
                        Cassandra_Home= C:cassandra;

Step4: Now go to cassandra directory and open the conf folder. Here you find the cassandra.yaml open and edit it as shown below. 

i) Find the line #commitlog_directory and change the default value of commitlog_directory.

          For ex:- commitlog_directory: C:/cassandra/commitlog

Note: The commitlog folder is created automatically when you start cassandra. It is used store the commit logs.

ii) Find the line #data_file_directories and change the default value of data_file_directories.

          For ex:- data_file_directories: - C:/cassandra/data

Note: The data folder is created automatically when you start cassandra. It is used store data. Some times the folders does not create automatically so you have to create manually if not it gives errors.

Start Cassandra Server

Directly go to bin folder and double click on the cassandra.bat file and looks like as shown below.



Installing cqlsh

The cqlsh is called as interactive command tool using this we can interact with Cassandra database. But here is a drawback the cqlsh not available along with cassandra software so you should download and configure it  separately.

Note: please download and install 2.7 version of Python because installing thrift library with current version 3.x has some issues.

1) Goto python official website [ http://www.python.org/download/releases/ ] and download the python and set the path in system variables as shown

variable name: PATH
variable value: C:Python27 

2) Before installing cql you should download the thrift library for that just copy and paste the below url in your browser [ https://pypi.python.org/pypi/thrift ] download and extract it after that to install the thrift library open the command prompt then type the path of thrift folder and give the command. For example  C: hrift-0.9.1> python setup.py install

3) Finally go to cassandrapylib folder and again run the  python setup.py install command in the cmd prompt. For example C:cassandrapylib> python setup.py install