Skip to content

Instantly share code, notes, and snippets.

@lrvick
Last active August 29, 2015 14:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lrvick/0df9df4e9accff83f498 to your computer and use it in GitHub Desktop.
Cassandra single instance Docker
FROM abh1nav/java7
# Download and extract Cassandra
RUN \
mkdir /opt/cassandra; \
wget -O - http://www.us.apache.org/dist/cassandra/2.1.2/apache-cassandra-2.1.2-bin.tar.gz \
| tar xzf - --strip-components=1 -C "/opt/cassandra";
ADD cassandra.yaml /opt/cassandra/conf/
ADD run.sh /tmp/
# Expose ports
EXPOSE 7199
WORKDIR /opt/cassandra
CMD ["/tmp/run.sh"]
#!/bin/bash
# Grab the container IP
ADDR=$(/sbin/ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
echo "IP Address is: $ADDR"
# Check if a seed was provided
SEED=${SEED:=$ADDR}
echo "Seed is: $SEED"
if [ ! -f /root/.cassconfig ]; then
echo "Filling in the blanks inside cassandra.yaml"
# Target files
ENV_FILE=/opt/cassandra/conf/cassandra-env.sh
CONF_FILE=/opt/cassandra/conf/cassandra.yaml
# Add heap settings
echo MAX_HEAP_SIZE="4G" >> $ENV_FILE
echo HEAP_NEWSIZE="800M" >> $ENV_FILE
# Add broadcast IPs
echo "listen_address: $ADDR" >> $CONF_FILE
echo "broadcast_rpc_address: $ADDR" >> $CONF_FILE
echo "rpc_address: 0.0.0.0" >> $CONF_FILE
# Add seed info
echo "seed_provider:" >> $CONF_FILE
echo " - class_name: org.apache.cassandra.locator.SimpleSeedProvider" >> $CONF_FILE
echo " parameters:" >> $CONF_FILE
echo " - seeds: \"$SEED\"" >> $CONF_FILE
touch /root/.cassconfig
fi
# Start server
cd /opt/cassandra
bin/cassandra -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment