In this article, we are going to learn ‘How to install Cassandra DB on Windows?’ in simple steps. The Installation process of Cassandra DB is a bit tricky as compared to other database software. Needless to mention, Cassandra is a NoSQL DB and it is known for high performance.
Table of Contents (Click on links below to navigate)
How to install Cassandra DB on Windows?
We will discuss the process of installing Cassandra in our local system here in this section. There are three mandatory software that we should have in our system in order to take complete benefit of the Cassandra DB. These are:
1) JDK 8+
2) Python 2.7+
3) Apache Cassandra 3+
Apart from that, we should have some special settings in order to stat Cassandra smoothly in our system. We will cover all process step by step.
How to install JDK?
If you are a Java developer, I am sure you must already have JDK installed in your system. You must have JDK 8 or higher version in your system to work with Cassandra. Even if not, you can go through the Oracle JDK download page to get it installed based on your system settings. The official document of Apache Cassandra says that, you should have JDK 8+ in your system. However, many developers tried it and suggested at many places on the web that it works only on JDK 8.
If you have set higher version than JDK 8 in your JAVA_HOME of environment variable settings, no worries. Let it be as it is. We will set JDK 8 specifically for Cassandra to run in later steps.
How to install Python?
In order to work with Apache Cassandra 3+, you should have Python 2.7+ installed in your system. The official document of Apache Cassandra says that, you should have Python 2.7+ in your system. However, many developers tried it and suggested in many places on the web that it works only on Python 2.7. Hence, for the safer side, we will install Python 2.7 only. Moreover, Python is required to run Cassandra Query shell(cqlsh) in your system.
Visit Python download page and click on the ‘Windows x86-64 MSI installer’ in case of 64 bit Operating system to download the same.
Double click on the downloaded MSI installer, follow the given instructions to install it.
How to install Cassandra?
In order to download & install Cassandra in your system, follow below steps:
Step#1: Access Apache Cassandra Download Page from your browser and download the latest stable version. Needless to say, we should always install the latest stable version rather than latest GA version in order to escape from any bug/issue. The latest stable version at this time is cassandra-3.11.12.
Step#2: Extract the downloaded file until you get the folder name as ‘apache-cassandra-3.11.12’. Keep the folder in any directory such as ‘C:\apache-cassandra-3.11.12’ in my case.
How to make Cassandra working in your system?
Step#1: Go to Environment variable section of your system and select the ‘Path’ System variables, then click on ‘Edit’. Now, add one new entry as ‘C:\apache-cassandra-3.11.12\bin’.
Step#2: As aforementioned, we are assuming that the installed version of Cassandra will work on JDK 8 only. Instead of changing JDK version in environment variable, let’s change the configuration in Cassandra itself. If you change JDK version in environment variable just to run Cassandra, it may impact all software that are using JDK like your eclipse IDE etc.
Go to bin folder(‘C:\apache-cassandra-3.11.12\bin’) of Cassandra, you will find ‘cassandra.bat’ file. Open it with the help of any text editor. In ‘cassandra.bat’ file, after the text ‘set UNINSTALL=”UNINSTALL”‘ add a line in order to set the JAVA_HOME as shown below which is pointing to JDK 8. For example, in my case it is ‘jdk1.8.0_251’. At the end, don’t forget to save the file.
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_251
Step#3: At the same bin folder(‘C:\apache-cassandra-3.11.12\bin’), open a file named ‘nodetool.bat’. Now, add the same line (set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_251) at the top of the file after the comments and save it.
Step#4: Open a command prompt(‘cmd’) window and navigate to the bin directory(‘C:\apache-cassandra-3.11.12\bin’). Now type cassandra to run it. Now observe the message ‘Starting Cassandra Server’ at the start or ‘startup complete’ at the bottom lines.
While running Cassandra, you may face a warning ‘Powershell script execution unavailable’. Refer below section in order to resolve this warning and run Cassandra with fully featured functionalities.
How to enable unrestricted Powershell execution Policy?
In order to run Cassandra with fully featured functionalities, we need to unrestrict Powershell execution policy. It will look like below on running Cassandra.
Let’s follow the below steps:
Step#1: In Windows search bar, type powershell, then select ‘Windows Powershell’ and run as administrator. You will come to the location ‘C:\WINDOWS\system32’.
Step#2: Type command : Set-ExecutionPolicy Unrestricted
Step#3: Now, to check the effect of changes, type command: Get-ExecutionPolicy -List
You will see the Local Machine is Unrestricted now as shown below.