How to 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:

java --version

  • 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:

python --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.

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.

sudo add-apt-repository ppa:webupd8team/java

After entering this command, it may prompt you to hit enter to continue.
Once it completes update the package database using the following:

sudo apt-get update

You can now install Oracle JRE with the following:
sudo apt-get install oracle-java8-set-default

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.

Java Installer Screen

 

Once successfully installed verify the default version of Java by typing:

java -version

You’ll receive the following or something very similar :

Java Version Output

 

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. For example, use 37x if Cassandra 3.7 is the newest version.):
echo "deb http://www.apache.org/dist/cassandra/debian 36x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list

Next, run the cURL command to add the repository keys :

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

We can now update the repositories:

sudo apt-get update

 

Note
If you get the following error: GPG error: http://www.apache.org 36x InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY A278B781FE4B2BDA
Add the public key by running the following command:
sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-key A278B781FE4B2BDARepeat the update to the repositories:
sudo apt-get update

Finally, finish installing by entering the following:
sudo apt-get install cassandra

Verify the installation of Cassandra by running:
nodetool status

The desired output will show UN meaning everything is up and running normally.

Verifying Cassandra is Installed

 

Step 3: Connect with cqlsh

If you have an older version of Python before 2.7.11, you’ll skip this step and start using Cassandra with the cqlsh command. Good for you! You have successfully installed Cassandra!
cqlsh

You should see something similar to this:
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.6 | CQL spec 3.4.2 | Native protocol v4] Use HELP for help.

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:
python --version

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.

sudo apt-get install python-pip

 

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.

pip install cassandra-driver

 

Step 3c: Finally disable the embedded driver by entering :

export CQLSH_NO_BUNDLED=true

You should now be able to run the cqlsh command.

cqlsh

You should see this if successful :

Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.6 | CQL spec 3.4.2 | Native protocol v4] Use HELP for help.

To exit cqlsh type exit:
cqlsh> 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:

sudo service cassandra start
sudo service cassandra stop

How to Install the Cassandra Storage Engine for MariaDB 10.0 on Fedora 20

MariaDB is a drop-in replacement for MySQL. It is easy to install, offers many speed and performance improvements, and is easy to integrate into most MySQL deployments. Answers for compatibility questions can be found at: MariaDB versus MySQL – Compatibility. MariaDB offers more storage engines than MySQL, including Cassandra (NoSQL), XtraDB (drop-in replacement for InnoDB), and OQGRAPH.

Pre-Flight Check
  • These instructions are intended for installing the Cassandra Storage Engine for MariaDB 10.0 on Fedora 20.
  • I’ll be working from a Liquid Web Self Managed Fedora 20 server, and I’ll be logged in as root.
  • Your server should already have MariaDB 10.0 installed. If you’re working from MariaDB 5.5, visit our tutorial on: How to Upgrade MariaDB 5.5 to MariaDB 10.0 on Fedora 20

Continue reading “How to Install the Cassandra Storage Engine for MariaDB 10.0 on Fedora 20”

How to Upgrade MariaDB 5.5 to MariaDB 10.0 on Fedora 20

MariaDB is a drop-in replacement for MySQL installed by default on CentOS 7, and offers many speed and performance improvements. MariaDB offers more storage engines than MySQL, including Cassandra (NoSQL), XtraDB (drop-in replacement for InnoDB), and OQGRAPH.

Pre-Flight Check
  • These instructions are intended for upgrading from MariaDB 5.5 to MariaDB 10.0 on Fedora 20.
  • I’ll be working from a Liquid Web Self Managed Fedora 20 server, and I’ll be logged in as root.

Continue reading “How to Upgrade MariaDB 5.5 to MariaDB 10.0 on Fedora 20”

How to Install the Cassandra Storage Engine for MariaDB 10.0 on CentOS 7

MariaDB is a drop-in replacement for MySQL. It is easy to install, offers many speed and performance improvements, and is easy to integrate into most MySQL deployments. Answers for compatibility questions can be found at: MariaDB versus MySQL – Compatibility. MariaDB offers more storage engines than MySQL, including Cassandra (NoSQL), XtraDB (drop-in replacement for InnoDB), and OQGRAPH.

Pre-Flight Check
  • These instructions are intended for installing the Cassandra Storage Engine for MariaDB 10.0 on CentOS 7.
  • I’ll be working from a Liquid Web Core Managed CentOS 7 server, and I’ll be logged in as root.
  • Your server should already have MariaDB 10.0 installed. If you’re working from MariaDB 5.5, visit our tutorial on: How to Upgrade MariaDB 5.5 to MariaDB 10.0 on CentOS 7

Continue reading “How to Install the Cassandra Storage Engine for MariaDB 10.0 on CentOS 7”

How To Install Cassandra 2 on Fedora 20

Apache Cassandra is a NoSQL database intended for storing large amounts of data in a decentralized, highly available cluster. NoSQL refers to a database with a data model other than the tabular relations used in relational databases such as MySQL, PostgreSQL, and Microsoft SQL.

Pre-Flight Check
  • These instructions are intended for installing Cassandra 2 on a single Fedora 20 node.
  • I’ll be working from a Liquid Web Self Managed Fedora 20 server, and I’ll be logged in as root.
  • You may be able to skip to Step #2 if you already have a stable version of Java 7 (preferably the Oracle/Sun JVM). Check to see if your server already has Java installed by running the following command: java -version

 

Step 1: Install Java

First, you’ll follow a simple best practice: ensuring the list of available packages is up to date before installing anything new.

yum -y update

At this point, installing java is as simple as running just one command:

yum -y install java

Step #2: Add the DataStax Community Repository

For a refresher on editing files with vim see: New User Tutorial: Overview of the Vim Text Editor

vim /etc/yum.repos.d/datastax.repo

Add the following information to the file you’ve created, using i to insert:

[datastax] name = DataStax Repo for Apache Cassandra
baseurl = http://rpm.datastax.com/community
enabled = 1
gpgcheck = 0

Then exit and save the file with the command :wq (see the example below):
How To Install Cassandra 2 and Run a Single Node Cluster on CentOS 6 - 02 DataStax Repo

Step #3: Install Apache Cassandra 2

At this point, installing Cassandra is as simple as running just one command:

yum -y install dsc20

Step #4: Get Cassandra Running

Start-Up Cassandra

systemctl start cassandra

Check Cassandra Service Status

systemctl status cassandra

Enable Cassandra to Start at Boot

systemctl enable cassandra

Check Cassandra Node Status

nodetool status

If you get an error such as: ‘Failed to connect to ’127.0.0.1:7199′: Connection refused’

Then visit the following tutorial: Error: Failed to connect to ’127.0.0.1:7199′: Connection refused (Cassandra) [SOLVED]

Restart Cassandra

systemctl restart cassandra

Shutdown Cassandra

service cassandra stop

Enter the Cassandra Command Line

cqlsh

The cqlsh interface should look similar to:

Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.1 | Cassandra 2.0.10 | CQL spec 3.1.1 | Thrift protocol 19.39.0] Use HELP for help.
cqlsh>

How to Install the Cassandra Storage Engine for MariaDB 10.0 on CentOS 6

MariaDB is a drop-in replacement for MySQL. It is easy to install, offers many speed and performance improvements, and is easy to integrate into most MySQL deployments. Answers for compatibility questions can be found at: MariaDB versus MySQL – Compatibility. MariaDB offers more storage engines than MySQL, including Cassandra (NoSQL), XtraDB (drop-in replacement for InnoDB), and OQGRAPH.

Pre-Flight Check
  • These instructions are intended for installing the Cassandra Storage Engine for MariaDB 10.0 on CentOS 6.
  • I’ll be working from a Liquid Web Core Managed CentOS 6.5 server, and I’ll be logged in as root.
  • Your server should already have MariaDB 10.0 installed. If you’re working from MySQL 5.1 or MariaDB 5.5, visit our tutorial on: How to Upgrade MySQL 5.1 to MariaDB 10.0 on CentOS 6

Continue reading “How to Install the Cassandra Storage Engine for MariaDB 10.0 on CentOS 6”

How to Upgrade MariaDB 5.5 to MariaDB 10.0 on CentOS 7

MariaDB is a drop-in replacement for MySQL installed by default on CentOS 7, and offers many speed and performance improvements. MariaDB offers more storage engines than MySQL, including Cassandra (NoSQL), XtraDB (drop-in replacement for InnoDB), and OQGRAPH.

Pre-Flight Check
  • These instructions are intended for upgrading from MariaDB 5.5 to MariaDB 10.0 on CentOS 7.
  • I’ll be working from a Liquid Web Core Managed CentOS 7 server, and I’ll be logged in as root.

Continue reading “How to Upgrade MariaDB 5.5 to MariaDB 10.0 on CentOS 7”

How to Upgrade MySQL 5.1 to MariaDB 10.0 on CentOS 6

MariaDB is a drop-in replacement for MySQL. It is easy to install, offers many speed and performance improvements, and is easy to integrate into most MySQL deployments. Answers for compatibility questions can be found at: MariaDB versus MySQL – Compatibility. MariaDB offers more storage engines than MySQL, including Cassandra (NoSQL), XtraDB (drop-in replacement for InnoDB), and OQGRAPH.

Pre-Flight Check
  • These instructions are intended for upgrading from MySQL 5.1 to MariaDB 10.0 on CentOS 6.
  • I’ll be working from a Liquid Web Core Managed CentOS 6.5 server, and I’ll be logged in as root.

Continue reading “How to Upgrade MySQL 5.1 to MariaDB 10.0 on CentOS 6”

How To Install MariaDB 5.5 on CentOS 6

MariaDB is a drop-in replacement for MySQL. It is easy to install, offers many speed and performance improvements, easy to integrate into most MySQL deployments. Answers for compatibility questions can be found at: MariaDB versus MySQL – Compatibility. MariaDB offers more storage than MySQL, including Cassandra (NoSQL), XtraDB (drop-in replacement for InnoDB), and OQGRAPH.

Pre-Flight Check
  • These instructions are intended for installing MariaDB on a single CentOS 6 node.
  • I’ll be working from a Liquid Web Core Managed CentOS 6.5 server, and I’ll be logged in as root.

Continue reading “How To Install MariaDB 5.5 on CentOS 6”

How To Install Cassandra on CentOS 7

Apache Cassandra is a NoSQL database intended for storing large amounts of data in a decentralized, highly available cluster. NoSQL refers to a database with a data model other than the tabular relations used in relational databases such as MySQL, PostgreSQL, and Microsoft SQL.

Pre-Flight Check
  • These instructions are intended for installing Cassandra 2 on a single CentOS 7 node.
  • I’ll be working from a Liquid Web Core Managed CentOS 7 server, and I’ll be logged in as root.
  • You may be able to skip to Step #2 if you already have a stable version of Java 7 (preferably the Oracle/Sun JVM). Check to see if your server already has Java installed by running the following command: java -version
  • Continue reading “How To Install Cassandra on CentOS 7”