Apache Cassandra is a free and open-source NoSQL database system which includes high availability and non-compromising performance. It is using by many large companies like Github, NetFlix, Reddit and Instagram. In this tutorial we will show you how to install Apache Cassandra on Ubuntu 22.04.
- Make sure you are login in as root or user with sudo privileges.
Perform the following steps to install Apache Cassandra on Ubuntu 22.04 system:
Step 1 – Installing Java
It’s required to have Java installed on your system before installing Apache Cassandra. So first we will install OpenJDK by running following command. You can skip this step if your system already Java installed.
sudo apt update
sudo apt install default-jdk -y
Once the process completed, verify the Java installation by typing:
The output should look something like this:
openjdk version "11.0.17"
Step 2 – Import GPG Key & Add Repository
Next, you need to add repository for the Apache Cassandra using wget and import the GPG key to the system:
wget -q -O - https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
sudo sh -c 'echo "deb http://www.apache.org/dist/cassandra/debian 311x main" > /etc/apt/sources.list.d/cassandra.list'
It will not show anything in output.
Step 3 – Install Apache Cassandra
You are now ready to install Cassandra on Ubuntu.
Update the repository package list:
sudo apt update
To proceed ahead, run the following command to install Apache Cassandra:
sudo apt install Cassandra
Apache Cassandra service will automatically start after the installation process is complete.
Step 4 – Verify Installation
You can check Cassandra installation by issuing below given command:
sudo systemctl status cassandra
Output should show something like below:
● cassandra.service - LSB: distributed storage system for structured data Loaded: loaded (/etc/init.d/cassandra; generated) Active: active (running) since Tue 2022-12-03 03:25:52 UTC; 15min 25s ago Docs: man:systemd-sysv-generator(8) Process: 9502 ExecStart=/etc/init.d/cassandra start (code=exited, status=0/SUCCESS) Tasks: 52 (limit: 4495)
That’s it. At this step, Apache Cassandra is installed on your Ubuntu server.
Step 5 – Connecting to Cluster
You need to use nodetool to connect the clusterIt. To check the cluster’s status type:
sudo nodetool status
It will show output as following:
Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 127.0
In the output, UN means it’s Up and Normal.
Then connect to the cluster using its interactive command line interface
Connected to Test Cluster at 127.0.0.1:9042 [cqlsh 6.0.0 | Cassandra 4.0.4 | CQL spec 3.4.5 | Native protocol v5] Use HELP for help.
Type exit to quit.
You have successfully installed Apache Cassandra on Ubuntu 22.04. To learn more about Cassandra, visit the official Apache Cassandra Documentation page.
If you have a problem or suggestion, please leave a comment below.
Leave a Reply