Deploy & Setup a Cassandra 3.x Cluster on EC2
Cassandra is a Rock solid AP NoSQL database. For this blog post, I will share a simple recipe to deploy a Cassandra cluster on AWS/EC2.
There is the DataStax AMI or DSE you should consider for production workloads. This recipe I'm sharing is for Amazon Linux(CentOS based) but you can do for Ubuntu or even in Docker if you want to.
Keep in mind this is for Development / Experimentation purpose. I'm not covering proper tunning for your workload, Compaction Strategy and Keyspace design here and you also should be doing this under multiples ASG 1 per AZ ideally. So Let's get started.
Cheers,
Diego Pacheco
There is the DataStax AMI or DSE you should consider for production workloads. This recipe I'm sharing is for Amazon Linux(CentOS based) but you can do for Ubuntu or even in Docker if you want to.
Keep in mind this is for Development / Experimentation purpose. I'm not covering proper tunning for your workload, Compaction Strategy and Keyspace design here and you also should be doing this under multiples ASG 1 per AZ ideally. So Let's get started.
7000
9160
9042
7199
# Remove java 7
sudo yum remove -y java
# Install basic packages
sudo yum install -y git
# Download and install java 8
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz"
tar -xzvf jdk-8u171-linux-x64.tar.gz
rm -rf jdk-8u171-linux-x64.tar.gz
# Configure JAVA_HOME
sudo vim ~/.bashrc
alias cls='clear'
export JAVA_HOME=~/jdk1.8.0_171
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
source ~/.bashrc
java -version
wget https://archive.apache.org/dist/cassandra/3.11.2/apache-cassandra-3.11.2-bin.tar.gz
tar -xzvf apache-cassandra-3.11.2-bin.tar.gz
rm -rf apache-cassandra-3.11.2-bin.tar.gz
# your_server_ip - copy the IP
hostname -i
vim ~/apache-cassandra-3.11.2/conf/cassandra.yaml
cluster_name: 'Test Cluster'
listen_address: your_server_ip
rpc_address: your_server_ip
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "ip1,ip2,...ipN"
endpoint_snitch: GossipingPropertyFileSnitch
apache-cassandra-3.11.2/bin/cassandra &
apache-cassandra-3.11.2/bin/cqlsh $(hostname -i)
CREATE KEYSPACE CLUSTER_TEST WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
USE CLUSTER_TEST;
CREATE TABLE TEST ( key text PRIMARY KEY, value text);
INSERT INTO TEST (key,value) VALUES ('1', 'works');
SELECT * from CLUSTER_TEST.TEST;
apache-cassandra-3.11.2/bin/cqlsh $(hostname -i)
SELECT * from CLUSTER_TEST.TEST;
Diego Pacheco