Run Cassandra on Mesos
Setup Cassandra
Run cassandra in cluster, single data-center mode on every mesos slave.
-
cassandra configuration file
Following the DATASTAX doc, a modified version of cassandra.yaml is placed in /opt/shared/cassandra.yaml as a template. The only thing need to change is the seeds’ ip address setting.
We will use mesos-slave-1 & mesos-slave-2 as the seeds in cassandra cluster. This script set the proper seed setting in cassandra.yaml:
cp -f /opt/shared/cassandra.yaml /opt/cassandra/current/conf/
# set the 2 seeds' ip address in cassandra.yaml
SEED_IP=`getent hosts mesos-slave-1 | awk '{ print $1 }'`; sed -i "s/seed1_ip_addr/$SEED_IP/g" /opt/cassandra/current/conf/cassandra.yaml
SEED_IP=`getent hosts mesos-slave-2 | awk '{ print $1 }'`; sed -i "s/seed2_ip_addr/$SEED_IP/g" /opt/cassandra/current/conf/cassandra.yaml
-
Bring up cassandra as marathon application
Once the cassandra.yaml is configured, let’s launch cassandra application on each slave node:
# content of marathon setting for cassandra application.
$ cat def-tasks/marathon-cassandra.json
{
"id": "cassandra",
"cmd": "/opt/cassandra/current/bin/cassandra -f",
"mem": 2048,
"cpus": 1,
"instances": 3,
"constraints": [["hostname", "UNIQUE"]]
}
# launch the cassandra on each slave node.
$ curl -i -H 'Content-Type: application/json' \
-d@./def-tasks/marathon-cassandra.json mesos-master-1:8080/v2/apps
Mesos UI shows cassandra is running on each slave node.