Deploy multi data center elassandra cluster

(λx.x)eranga
Effectz.AI
Published in
4 min readMay 3, 2019

About elassandra

Elassandra is a distributed storage which built with combining elasticseachwith cassandra. It comes elasticsearch as a cassandra plugin. Basically it has cassandra API as well as elasticsearch API. When data save on cassandra it will automatically index on elasticsearch. It’s an ideal and powerful solutions to achieve full text search on cassandra. Read more about elassandra from here.

I’m this post I’m gonna show about deploying elassandra cluster in multi data center environment. Following are the steps to follow.

Cluster infrastructure

I’m gonna deploy elassandra cluster on two data centers DC1 and DC2. Each data center have two elassandra nodes, altogether there will be 4 nodes in the cluster. Following are the nodes. In each data center I have a seed node which use to bootstrap the cluster between data centers. It is a best practice to have more than one seed node per datacenter. In here I have used one seed node since two nodes available per data center.

Install java

To run elassandra it required java 8+. In here I’m gonna install OpenJDK 8(if want you can install oracle JDK as well, oracle JDK is the recommended version for elassandra). Following is the way to install OpenJDK 8.

Download elassandra

There are several ways to install elassandra tarball, deb and rpm. In here I’m gonna install with tarball. To that I need to download and extract the elassandra tarball first.

Elassnadra directory contains all the configurations and scripts that need to run the cluster. Following is the structure of elassandra-5.5.0.14 directory.

Cassandra config

Next step is to configure the cassandra config file cassandra.yml with cluster configurations. All the configuration files locates at elassandra-5.5.0.14/conf directory. Following are the configurations that I have added to cassandra.yml. Add these information to each and every node in the cluster(all nodes in DC1 and DC2).

Data center config

After defining cassandra configurations I need to define the data center configurations. The data center configurations file locates at elassandra-5.5.0.14/conf/cassandra-rackdc.properties. Following are the configurations I have added. Basically it indicate the rack and data center of the each and every node.

Remove cassandra topology

The GossipingPropertyFileSnitch always loads cassandra-topology.properties when that file is present. I have removed that file from each node.

Start elassandra

Now everything is ready to start the cluster. I can start elassandra on each and every node one by one. Elasandra start scripts locates on elassandra-5.5.0.14/bin directory.

After starting cassandra on all nodes I can view the cluster status by nodetool command which locates on elassandra-5.5.0.14/bin directory.

Following is the nodetool status output of my cluster. It shows all the nodes and health informations of the cluster.

Create keyspace and table

I can connects to cassandra with cqlsh command which locates on elassandra-5.5.0.14/bin directory to create the keyspace and tables. Following is the way to do that.

I have created keyspace with Replication Factor = 2. When creating the keyspace I have specified the RF on each data center 'DC1':'2', 'DC2':'2'.

Create elasticsearch index

Finally I can create the elasticsearch index of connects table. Following is the way to do that with HTTP PUT request.

I have executed this command from the node 172.31.27.143 in DC1. Following is the output.

The created elasticsearch index’s replication(number of replicas) sets with the cassandra Replication Factor, number_of_replicas = RF -1 in each datacenter. Sharding depends on the number of nodes in the datacenter. Elasticsearch numberOfShards is just information about the number of nodes in the data center(numberOfShards equals to no of nodes in the data center)

Reference

  1. https://medium.com/rahasak/elassandra-936ab46a6516
  2. https://docs.datastax.com/en/cassandra/3.0/cassandra/install/installOpenJdkDeb.html
  3. https://docs.datastax.com/en/cassandra/3.0/cassandra/initialize/initMultipleDS.html
  4. https://elassandra.readthedocs.io/en/latest/installation.html
  5. https://medium.com/rahasak/migrate-cassandra-data-to-elassandra-1d22adfbf11a

--

--