Wednesday, January 22, 2014

Running Cassandra 2.x.x on Windows 7 and 8

This blog post describes how to get the Cassandra 2.x.x family running on a windows machine.  It's clear that Cassandra should not be run for production on Windows (except perhaps on Azure), but if you're a student learning to use C* it may well be you have no choice to run it on Windows 7 or 8 on your laptop.  Lets get started : 

Install JRE 7

Open a command prompt and type java -version to see if it is installed properly.  If not find a jre from oracle and install it.  Make sure it's a version 7 at the least (version 6 will not work).

You'll need to set JAVA_HOME. Find the control panel (on windows 8 search for it).  Go to "system and security" and then "system". Click on "Advanced Settings" and then the "Environment Variables" button. Click on the new button an in the Variable name box type JAVA_HOME
under the value you'll need to put in the path to the java you are using.  Mine is

c:\program files\java\jre7

but yours may be different, especially if you have a jdk.  If you are going to program java clients for C* you will need a JDK but that's a different post

 

Install Cassandra

Download Cassandra from http://cassandra.apache.org/ probably a file like
apache-cassandra-2.0.4-bin.tar.gz
You'll need to unpack this file and that will depend on which flavor of windows you have.  At this point I'll assume you have a legal copy of winzip or similar.  Unpack the downloaded file to the root of the c: or d: drive on your machine

You can now change to the Cassandra install directory in your command prompt, change to the bin directory to start Cassandra, type Cassandra to start it.  The window will print a lot of information but you are looking for a line like:

 INFO 19:00:31,031 Listening for thrift clients...

to make sure it's working.

CQLSH

So now we have C* running, we need to check we can connect to it.  Start by opening another command prompt and type cqlsh. Sadly it won't start, cqlsh now needs an installation of python, so lets get one installed. Download one from  http://www.python.org/  and go to downloads then "individual release". click on the 2.x stable release and then
scroll down to the download section.  Your looking for the Windows MSI installer.  I used:

http://www.python.org/ftp/python/2.7.6/python-2.7.6.msi

Download it and run it to install Python, you'll need a version 2 of python, NOTE THIS WELL, version 3 will not work! This installs a nice windows version of python but does not install
a path to the executable.  You'll need to set it by hand I guess.  Once again Find the control panel (on windows 8 search for it).  Go to "system and security" and then "system"
Click on "Advanced Settings" and then the "Environment Variables" button.  Under the system variables find PATH.  Highlight it and click edit.

Careful!  We don't want to wipe the current contents (if you do hit cancel) go to the end of the current path and enter

;c:\python27

Note the ; at the beginning.  Again this will depend on the current version of python you've installed and should mirror the path to your python installation. Click OK to close the
dialog boxes and open a command prompt again.

Now you should be able to change to the cassandra directory and then the bin directory and type cqlsh.  With luck you should get the
cassandra cqlsh prompt:

Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.0 | Cassandra 2.0.4 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Use HELP for help.
cqlsh>

type "use system;" followed by "describe  keyspaces;", cqlsh should reply:

system  system_traces

You're now connected and ready to start work.

BTW, folks at datastax and apache Cassandra, why is this so hard ?  Would Datastax Devcenter work easier ?

5 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Every people who wants to ,this blog done a great job by updating the useful information.
    Best Web Design

    ReplyDelete
  3. Will forward this to my Web Developer, this may help him a lot!!


    ReplyDelete
  4. thank for your helpful guide! I did it! :D

    ReplyDelete
  5. Nice post. I learn something new and challenging on your blogs thanks for sharing!!!!!!
    DAPPS Development Company

    ReplyDelete