Install Apache Cassandra on Ubuntu

Install Apache Cassandra on Ubuntu

In this quick post, we will see how we can install one of the most popular distributed Databases, Apache Cassandra on Ubuntu and start using it as well. We will get started now.

Read posts about Neo4J, Elasticsearch and MongoDB as well.

Apache Cassandra

Cassandra is one of the most popular distributed NoSQL databases from Apache which is known for its scalability, performance and its high availability with no single point of failure.

Some points which make Apache Cassandra stand tall are:

  • Consistent and highly fault-tolerant.
  • Very close in architecture to Amazon’s Dynamo DB and data model is close to Google’s Bigtable.
  • Created at facebook
  • It is a column-oriented database
  • Used at some very big companis like Cisco, Rackspace, Netflix and many more

Installing Java

To install Cassandra on Ubuntu, we must install Java first. Java might not be installed by default. We can verify it by using this command:

java -version

When we run this command, we get the following output:

We will now install Java on our system. Use this command to do so:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Once these commands are done running, we can again verify that Java is now installed by using the same command.

Installing Cassandra

Installing Cassandra on Ubuntu is a very easy task and is just a matter of few commands. We will start by adding Cassandra repository to the Ubuntu Source list:

echo "deb http://www.apache.org/dist/cassandra/debian 311x main"
| sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list

Once we run this program, we will get the following output:

Now, we will add the Apache Cassandra repository keys:

curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add

Once we run this program, we will get the following output:

Now, we can update the apt-get list for Ubuntu using this command:

sudo apt-get update

Finally, we’re ready to install Cassandra on Ubuntu machine:

sudo apt-get install cassandra

Last command can take a few minutes based on the Internet speed. We can now check if Cassandra is up and running on our machine:

sudo service cassandra status

We will see that the service is Active:

Connecting to Cassandra cluster

Cassandra is started automatically once the installation process is complete. Cassandra is a distributed database and so, it doesn’t work as a single system but instead, it works in a cluster which can consist of virtually any number of nodes.

When Cassandra starts on our machine, it set up a cluster automatically with a single node as part of it. We can check if the cluster is up using this command:

sudo nodetool status

If we see UN in our output, this means that Cluster is Up and Running:

Connecting to Cassandra Database

In a final step, we will show how we can enter into the Cassandra terminal. Use a simple command to start using Cassandra:

cqlsh

Once you run this, we will see that we can now execute Cassandra commands on our machine and create related data:

Related Posts
Leave a Reply

Your email address will not be published.Required fields are marked *