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.
How to install Cassandra DB on Windows?
We will discuss about ‘How to install Cassandra DB on Windows?’ 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 start Cassandra smoothly in our system. We will cover the whole 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, and follow the instructions given 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?
After learning ‘How to install Cassandra DB on Windows?’, now it’s time to verify that the installed Cassandra is working properly or not. Here are the steps:
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 mentioned above, 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 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.
This is all about ‘How to install Cassandra DB on Windows?’, and enough to make Cassandra setup ready in your system.
Are there any graphical tools available for managing Cassandra on Windows?
Yes, there are several third-party graphical tools like DataStax DevCenter and Apache Cassandra Query Language (CQL) for Windows that can help you interact with and manage Cassandra databases more easily.
Do I need Java installed to run Cassandra on Windows?
Yes, Cassandra is a Java-based application, and you need to have Java Development Kit (JDK) 8 or later installed on your Windows machine. Make sure to set the JAVA_HOME environment variable in ‘cassandra.bat’ file located at Cassandra’s bin folder (‘C:\apache-cassandra-3.11.12\bin’) appropriately.
Can I run multiple Cassandra nodes on a single Windows machine for testing or development?
Yes, you can run multiple Cassandra nodes on a single Windows machine by configuring different data directories, ports, and node names in the cassandra.yaml configuration file for each node. However, you should be careful of resource limitations.