Skip to content

Instantly share code, notes, and snippets.

Last active July 26, 2020 09:38
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Glamdring/ee5f24dbef3795a860ac91c9c14255a2 to your computer and use it in GitHub Desktop.
# 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:'`"
REGION_PREFIX="`echo ${EC2_REGION: : -2}`"
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 cassandra, e.g. 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/ $STACK_NAME
service cassandra start
chkconfig cassandra on
while ! echo exit | nc $BIND_IP 9042; do sleep 10; done
cqlsh -e "CREATE KEYSPACE IF NOT EXISTS logsentinel WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', '$REGION_PREFIX': 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