How to install Cassandra on Ubuntu

Connect with

Apache Cassandra
Installing of Apache Cassandra with DataStax on debian based OS either Ubuntu or Linux Mint are same. Follow following steps and you are done.

Prerequisites

  • Ensure that your platform is supported.
  • Advanced Package Tool is installed.
  • root or sudo access to the install machine.
  • Latest version of Oracle JDK8.
  • Python 2.7

The packaged releases create a cassandra user. When starting Cassandra as a service, the service runs as this user. The following utilities are included in a separate package: sstable2json, sstablelevelreset, sstablemetadata, json2sstable, sstablerepairedset, sstablesplit, and token-generator.

Step by Step installation

In a terminal window:

Check which version of Java is installed by running the following command:

 $ java -version

output

ranjeetjha@jha:~$ 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)
ranjeetjha@jha:~$ 

It is recommended to use the latest version of Oracle Java 8 or OpenJDK 8 on all nodes.
Add the DataStax Distribution of Apache Cassandra 3.x repository to the /etc/apt/sources.list.d/cassandra.sources.list

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

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

Install the latest package:

 $ sudo apt-get update
 $ sudo apt-get install datastax-ddc

This command automatically installs the Cassandra utilities such as sstablelevelreset, sstablemetadata, sstableofflinerelevel, sstablerepairedset, sstablesplit, token-generator. Each utility provides usage/help information; type help after entering the command.
Debian packages start the Cassandra service automatically, you do not need to start the service. Now cassandra service is running you can check by typing following command.

To check status of service

  $ service cassandra status

To start cassandra service

  $ service cassandra start

To stop cassandra service

  $ service cassandra stop

Verify that DataStax Distribution of Apache Cassandra is running:

 $ nodetool status
   Datacenter: datacenter1
   =======================
   Status=Up/Down
   |/ State=Normal/Leaving/Joining/Moving
   --  Address             Load       Tokens  Owns    Host ID                               Rack
   UN  127.0.0.147.66 KB   47.66 KB   256     100%    aaa1b7c1-6049-4a08-ad3e-3697a0e30e10  rack1

Because the Debian packages start the Cassandra service automatically, you must stop the server and clear the data:

Doing this removes the default cluster_name (Test Cluster) from the system table. All nodes must use the same cluster name.

    $ sudo service cassandra stop
    $ sudo rm -rf /var/lib/cassandra/data/system/*

Reference

Datastax


Connect with

1 thought on “How to install Cassandra on Ubuntu

  1. That is a very good tip especially to those new to the blogosphere.
    Short but very precise info… Thanks for sharing this one.

    A must read article!

Leave a Reply

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