Skip to content

Instantly share code, notes, and snippets.

@marktopper
Last active March 24, 2023 14:49
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save marktopper/57af0232db757971e5f7 to your computer and use it in GitHub Desktop.
Save marktopper/57af0232db757971e5f7 to your computer and use it in GitHub Desktop.
Install Kong + Cassandra + Java [Ubuntu 14.04]

Installing Java

We need Java in order to have Cassandra running since Cassandra 2.0 and later require Java 7 or later. And we need Cassandra in order to run Kong.

So lets start installing Java 8 (the newest one)

First we add a repository to our build in order to manage the Java 8 package, since that is not normally supported by Ubuntu.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

Now the repository have been added and updated we can go ahead and install Java 8

sudo apt-get install oracle-java8-installer

If you wish to install Java 7 instead, use this:

sudo apt-get install oracle-java7-installer

That will keep your Java installation up to date.

Now we need to setup the Java environment variables JAVA_HOME and PATH, luckily we can do that in another singe command:

sudo apt-get install oracle-java8-set-default

For Java 7 use:

sudo apt-get install oracle-java7-set-default

Now Java is fully installed on your server.

Installing Cassandra

Now we can install Cassandra since we have installed Java, and Java 7+ is required for Cassandra 2.0+.

First we we will have to add the DataStax Community repository to the /etc/apt/sources.list.d/cassandra.sources.list

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

Then we will have to add the DataStax repository key to your aptitude trusted keys.

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

Now when that is done we can go ahead update and install Cassandra.

sudo apt-get update
sudo apt-get install cassandra

We need to do a small configuration in order to have Cassandra working proberly. Open /etc/passwd and change

cassandra:x:***:***:Cassandra database,,,:/var/lib/cassandra:/bin/false

to

cassandra:x:***:***:Cassandra database,,,:/var/lib/cassandra:/bin/bash

Note: Do only change the /bin/false part to /bin/bash. Everything else in the line to remain as it is.

Now we can run Cassandra

sudo /usr/sbin/cassandra

Installing Kong

First we have to download the file from Kong's website. Luckily we can do that pretty easy:

wget "https://github.com/Mashape/kong/releases/download/0.3.2/kong-0.3.2.trusty_all.deb"

Now when we have the file we can install Kong, but it is a good idea to get the last required packages first.

sudo apt-get update
sudo apt-get install netcat lua5.1 openssl libpcre3 dnsmasq

And now we can install Kong

sudo dpkg -i kong-0.3.2.*.deb

Questions & Problems

I can be reached at mark@webman.io.

@BransonGitomeh
Copy link

BransonGitomeh commented Oct 19, 2016

thanks! very helpfull. though when i ran

sudo /usr/sbin/cassandra
root@sabek-lab:~# Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000e7400000, 415236096, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 415236096 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /root/hs_err_pid4181.log

but cassandra started just fine

@divneet
Copy link

divneet commented Mar 16, 2017

I followed the steps written above , although unable to connect to 'cqlsh'

the error i get

Connection error: ('Unable to connect to any servers', {'127.0.0.1': TypeError('ref() does not take keyword arguments',)})

@abdulgaffarabu
Copy link

Before trying to connect to cassandra shell (cqlsh), you need to run nodetool status.

The procedure is ...
~# service cassandra start

make sure your cassandra service started by running the following command.
~# service cassandra status

If status is "running" then run the nodetool
~# nodetool status

Then run to connect cassandra shell
~# cqlsh

you will be connected to cqlsh like,
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.10 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment