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).
Join the DZone community and get the full member experience.
Join For FreeIt'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 thebin
directory. - Extract the Apache commons daemon distribution to a location of your choice.
- Copy the
prunsrv.exe
related to your architecture (32bit/64bit) to thedaemon
directory created inside thebin
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.
Published at DZone with permission of Dinuka Arseculeratne, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments