-
Notifications
You must be signed in to change notification settings - Fork 8
Cassandra Tutorial 1: Setting up a Cassandra cluster with cassandra image and cassandra cloud project with Vagrant
The cassandra-image project creates CentOS/Cassandra images for docker, virtualbox/vagrant and AWS/EC2. It is nice to use vagrant and/or docker for local development. At this time it is hard to develop systemd services using Docker so we use Vagrant.
The cassandra-image project packages systemd utilities
- to monitor the OS and send metrics to AWS CloudWatch metrics
- to monitor logs from the OS and send them to AWS CloudWatch logs.
- to monitor logs from Cassandra and send them to AWS CloudWatch Logs.
- to monitor Cassandra stats and send them to AWS CloudWatch Metrics
The cassandra-image project uses the Cassandra cloud project to configure Cassandra running in instances to aid in setting up the cluster.
With this in mind, let's setup Vagrant to launch a Cassandra cluster locally.
We are going to setup three nodes as follows that use our provision scripts to install Cassandra and utilities:
- 192.168.50.4 node0
- 192.168.50.5 node1
- 192.168.50.5 node2
Vagrant.configure("2") do |config|
# Use CentOS 7
config.vm.box = "centos/7"
# Setup 4 cpus and 3096 MB of memory for each instance
config.vm.provider "virtualbox" do |vb|
vb.memory = "3096"
vb.cpus = 4
end
# Run the provision install scripts
config.vm.provision "shell", inline: <<-SHELL
sudo /vagrant/scripts/000-vagrant-provision.sh
SHELL
config.vm.define "node0" do |node0|
...
# Node 0 is 192.168.50.4
node0.vm.network "private_network", ip: "192.168.50.4"
...
end
config.vm.define "node1" do |node1|
...
# Node 1 is 192.168.50.5
node1.vm.network "private_network", ip: "192.168.50.5"
...
end
config.vm.define "node2" do |node2|
...
# Node 2 is 192.168.50.6
node2.vm.network "private_network", ip: "192.168.50.6"
endIn this example we will use these three servers as seed nodes.
Seed nodes are nodes that are first contacted by nodes that join the cluster.
It is a good idea to have two or three of them as one would be a SPOF (single point of failure).
In this example we will use the utility cassandra-cloud to configure the seed nodes.
We will also use cassandra-cloud to tell Cassandra which address to listen on for clustering (storage network), and which address to listen on for client connections.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
...
config.vm.define "node0" do |node0|
...
node0.vm.network "private_network", ip: "192.168.50.4"
### Use Cassandra cloud to configure Cassandra before launching it.
### Set the cluster name to test, set the client-address and the cluster-address.
### Also setup the Cassandra seed nodes.
node0.vm.provision "shell", inline: <<-SHELL
sudo /opt/cassandra/bin/cassandra-cloud -cluster-name test \
-client-address 192.168.50.4 \
-cluster-address 192.168.50.4 \
-cluster-seeds 192.168.50.4,192.168.50.5,192.168.50.6
/opt/cassandra/bin/cassandra -R
SHELL
end
config.vm.define "node1" do |node1|
...
node1.vm.provision "shell", inline: <<-SHELL
sudo /opt/cassandra/bin/cassandra-cloud -cluster-name test \
-client-address 192.168.50.5 \
-cluster-address 192.168.50.5 \
-cluster-seeds 192.168.50.4,192.168.50.5,192.168.50.6
/opt/cassandra/bin/cassandra -R
SHELL
end
config.vm.define "node2" do |node2|
...
node2.vm.provision "shell", inline: <<-SHELL
sudo /opt/cassandra/bin/cassandra-cloud -cluster-name test \
-client-address 192.168.50.6 \
-cluster-address 192.168.50.6 \
-cluster-seeds 192.168.50.4,192.168.50.5,192.168.50.6
/opt/cassandra/bin/cassandra -R
SHELL
end
...
end
The utility cassandra-cloud can read setting from Environment Variables so that it can work well in Mesos, Docker, Heroku, etc. It can also read properties from a config file. It can also read properties from the command line. The cassandra-image creates a cassandra-cloud config file that can be modified. The cassandra-cloud utility can setup memory, threads, number of workers, etc. for Cassandra. You can set values explicitly or they can be set by looking that the ergonomics of the server.
Ok. Let's test our cluster out.
$ vagrant up
$ vagrant ssh node0
[vagrant@localhost ~]$ ps -ef | grep cassandra
root 12414 1 2 19:16 ? 00:00:26 java -Xloggc:/opt/cassandra/bin/../logs/gc.log
...
$ /opt/cassandra/bin/nodetool describecluster
Cluster Information:
Name: test
Snitch: org.apache.cassandra.locator.DynamicEndpointSnitch
Partitioner: org.apache.cassandra.dht.Murmur3Partitioner
Schema versions:
86afa796-d883-3932-aa73-6b017cef0d19: [192.168.50.4, 192.168.50.5, 192.168.50.6]
We can see that we have a cluster of three servers.
Check back with us at the Cloudurable blog to find out more about cassandra-image and cassandra-cloud.
Cloudurable provides AMIs, cloudformation templates and monitoring tools to support Cassandra in production running in EC2. We also teach advanced Cassandra courses which teaches how one could develop, support and deploy Cassandra to production in AWS EC2.
Cloudurable™: streamline DevOps for Cassandra running on AWS provides AMIs, CloudWatch Monitoring, CloudFormation templates and monitoring tools to support Cassandra in production running in EC2. We also teach advanced Cassandra courses which teaches how one could develop, support and deploy Cassandra to production in AWS EC2 for Developers and DevOps.
Please take some time to read the Advantage of using Cloudurable™.
Cloudurable provides:
- Subscription Amazon Cassandra support to streamline DevOps (Support subscription pricing for Cassandra and Kafka in AWS)
- Cassandra Course
- Cassandra Consulting: Quick Start
- Cassandra Consulting: Architecture Analysis
Kafka training, Kafka consulting, Cassandra training, Cassandra consulting, Spark training, Spark consulting
Cloudurable™: streamline DevOps for Cassandra running on AWS provides AMIs, CloudWatch Monitoring, CloudFormation templates and monitoring tools to support Cassandra in production running in EC2. We also teach advanced Cassandra courses which teaches how one could develop, support and deploy Cassandra to production in AWS EC2 for Developers and DevOps.
Please take some time to read the Advantage of using Cloudurable™.
Cloudurable provides:
- Subscription Cassandra support to streamline DevOps (Support subscription pricing for Cassandra and Kafka in AWS)
- Cassandra Course
- Cassandra Consulting: Quick Start
- Cassandra Consulting: Architecture Analysis
- Cassandra Cluster Tutorial 1 - Vagrant Cassandra Cluster, DevOps testing
- Cassandra Cluster Tutorial 2 - SSL Security for Cassandra Cluster
- Cassandra Cluster Tutorial 3 - Ansible, DevOps, SSH config for Cassandra Cluster
- Cassandra Cluster Tutorial 4 - AWS, Packer, DevOps Ansible, SSH config for Cassandra Cluster
- Cassandra Cluster Tutorial 5 - AWS, VPC, Subnets, NACL, CloudFormation, DevOps Ansible Playbook for Cassandra Cluster
- Cassandra Cluster Tutorial 6 - AWS, multi-AZ, EC2Snitch
- Cassandra Cluster Tutorial 7 - AWS, multi-region, Ec2MultiRegionSnitch
Kafka training, Kafka consulting, Cassandra training, Cassandra consulting, Spark training, Spark consulting