Single-Node Cassandra Cluster and NodeJS client — demo setup on Ubuntu 14.04 (AWS)

Cassandra + NodeJS


With this short article I will guide you step-by-step to get started with the Cassandra Database, including:

  • Configuring the EC2-Instance
  • Installing Cassandra Database
  • Setting up authentification strategy
  • Configure Cassandra to be open to the world

Configuring the EC2-Instance

Go to the AWS console -> EC2 and Launch an Instance. In this tutorial, we use Ubuntu Image for the Instance.

In the security group section, we need to open the some following ports for inbound communication that are used by Cassandra Database.

  • 7000 — Internode communication (not used if TLS enabled)
  • 7001 — TLS Internode communication (used if TLS enabled)
  • 9160 — Thrift client API
  • 9042 — CQL native transport port

Installing Cassandra

Authentification Setup

Out of the box, Cassandra provides two authentification modes: AllowAllAuthenticator and PasswordAuthenticator.

AllowAllAuthenticator performs no checks and is the default authentifator .
PasswordAuthenticator relies on username/password pairs to authenticate users. It keeps usernames and hashed passwords in system_auth.credentials table.

We want to switch from AllowAllAuthenticator to PasswordAuthenticator.

Open the cassandra.yaml configuration file:

sudo vim /etc/cassandra/cassandra.yaml

and change the authenticator option to PasswordAuthenticator. By default, the authenticator option is set to AllowAllAuthenticator.

authenticator: PasswordAuthenticator

For more detailed information, refer to

Now, we will setup a different user. We access the cqlsh-console with the default Cassandra username and password: cassandra.

cqlsh -u cassandra -p cassandra

and run:


For details concerning creating new users (or roles) refer to:

Database configuration

Firstly, we need to find out the private IP of our EC2-Instance. You will find it in the your AWS-Dashboard, by going to EC2 -> running instances and clicking on your instance. Private IP will be visible in the description tab.

Description of EC2-Instance — Private IP

Now open the /etc/cassandra/cassandra.yaml file again, and overwrite the following properties:

listen_address: <yourPrivateIP>
seeds: ",<yourPrivateIP>"
rpc_address: <yourPrivateIP>

and restart the Cassandra database:

sudo service cassandra restart

NodeJS client example

We use the cassandra-driver npm package.

const cassandra = require(‘cassandra-driver’);const client = new cassandra.Client({
contactPoints: [ ‘your-public-api’ ],
authProvider: new cassandra.auth
.PlainTextAuthProvider(‘developer’, ‘devpassword’)

Note that we use here the public IP of the EC2-Instance, not the private IP that we used before in the Cassandra config.

Finally we can setup the first keyspace and table.

client.execute(`CREATE KEYSPACE IF NOT EXISTS vq_ai_tracking WITH REPLICATION = { ‘class’ : ‘SimpleStrategy’, ‘replication_factor’ : 1 };`)
.then(() =>
client.execute(`CREATE TABLE IF NOT EXISTS vq_ai_tracking.actions(userId uuid primary key);`,
(err, result) => {
console.log(err, result);

Further reading



Hi, I’m Adrian. This is my private blog and you’ll find here from time to time updates about my travels, works and investments.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adrian Barwicki

Hi, I’m Adrian. This is my private blog and you’ll find here from time to time updates about my travels, works and investments.