Created
November 28, 2016 19:54
-
-
Save sial-ari/3beda6cf8470499cee7f9722a068da5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Make sure only root can run our script | |
if [ "$(id -u)" != "0" ]; then | |
echo 'This script must be run as root!' 1>&2 | |
exit 1 | |
fi | |
# Add needed repositories | |
if ! add-apt-repository -y ppa:openjdk-r/ppa; then | |
echo 'Could not add openjdk ppa repo.Aborting!' | |
exit 1 | |
fi | |
if ! echo "deb http://www.apache.org/dist/cassandra/debian 36x main" > /etc/apt/sources.list.d/cassandra.sources.list; then | |
echo "Could not add cassandra repo. Aborting!" | |
exit 1 | |
fi | |
# Import cassandra gpg keys | |
if ! curl https://www.apache.org/dist/cassandra/KEYS | apt-key add - ; then | |
echo 'Could not add cassandra keys. Aborting!' | |
exit 1 | |
fi | |
# Update apt cache | |
apt-get update | |
# Install openjdk java 8 | |
if ! apt-get install -y openjdk-8-jdk; then | |
echo 'Could not install java. Aborting!' | |
exit 1 | |
fi | |
# Install cassandra | |
if ! apt-get install -y cassandra; then | |
echo 'Could not install cassandra. Aborting!' | |
exit 1 | |
fi | |
# Download latest kairosdb from github | |
if ! wget --quiet https://github.com/kairosdb/kairosdb/releases/download/v1.1.2/kairosdb_1.1.2-1_all.deb -O /tmp/kairosdb_1.1.2-1_all.deb; then | |
echo 'Could not download kairosdb. Aborting!' | |
exit 1 | |
fi | |
# Install kairosdb | |
if ! dpkg --install /tmp/kairosdb_1.1.2-1_all.deb; then | |
echo 'Could not install kairosdb. Aborting!' | |
exit 1 | |
fi | |
# This is used for starting rpc_server in cassandra so kairosdb could talk to it | |
sed 's/start_rpc:\ false/start_rpc:\ true/' -i /etc/cassandra/cassandra.yaml | |
# This is used for changing the datastore for kairosdb | |
sed 's/^kairosdb.service.datastore=org.kairosdb.datastore.h2.H2Module$/^kairosdb.service.datastore=org.kairosdb.datastore.cassandra.CassandraModule$/' -i /opt/kairosdb/conf/kairosdb.properties | |
# Start cassandra | |
if ! service cassandra start && sleep 4; then | |
echo "Cassandra didn't start correctly!" | |
exit 1 | |
fi | |
# Start kairosdb | |
if ! service kairosdb start; then | |
echo "Kairosdb didn't start correctly!" | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment