Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Running Cassandra as a Windows Service

DZone's Guide to

Running Cassandra as a Windows Service

This post will focus on the getting started aspect with regard to Cassandra and mainly in terms of Windows because—fortunately or unfortunately—that is the operating system I am stuck with at the moment (no pun intended).

Free Resource

Download the Guide to Open Source Database Selection: MySQL vs. MariaDB and see how the side-by-side comparison of must-have features will ease the journey. Brought to you in partnership with MariaDB.

It's been some time since my last post. Blogging has not been an option for the past few weeks with other commitments going on. But you cannot stop doing what you love the most. So here I am back again fervently nudging away on the keyboard. I was analyzing the use of Cassandra for one of the projects I am working on. This post will focus on the getting started aspect with regard to Cassandra and mainly in terms of Windows because—fortunately or unfortunately—that is the operating system I am stuck with at the moment (no pun intended).

The latest Cassandra distribution can be downloaded at here

I wanted to have the ability to run Cassandra as a Windows service. Here are the steps on how to get that done:

  • Download Apache commons daemon here.
  • Extract the Cassandra distribution to a location of your choice.
  • Go into the bin directory of the Cassandra distribution you just extracted.
  • Create a folder called daemon inside the bin directory.
  • Extract the Apache commons daemon distribution to a location of your choice.
  • Copy the prunsrv.exe related to your architecture (32bit/64bit) to the daemon directory created inside the bin directory in your Cassandra distribution extract.
  • Go into your bin directory via the command line and execute the following command:
cassandra.bat install

That’s it. Now you have Cassandra installed as a Windows service which you can set to start automatically if that is what you prefer.

By default, authentication and authorization is disabled on Cassandra. Enabling this is a breeze with the Cassandra YAML configuration file. Go to the conf directory of your Cassandra distribution where you will find a file named cassandra.yaml. Open up this with your favorite text editor (Notepad++ is awesome. Just saying). Make the following changes to the already existing configuration:

  • Authenticator: org.apache.cassandra.auth.PasswordAuthenticator
  • Authorizer: org.apache.cassandra.auth.CassandraAuthorizer

Now that you have enabled authentication and authorization, you can go in and login to Cassandra. The super user in Cassandra has the following credentials which you must use to log in:

  • User name: cassandra
  • Password: cassandra

To log in, let us go back to the bin directory of the Cassandra distribution where you will find a batch file called cqlsh. Bring up your command line again and execute the following command:

cqlsh -u cassandra -p cassandra

Now that you are in, if required you can go and change your super user password. One of the advantages of Cassandra for me is how similar the syntax is to relational databases. You can get up and running in a very short amount of time as the commands are very similar to traditional SQL. Cassandra has its own query language called CQL.

Next up, I was looking for a convenient GUI to interact with Cassandra. Browsing around, the most user-friendly interface I found was DBeaver which you can download from here.

On the next article, I will focus on functionality with respect to Cassandra and how your thinking pattern should change when working with Cassandra as it will not be the same as how you design a traditional database schema.



Interested in reducing database costs by moving from Oracle Enterprise to open source subscription?  Read the total cost of ownership (TCO) analysis. Brought to you in partnership with MariaDB.

Topics:
cassandra ,windows ,CQL

Published at DZone with permission of Dinuka Arseculeratne, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}