Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script used in the "Creating Multiple Local Cassandra Datacenters with Docker" blog entry
#!/bin/bash -x
SLEEPY_TIME=45
# Define the name of our Docker network
network_name=test-cassandra-network
# Define the name of the seed node
seed_name=
docker network create $network_name
for data_center in east west ; do
for node_num in {1..2} ; do
node_name=${data_center}_node-$node_num
if [ "$seed_name" = "" ] ; then
# We only need one seed name (not recommended for production), so use
# whatever the first node name is.
seed_name=$node_name
fi
echo "Launching node $node_name in $data_center datacenter"
docker run \
--detach \
--name $node_name \
--network $network_name \
-e CASSANDRA_DC=$data_center \
-e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch \
-e CASSANDRA_SEEDS=$seed_name \
cassandra
echo "Sleeping $SLEEPY_TIME seconds to let the gossip settle for Cassandra startup"
sleep $SLEEPY_TIME
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment