;

How to Install Cassandra on Ubuntu 16

Try it in our public cloud & Get $5 Credit
CLAIM NOW

How to Install Cassandra on Ubuntu 16

Cassandra is an open-source non-relational database management system. It was designed to be used with lots of redundancy, and it can be split up onto multiple machines so that if one part fails, the other parts continue to with little to no interruption to users. Ubuntu is a great operating system to host on as it won’t bog down the system. Even if the command line scares you at first, It’s not that hard to install. This article will guide you on how to install Apache Cassandra on Ubuntu 16.04 Server LTS.

Getting Started

To complete this guide, you will need the following:
• 1 server (Cloud Server or Dedicated Server) running Ubuntu 16.
• Root access

Gaining root permission is simple and prevents bugs from popping up during installation. Just make sure to exit out of the root when you’re done with setup.

Tutorial

Install Java
First we need to make sure that Java is installed, so add the repository. Repositories are basically groups or lists of programs that are useful together, and adding a repository is the best way to get a program. You may get a warning to use Java 8 instead of 9; don’t worry, continue on.

add-apt-repository ppa:webupd8team/java

After that’s added, update the list of repositories.

apt-get update

Install Java. Answer yes if you get a confirmation for storage and accept the license terms. Installing might take a few moments depending on your computer’s speed.

apt-get install oracle-java8-set-default

Confirm your version of Java. At the time of writing, the latest stable version is 1.8.

java -version

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Install Cassandra

Just like with Java, we need to add the repository. Since these are protected files, you need to provide your email and password associated with Datastax. Depending on your exact computer setup, you may need to add a backslash (\) to parts of your email with special characters. Instead of
“Ma!lLover@Globo.Tech,” it would be “Ma\!lLover@Globo.Tech”. You might also have to replace “@” with “%40”.

echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list

Also add the repository key to get past the extra layer of security.

curl -L http://debian.datastax.com/debian/repo_key | sudo apt-key add -

Update your list a third time and install Casandra the same way as the last two.

apt-get update
apt-get install cassandra -y

Start Cassandra up and configure it to your liking. You’ll most likely want to enable it to start on boot. In case of a power outage or maintenance, you won’t forget to start it back up after a reboot.

systemctl start cassandra
systemctl enable cassandra

Cassandra uses a separate command line to be controlled, so we need to make sure to activate that.

[root@cassandra ~]# cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.0.8 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.
cqlsh>

You may want to check information about the node and cluster to get an idea of how to fix various issues or update information. You can do that using the “nodetool” command:

[root@cassandra ~] nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 222.14 KB 256 100.0% 2a0b7fa9-23c6-40d3-83a4-e6c06e2f5736 rack1
[root@cassandra ~]#

Conclusion

You should now have Java and Cassandra installed and ready to use. Make sure to share this guide with others looking for help.