How to install Cassandra 0.8 on Windows

In this example we will install Apache Cassandra 0.8.1 on Windows 7.

What is Apache Cassandra?

Apache Cassandra is an open source, distributed, decentralized, elastically scalable, highly available, fault-tolerant, tuneably consistent, column-oriented database that bases its distribution design on Amazon’s Dynamo and its data model on Google’s Bigtable. Created at Facebook, it is now used at some of the most popular sites on the Web.

Installing Cassandra on Windows

Start by downloading the latest binaries from Apache Cassandra download page.

apache-cassandra-0.8.1-bin.tar.gz

Create this directory and then unzip the contents of the download into it

C:\cassandra

Then create these directories:

C:\cassandra\storage\commitlog
C:\cassandra\storage\data
C:\cassandra\storage\savedcaches

Now we need to edit this configuration file:

C:\cassandra\conf\cassandra.yaml

So that this section (around line 70) looks like this

# directories where Cassandra should store data on disk.
data_file_directories:
    - C:\cassandra\storage\data

# commit log
commitlog_directory: C:\cassandra\storage\commitlog

# saved caches
saved_caches_directory: C:\cassandra\storage\savedcaches

You need to make sure you have set the JAVA_HOME variable in Windows

Now you are ready to start Cassandra using this command

C:\cassandra\bin>cassandra -f

You should output similar to this

Starting Cassandra Server
 INFO 20:55:02,639 Logging initialized
 INFO 20:55:02,668 Heap size: 1070399488/1070399488
 INFO 20:55:02,670 JNA not found. Native methods will be disabled.
 INFO 20:55:02,690 Loading settings from file:/C:/cassandra/conf/cassandra.yaml
 INFO 20:55:02,893 DiskAccessMode 'auto' determined to be standard, indexAccessMode is standard
 INFO 20:55:03,144 Global memtable threshold is enabled at 340MB
 INFO 20:55:03,146 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,161 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,166 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,171 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,177 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,183 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,326 Opening C:\cassandra\storage\data\system\Schema-g-3
 INFO 20:55:03,362 Opening C:\cassandra\storage\data\system\Schema-g-2
 INFO 20:55:03,367 Opening C:\cassandra\storage\data\system\Schema-g-1
 INFO 20:55:03,393 Opening C:\cassandra\storage\data\system\Migrations-g-3
 INFO 20:55:03,399 Opening C:\cassandra\storage\data\system\Migrations-g-2
 INFO 20:55:03,404 Opening C:\cassandra\storage\data\system\Migrations-g-1
 INFO 20:55:03,423 Opening C:\cassandra\storage\data\system\LocationInfo-g-7
 INFO 20:55:03,427 Opening C:\cassandra\storage\data\system\LocationInfo-g-5
 INFO 20:55:03,431 Opening C:\cassandra\storage\data\system\LocationInfo-g-6
 INFO 20:55:03,518 Loading schema version 177dc9d0-a283-11e0-0000-242d50cf1fdf
 INFO 20:55:03,949 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,953 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,957 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,961 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,965 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,970 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,973 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:03,976 Removing compacted SSTable files (see http://wiki.apache.org/cassandra/MemtableSSTable)
 INFO 20:55:04,008 Creating new commitlog segment C:\cassandra\storage\commitlog\CommitLog-1309377304008.log
 INFO 20:55:04,027 Replaying C:\cassandra\storage\commitlog\CommitLog-1309373839356.log
 INFO 20:55:04,087 Finished reading C:\cassandra\storage\commitlog\CommitLog-1309373839356.log
 INFO 20:55:04,090 Log replay complete, 0 replayed mutations
 INFO 20:55:04,101 Cassandra version: 0.8.1
 INFO 20:55:04,102 Thrift API version: 19.10.0
 INFO 20:55:04,102 Loading persisted ring state
 INFO 20:55:04,103 Starting up server gossip
 INFO 20:55:04,128 Enqueuing flush of Memtable-LocationInfo@4239289(29/36 serialized/live bytes, 1 ops)
 INFO 20:55:04,129 Writing Memtable-LocationInfo@4239289(29/36 serialized/live bytes, 1 ops)
 INFO 20:55:04,181 Completed flushing C:\cassandra\storage\data\system\LocationInfo-g-8-Data.db (80 bytes)
 INFO 20:55:04,213 Starting Messaging Service on port 7000
 INFO 20:55:04,221 Compacting Major: [SSTableReader(path='C:\cassandra\storage\data\system\LocationInfo-g-6-Data.db'), SSTableReader(path='C:\cassandra\storage\data\system\LocationInfo-g-5-Data.db'), SSTableReader(path='C:\cassandra\storage\data\system\LocationInfo-g-8-Data.db'), SSTableReader(path='C:\cassandra\storage\data\system\LocationInfo-g-7-Data.db')]
 INFO 20:55:04,291 Using saved token 52141074183849440117505924565797785791
 INFO 20:55:04,293 Enqueuing flush of Memtable-LocationInfo@24223536(53/66 serialized/live bytes, 2 ops)
 INFO 20:55:04,294 Writing Memtable-LocationInfo@24223536(53/66 serialized/live bytes, 2 ops)
 INFO 20:55:04,294 Major@9300338(system, LocationInfo, 467/770) now compacting at 16777 bytes/ms.
 INFO 20:55:04,341 Completed flushing C:\cassandra\storage\data\system\LocationInfo-g-10-Data.db (163 bytes)
 INFO 20:55:04,350 Compacted to C:\cassandra\storage\data\system\LocationInfo-tmp-g-9-Data.db.  770 to 447 (~58% of original) bytes for 3 keys.  Time: 128ms.
 INFO 20:55:04,354 Will not load MX4J, mx4j-tools.jar is not in the classpath
 INFO 20:55:04,427 Binding thrift service to localhost/127.0.0.1:9160
 INFO 20:55:04,433 Using TFastFramedTransport with a max frame size of 15728640 bytes.
 INFO 20:55:04,439 Listening for thrift clients...

All seems to be working. Cassandra is listening on localhost port 9160

You will notice is says this on line 4

JNA not found. Native methods will be disabled.

This can to resolved by Installing Java JNA

Next lets connect to Cassandra. Open another command prompt and browse to

C:\cassandra\bin

And then enter

cassandra-cli.bat

You should get this output:

Starting Cassandra Client
Welcome to the Cassandra CLI.

Type 'help;' or '?' for help.
Type 'quit;' or 'exit;' to quit.

Next we will connect to a Cluster by typing

connect localhost/9160;

Or by typing

connect localhost/9160 jsmith 'havebadpass';

You should see

Connected to: "Test Cluster" on localhost/9160
[default@unknown]

Or this if you entered a username and password

Connected to: "Test Cluster" on localhost/9160
[jsmith@unknown]


Comments

  1. Daniel R July 16th

    Comment Arrow

    Nice post, it was hard to find a “How To” for 0.8. Also thanks for including the link on how to set the JAVA_HOME, I had issues with that.


  2. Madhu October 29th

    Comment Arrow

    It was very helpful. Thanks.
    Madhu


  3. Roy August 1st

    Comment Arrow

    Thanks.
    Very helpful!.


  4. viraj August 21st

    Comment Arrow

    very nicely documented


  5. Hyeongseok August 31st

    Comment Arrow

    Thank you very much for nice posting!! It really helped me out


  6. bhalchandra bhutkar September 3rd

    Comment Arrow

    Hey buddy , Thanks a Ton !!!


  7. Malang November 2nd

    Comment Arrow

    worked for me


  8. pramod October 5th

    Comment Arrow

    Thank you very much… was helpful


Add Yours

  • Author Avatar

    YOU


Comment Arrow




About Author

Robert

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning hands down.