×



Apache Cassandra is a NoSQL database used for storing large amounts of data. It has a distributed architecture and is designed to manage large volumes of data with dynamic replication. It is used by thousands of companies to save and retrieve thousands of terabytes of data. Apache Cassandra is the best choice for you if you are looking for a database management system with scalability and high availability.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related database queries.

In this context, we shall look into how to install Apache Cassandra on Ubuntu OS.


How to Install Apache Cassandra on Ubuntu ?

To begin with this Installation procedure, simply follow the steps given below.


1. Install java

Apache Cassandra requires java to be running on the machine. Use these commands to install java on your system:

$ sudo apt update
$ sudo apt install openjdk-8-jdk

To verify if Java is installed, issue this command in Terminal:

$ java -version


2. Install Apache Cassandra

Before proceeding towards the installation of Apache Cassandra, you will first need to install the apt-transport-https package. You can install it using this command:

$ sudo apt install apt-transport-https

Enter the password for sudo. When prompted for continuation, press y.

Now import and add the GPG key using this command in the Terminal:

$ wget -q -O - https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -

If the key is added successfully, you will see OK in the output.

Now add the Apache Cassandra repository to apt list of sources using this command in the Terminal:

$ sudo sh -c 'echo "deb http://www.apache.org/dist/cassandra/debian 311x main" > /etc/apt/sources.list.d/cassandra.list'

Update the apt list of sources using the command below in the Terminal:

$ sudo apt update

Now that the repository has been added, you can install Apache Cassandra using this command in the Terminal:

$ sudo apt install Cassandra

Enter the password for sudo. When prompted for continuation, press y.

After the installation of Apache Cassandra, its service starts automatically. To verify it, use the command below:

$ sudo systemctl status Cassandra

Also, you can verify the status using the below command:

$ sudo nodetool status

Now the Apache Cassandra has been successfully installed. To login to Apache Cassandra, you can use the cqlsh command-line tool as follows:

$ cqlsh


How to Rename Apache Cassandra Cluster ?

In the previous output, you can see the cluster name is "Test Cluster".

i. To change the default cluster name, log in to Cassandra using the cqlsh command-line tool as follows:

$ cqlsh

ii. Then issue the command below in the Terminal to rename the Apache Cassandra Cluster to let's say "LinuxApt_cluster":

$ UPDATE system.local SET cluster_name = 'LinuxApt_cluster' WHERE KEY = 'local';

Make sure to change the LinuxApt_cluster with your own desired name.

iii. Now to exit the cqlsh tool, type exit, and press Enter:

$ exit

iv. Then edit the cassandra.yaml configuration file using the command below in the Terminal:

$ sudo nano /etc/cassandra/cassandra.yaml

v. Now in the cassandra.yaml configuration file, search for the cluster_name.

Once you find it, change its name to your desired value.

vi. Then save and exit the file.

vii. Now to verify if the cluster name has been changed successfully, use the command below:

$ cqlsh

The output below verifies that the cluster name has been changed successfully to LinuxApt_cluster.


How to Uninstall Apache Cassandra from Ubuntu ?

In case you need to remove Apache Cassandra from your machine, you can do this using the following steps:

i. Stop the service of Cassandra using the command below:

$ sudo service cassandra stop

ii. Then remove the library and log directories using these commands:

$ sudo rm -r /var/lib/cassandra
$ sudo rm -r /var/log/Cassandra

iii. After that, uninstall Apache Cassandra using the command below:

$ sudo apt purge cassandra


[Need assistance in fixing Ubuntu Database Linux errors? We can help you. ]


Conclusion


More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com