Setting Up Cassandra
1. Introduction
Apache Cassandra is a highly scalable, distributed NoSQL database designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. In this tutorial, we will walk through the steps needed to set up Cassandra on your machine.
2. Prerequisites
Before setting up Cassandra, ensure you have the following prerequisites:
- Java Development Kit (JDK) installed (version 8 or higher)
- A compatible operating system (Linux, macOS, or Windows)
- Administrative access to the machine for installation
3. Installing Java
Cassandra requires Java to run. You can check if Java is installed by running the following command:
If Java is not installed, you can download it from the Oracle website or use a package manager like apt
or brew
to install it.
4. Downloading Cassandra
To download Cassandra, head to the official Apache Cassandra download page. Choose the version you want and download the binary tarball or zip file.
Example command to download Cassandra:
5. Extracting Cassandra
After downloading, you need to extract the files. Use the following command:
This will create a directory named apache-cassandra-3.11.10
.
6. Configuring Cassandra
Navigate to the Cassandra directory and open the cassandra.yaml
file for configuration. This file is located in the conf
directory.
You can modify settings like listen_address
, rpc_address
, and data_file_directories
as per your requirements.
7. Starting Cassandra
To start Cassandra, navigate back to the root of the extracted directory and run the following command:
Cassandra will start in the background. You can verify if it is running by checking the logs located in the logs
directory.
8. Verifying the Installation
Once Cassandra is running, you can use the cqlsh
command-line utility to connect to the Cassandra server and interact with it:
To verify the connection, type the following command after entering cqlsh
:
You should see the version of Cassandra running.
Output example:
release_version | 3.11.10
9. Stopping Cassandra
To stop Cassandra, you can either kill the process or use the following command in the cqlsh
shell:
10. Conclusion
Congratulations! You have successfully set up Apache Cassandra on your machine. You can now explore its capabilities to handle large volumes of data and build highly available applications.