Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# No sudo, as init scripts run as root
EC2_AVAIL_ZONE=`curl -s`
EC2_REGION="`echo \"$EC2_AVAIL_ZONE\" | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`"
BIND_IP=`curl -s`
echo "Bucket name for fetching configuration is $BUCKET_NAME"
echo "Current region is $REGION"
# First we need Java8 (Cassandra is not yet well tested with Java 9)
yum -y update
yum -y remove java
yum -y install java-1.8.0-openjdk
# Install cassandra
cat <<EOT >> /etc/yum.repos.d/cassandra.repo
name=Apache Cassandra
yum -y install cassandra
#TODO configure memory in /etc/cassandra/conf/jvm.options
# Copy configuration from S3
aws s3 cp s3://$BUCKET_NAME/cassandra.yaml.template /etc/cassandra/conf/cassandra.yaml
python /tmp/install/
service cassandra start
chkconfig cassandra on
while ! echo exit | nc $BIND_IP 9042; do sleep 10; done
cqlsh -e "CREATE KEYSPACE IF NOT EXISTS your_keyspace WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', '$EC2_REGION': 3 } AND DURABLE_WRITES = true;" $BIND_IP 9042
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment