DataStax Blog

Getting Started with Apache Cassandra on Windows the Easy Way

By Robin Schumacher -  January 31, 2012 | 10 Comments

By Robin Schumacher | January 31, 2012

Many architects and developers today are targeting Apache Cassandra as the underlying database because of its ability to easily scale and perform fast under extreme workloads. Developers like the fact that no modifications are required on their part if the application is initially written to just use one Cassandra node, but grows into hundreds in the future.

According to industry analysts such as Evans Data, Microsoft Windows remains the number one platform used by developers to write code and test their work (although Mac has recently been challenging that ranking). Many times developers need a complete environment to do their work, and this translates into having a full functioning copy of the database their application will target running on their Windows workstation or laptop.

For those wanting to develop against Apache Cassandra on Windows, this article will show you how to easily install, setup, and manage/monitor Apache Cassandra on a Windows machine.

Download the Software

The first step is to download the software you’ll need for your Windows machine. In the past, getting Apache Cassandra and all its utilities and management software on Windows wasn’t that easy, but that’s now a thing of the past since DataStax introduced its free Windows installer.

DataStax makes available the DataStax Community Edition, which contains the latest community version of Apache Cassandra, along with the Cassandra Query Language (CQL) utility, and a free edition of DataStax OpsCenter, which is the tool you’ll want to use for managing and monitoring your Cassandra cluster on Windows. To get Datastax Community Edition, go to the downloads page and select the Windows installation package for your version of Microsoft Windows. Note that 32 and 64-bit installers are offered.

Validate Prerequisites

The only prerequisites you’ll need for your Windows machine are:

  • Windows 7 or Windows 2008 server
  • Java
  • Either the Firefox or Chrome Web browser for DataStax OpsCenter (which doesn’t support Internet Explorer yet)
  • There is a dependency on the Visual C++ 2008 runtime (32bit), but Windows 7 and Windows 2008 Server R2 has it already installed. If you need it, see: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=29

Using the Windows Installer

The Windows installer is an MSI package that is run like any other on Windows. When you execute the setup program, you are first presented with an initial welcome panel that identifies your installation package:

dsc windows

Clicking next takes you to the end user license agreement (don’t worry, the software is free):

dsc windows

The next panel allows you to specify where the software is to be installed:

dsc windows

Once the installation directory has been set, the installer will ask how you want to handle the services that will be installed. Installed services include:

  • The Apache Cassandra server, labeled DataStax Cassandra Community Service
  • The DataStax OpsCenter management tool, which includes both the OpsCenter service used to manage and monitor Cassandra, and the OpsCenter agent, which is used to gather metrics and carry out various tasks on every Cassandra node. Note that the primary OpsCenter service and agent are actually broken out into two distinct services on Windows

dsc windows

The next panel initiates the installation process:

dsc windows

dsc windows

The final panel asks if you would like to launch DataStax OpsCenter in your browser and also register to be updated when new versions of the software become available:

dsc windows

If you choose to execute DataStax OpsCenter (and you have either Google Chrome or Firefox as your default web browser), you’ll be presented with the OpsCenter dashboard:

dsc windows

dsc windows

Finding and Using Installed Software

You can find a number of the most used interfaces you’ll need in a Windows program group that the installer creates for you:

dsc windows

The primary interface into Cassandra is the CQL (Cassandra Query Language) shell utility, which can be used to create a new keyspace (analogous to a database in the RDBMS world) for the new Cassandra server:

create keyspace hr with replication={'class':'SimpleStrategy', 'replication_factor':1};

Once a keyspace is created, you can create column families (the primary data object in Cassandra), insert data, query data, and more:

use hr;
create table emp
         ... (empid int primary key,
         ... emp_first varchar,
         ... emp_last varchar,
         ... emp_dept varchar);
insert into emp (empid, emp_first, emp_last, emp_dept)
         ... values (1, 'Fred', 'Smith', 'HR');
insert into emp (empid, emp_first, emp_last, emp_dept)
         ... values (2, 'Mary', 'Taylor', 'HR');
insert into emp (empid, emp_first, emp_last, emp_dept)
         ... values (3, 'Bob', 'Jackson', 'Eng');
select * from emp;

 empid | emp_dept | emp_first | emp_last
-------+----------+-----------+----------
     1 |       HR |      Fred |    Smith
     2 |       HR |      Mary |   Taylor
     3 |      Eng |       Bob |  Jackson

Typing, “Help;” at the CQL prompt will bring up the supported list of commands.

You can also use the Cassandra Command Line Interface (CLI) utility, which until the arrival of CQL was the primary interface used to create, manage, and query objects:

dsc windows

Another utility that’s used to perform various management tasks on Cassandra is the nodetool shell program. It’s not installed as a Windows program group item, and most of what it does can be visually performed through DataStax OpsCenter, but you can access it in the bin subdirectory that’s under the main installation directory:

dsc windows

Lastly, you can start, stop, and manage the various services installed via the standard Windows services control panel interface:

dsc windows

Conclusion

That’s all there is to it to get Apache Cassandra and the DataStax OpsCenter visual management and monitoring tool installed on your Windows machine. For other software such as application drivers, client libraries, and more visit the downloads page.



Comments

  1. animesh says:

    The below commend on CQL shell is throwing error :
    cqlsh> create keyspace hr
    … with strategy_class=’SimpleStrategy’ and
    … strategy_options:replication_factor=1;
    Bad Request: line 3:16 mismatched input ‘:’ expecting ‘=’

  2. These commands work on CQL shell:


    Connected to Test Cluster at localhost:9160.
    [cqlsh 3.0.2 | Cassandra 1.2.5 | CQL spec 3.0.0 | Thrift protocol 19.36.0]
    Use HELP for help.
    cqlsh> create keyspace hr
    ... with replication={'class':'SimpleStrategy', 'replication_factor':1};
    cqlsh> use hr;
    cqlsh:hr> create table emp
    ... (empid int primary key,
    ... emp_first varchar,
    ... emp_last varchar,
    ... emp_dept varchar);
    cqlsh:hr> insert into emp (empid, emp_first, emp_last, emp_dept)
    ... values (1, 'Fred', 'Smith', 'HR');
    cqlsh:hr> insert into emp (empid, emp_first, emp_last, emp_dept)
    ... values (2, 'Mary', 'Taylor', 'HR');
    cqlsh:hr> insert into emp (empid, emp_first, emp_last, emp_dept)
    ... values (3, 'Bob', 'Jackson', 'Eng');
    cqlsh:hr> select * from emp;

    empid | emp_dept | emp_first | emp_last
    -------+----------+-----------+----------
    1 | HR | Fred | Smith
    2 | HR | Mary | Taylor
    3 | Eng | Bob | Jackson

    cqlsh:hr>

  3. Sumod Pawgi says:

    I have two questions
    1. The command “nodetool -h localhost ring”, gives a scrolling output essentially of the same data except the token keeps changing. In your example you get only one line of output. E.g. my output looks like -
    Datacenter: datacenter1
    ==========
    Replicas: 0

    Address Rack Status State Load Owns Token

    127.0.0.1 rack1 Up Normal 55.66 KB 100.00% -92028
    08575681848283
    127.0.0.1 rack1 Up Normal 55.66 KB 100.00% -91865
    89383384670650
    127.0.0.1 rack1 Up Normal 55.66 KB 100.00% -90331
    87480047628915
    127.0.0.1 rack1 Up Normal 55.66 KB 100.00% -89768
    71628370795793
    127.0.0.1 rack1 Up Normal 55.66 KB 100.00% -89293
    77877052537319
    127.0.0.1 rack1 Up Normal 55.66 KB 100.00% -89068
    31965697341820
    127.0.0.1 rack1 Up Normal 55.66 KB 100.00% -88749

    2. When I make a query using the CLI interface, I do not get plain text responses, I get hexadecimal responses e.g.
    [default@unknown] connect localhost/9160;
    Connected to: “Test Cluster” on localhost/9160
    [default@unknown] use hr;
    Authenticated to keyspace: hr
    [default@hr] get emp[1];
    => (name=, value=, timestamp=1382954646348000)
    => (name=emp_dept, value=4852, timestamp=1382954646348000)
    => (name=emp_first, value=46726564, timestamp=1382954646348000)
    => (name=emp_last, value=536d697468, timestamp=1382954646348000)
    Returned 4 results.
    Elapsed time: 66 msec(s).

    I am using Ops Center 3.2.2, API version 19.37.0 and Cassandra version 2.x

  4. Robin Schumacher Robin Schumacher says:

    Please use Stackoverflow for tech questions on Cassandra, DataStax Enterprise, or OpsCenter.

    1. Meenakshi says:

      @animesh:

      try this will definetly run as you are running cql commands in windows platform

      CREATE KEYSPACE hr WITH replication={‘class’:'SimpleStrategy’ , ‘replication_factor’:1};

  5. Is there a fully managed version of Cassandra (i.e., C#) available or in development? C++/CLI, in my opinion, is far from optimal.

  6. Robin Schumacher Robin Schumacher says:

    If by C# you mean a driver, yes, we do have a certified C# driver for Cassandra on our downloads page. If you mean a fully WIN-optimized version of Cassandra that is certified for WIN, that is in development now and hopefully will be available soon.

  7. kriti sharma says:

    how can i use ‘nodetool’ command in windows7 using cql3? i m a beginner with cassandra so pls help,

  8. Robin Schumacher Robin Schumacher says:

    The nodetool utility is different from CQL and the CQL utility. The commands you use with nodetool are for administration purposes whereas CQL is a query language much like SQL is for RDBMS’s.

    Hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>