Setup Cassandra and run a Single-Node Cluster
Apache Cassandra is an open source distributed database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Cassandra offers capabilities that relational databases and other NoSQL databases simply cannot match such as: continuous availability, linear scale performance, operational simplicity and easy data distribution across multiple data centers and cloud availability zones. Cassandra’s architecture is responsible for its ability to scale, perform, and offer continuous uptime. Rather than using a legacy master-slave or a manual and difficult-to-maintain shared architecture, Cassandra has a masterless "ring" design that is elegant, easy to setup, and easy to maintain.
Let’s see how we are going to install and use it to run a single-node cluster on Ubuntu 16.04.
Update our system to latest updates and security patches available before installing other prerequisites and Cassandra, . You can run the command below to get the latest updates.
Installing JDK 8:
Apache Cassandra is run on top of Java Virtual Machine (JVM). We’ll install Oracle JDK 8 on the system before we install Apache Cassandra. Apache Cassandra can also run on OpenJDK, IBM JVM and Azul Zing JVM.
We will install Oracle JDK using the Webupd8 team team PPA repository. First step is to add the webupd8team ppa repository using below command.
Press [ENTER] to continue or ctrl-c to cancel adding it.
You need to press enter to continue adding the webupd8team PPA repository. Then update the package database and install JDK 8 by flowing below command.
Now install the Oracle JRE package, this will not only installs but also makes it the default JRE.
Accept the license agreement when prompted.
Then accepting the Oracle Binary Code License Terms by Choosing 'Yes' option
Once installation of Java 8 complete, you can check the current java version by running command below.
ubuntu@ubuntu-16:~$ java -version java version "1.8.0_91" Java(TM) SE Runtime Environment (build 1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
Installing Apache Cassandra:
No we can start installing Apache Cassandra ,from the official Apache Software Foundation repositories, so start by adding the repo so that the packages are available to the system by adding the repo's source.
Then add the following three public keys from the Apache Software Foundation associated with the package repositories to avoid package signature warnings.
$ gpg --keyserver pgp.mit.edu --recv-keys F758CE318D77295D $ gpg --export --armor F758CE318D77295D | sudo apt-key add -
Add the second key using below commands.
$ gpg --keyserver pgp.mit.edu --recv-keys 2B5C1B00 $ gpg --export --armor 2B5C1B00 | sudo apt-key add -
To add third keys run the below commands.
$ gpg --keyserver pgp.mit.edu --recv-keys 0353B12C $ gpg --export --armor 0353B12C | sudo apt-key add -
After this once again update your system, so that ‘apt-get’ can read the metadata of Cassandra repository.
After system updates, now let's install Cassandra 37x on your Ubuntu 14 LTS. This is the latest stable version of Cassandra.
Run the below command to install Cassandra on your Ubuntu system and pres 'y' key to continue.
Starting Cassandra service:
Now Cassandra service should be up and running on your system.
To confirm that it’s not running, use below command to check its status.
If you did not get the running status, then flow the command below in your command line terminal to start its service.
Connecting to the Cluster:
Once your Cassandra service is up and running , check the status of the cluster using below command.
Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 127.0.0.1 103.01 KiB 256 100.0% da43244b-b1f1-4426-9b24-9ea3cb31ecb4 rack1