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.
FAQ
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.