Install Cassandra on Ubuntu 16.04 LTS
Apache Cassandra is a free open-source database system that is NoSQL based. Meaning Cassandra does not use the table model seen in MySQL, MSSQL or PostgreSQL, but instead uses a cluster model. It’s designed to handle large amounts of data and is highly scalable. We will be installing Cassandra and its pre-requisites, Oracle Java, and if necessary the Cassandra drivers.
Pre-Flight Check
- We are logged in as root on an Ubuntu 16.04 VPS powered by Liquid Web!
- Apache Cassandra and this article expect that you are using Oracle Java Standard Edition 8, as opposed to OpenJDk . Verify your Java version by typing the command below into your terminal:
- At the time of this article, Python 2.7.11 and later versions will need to install updated Cassandra drivers to fix a known bug with the cqlsh command. You can check your Python version similar to checking your Java version:
- If you have Python 2.7.11+ or later, download the required driver by running the pip command. You will need pip installed. Within this tutorial, we will show you how to install pip. However, pip is usually pre-installed with Python by default.
Installation of Apache Cassandra
Step 1: Install Oracle Java (JRE)
Cassandra requires your using Oracle Java SE (JRE) installed on your server. First, you will have to add Personal Package Archives to make the (JRE) package available.
After entering this command, it may prompt you to hit enter to continue.
Once it completes update the package database using the following:
You can now install Oracle JRE with the following:
A pink screen prompts you to agree to the terms and conditions of JRE. Hit enter to continue from this screen and accept the terms and conditions in the next screen.
Once successfully installed verify the default version of Java by typing:
You’ll receive the following or something very similar :
Step 2: Installing Apache Cassandra
First, we have to install the Cassandra repository to /etc/apt/sources.list.d/cassandra.sources.list directory by running following command (When we made this article Cassandra 3.6 was the current version. You may need to edit this line to reflect the latest release by updating the 36x value.
Next, run the cURL command to add the repository keys:
We can now update the repositories:
Finally, finish installing by entering the following:
Verify the installation of Cassandra by running:
The desired output will show UN meaning everything is up and running normally.
Step 3: Connect with cqlsh
If you have got associate older version of Python before two.7.11, you’ll skip this step and begin mistreatmentprophetess with the cqlsh command. smart for you! you have got with success put in Cassandra!
You should see something similar to this:
Note
For future reference, Cassandra’s configuration file, data directory and logs can be found in:
- /etc/cassandra is the default file configuration location.
- /var/log cassandra and /var/lib cassandra are the default log and data directories location.
However, if you get the following error,
Connection error: (‘Unable to connect to any servers’, {‘127.0.0.1’: TypeError(‘ref() does not take keyword arguments’,)}),
you’ll update the Cassandra drivers. These drivers have a known bug with Cassandra and later versions of Python. Check your Python version by typing:
Luckily, I am going to show you how you can fix this error in 3 easy steps by downloading the drivers.
Step 3a:
First we will need pip installed. If you don’t have it already, you can get it with the following command.
Step 3b:
Once pip is installed, run the following to install the new Cassandra driver. Please note this command may take a while to execute. Grab a snack and wait for it to complete. It can take 5-10 minutes to install fully.
Step 3c:
Finally disable the embedded driver by entering :
You should now be able to run the cqlsh command.
You should see this if successful :
To exit cqlsh type exit:
Congrats! You have successfully installed Cassandra!
Note
Cassandra should start automatically, but you’ll want to stop Cassandra to make any additional configuration changes. Start and stop it with the following:
Add Comment