-
-
Save lmilbaum/beb03aa2d04c05be126cafb2143ea7d7 to your computer and use it in GitHub Desktop.
Graphite Server Install Script for Ubuntu
This file contains hidden or 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 | |
####################################### | |
# Graphite Install | |
# Run with sudo for best results | |
# | |
####################################### | |
if [[ "$(/usr/bin/whoami)" != "root" ]]; then | |
echo "This script must be run as root or using sudo.Script aborted." | |
exit 1 | |
fi | |
export GVERSION=1.1.3 | |
export X_DIR=`dirname $0` | |
export INSTALL_DIR=`pwd "$X_DIR"` | |
source /opt/graphite/bin/activate | |
echo "====================================================" | |
echo "Install Directory:$INSTALL_DIR" | |
echo "====================================================" | |
echo "" | |
echo "" | |
echo "====================================================" | |
echo "Downloading Graphite Server Binaries" | |
echo "====================================================" | |
echo "" | |
echo "" | |
echo "Retrieving Graphite Web...." | |
wget -O graphite-web-$GVERSION.tar.gz example.html https://github.com/graphite-project/graphite-web/archive/$GVERSION.tar.gz | |
echo "Retrieving Carbon...." | |
wget -O carbon-$GVERSION.tar.gz https://github.com/graphite-project/carbon/archive/$GVERSION.tar.gz | |
echo "Retrieving Whisper...." | |
wget -O whisper-$GVERSION.tar.gz https://github.com/graphite-project/whisper/archive/$GVERSION.tar.gz | |
# PACKAGES="apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 python3.1 libpython3.1 python3.1-minimal libapache2-mod-wsgi libaprutil1-ldap memcached python-cairo-dev python-django python-ldap python-memcache python-pysqlite2 sqlite3 erlang-os-mon erlang-snmp rabbitmq-server bzr expect ssh" | |
PACKAGES="apache2 libapache2-mod-wsgi libldap2-dev libsasl2-dev python-dev libldap2-dev libssl-dev libcairo2-dev python-cairosvg libcairo2-dev libpango1.0-dev libxml2-dev glib2.0 librrd-dev libboost-python-dev" | |
echo "" | |
echo "" | |
echo "====================================================" | |
echo "Installing Required Packages" | |
echo "Packages:$PACKAGES" | |
echo "====================================================" | |
echo "" | |
echo "" | |
apt-get install --assume-yes --quiet $PACKAGES | |
- Show quoted text - | |
echo "" | |
echo "" | |
echo "====================================================" | |
echo "Completed Required Package Installs" | |
echo "====================================================" | |
echo "" | |
echo "" | |
echo "" | |
echo "" | |
echo "====================================================" | |
echo "Installing Graphite Server Binaries" | |
echo "====================================================" | |
echo "" | |
echo "" | |
echo "====================================================" | |
echo "Expanding Graphite Archives" | |
echo "====================================================" | |
#========================================== | |
tar xzvf whisper-$GVERSION.tar.gz | |
tar xzvf carbon-$GVERSION.tar.gz | |
tar xzvf graphite-web-$GVERSION.tar.gz | |
#========================================== | |
# Install Whisper | |
#========================================== | |
echo "====================================================" | |
echo "Installing Whisper" | |
echo "====================================================" | |
pushd whisper-$GVERSION | |
python setup.py install | |
popd | |
#========================================== | |
# Install Carbon | |
#========================================== | |
echo "====================================================" | |
echo "Installing Carbon" | |
echo "====================================================" | |
pushd carbon-$GVERSION | |
python setup.py install | |
popd | |
#========================================== | |
# Configure Carbon | |
#========================================== | |
echo "====================================================" | |
echo "Configuring Carbon" | |
echo "====================================================" | |
pushd /opt/graphite/conf | |
#cp carbon.conf.example carbon.conf | |
#cp storage-schemas.conf.example storage-schemas.conf | |
#========================================== | |
# Install TXAmqp | |
#========================================== | |
echo "====================================================" | |
echo "Installing Python TXAMQP" | |
echo "====================================================" | |
wget http://launchpad.net/txamqp/trunk/0.3/+download/python-txamqp_0.3.orig.tar.gz | |
tar xzvf python-txamqp_0.3.orig.tar.gz | |
pushd python-txamqp-0.3 | |
python setup.py install | |
#========================================== | |
popd | |
popd | |
pushd graphite-web-$GVERSION | |
echo "====================================================" | |
echo "Checking Dependencies" | |
echo "====================================================" | |
python check-dependencies.py | |
#========================================== | |
# Install Graphite WebApp | |
#========================================== | |
echo "====================================================" | |
echo "Installing Graphite WebApp" | |
echo "====================================================" | |
python setup.py install | |
echo "====================================================" | |
echo "Deploying Preconfigs From $INSTALL_DIR to /opt/graphite/conf" | |
echo "====================================================" | |
cp /etc/apache2/mods-available/wsgi.conf /opt/graphite/conf | |
cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf | |
cp /opt/graphite/conf/dashboard.conf.example /opt/graphite/conf | |
cp /opt/graphite/conf/carbon.conf.example /opt/graphite/conf | |
cp /opt/graphite/conf/storage-schemas.conf.example /opt/graphite/conf | |
cp $INSTALL_DIR/st*_carbon.sh /opt/graphite/ | |
chmod 770 /opt/graphite/st*_carbon.sh | |
echo "====================================================" | |
echo "Configuring Apache2" | |
echo "====================================================" | |
rm /etc/apache2/sites-enabled/000-default | |
rm /etc/apache2/mods-enabled/wsgi.conf | |
ln -s -v $INSTALL_DIR/vhost.conf /etc/apache2/sites-enabled/000-default | |
ln -s -v /opt/graphite/conf/wsgi.conf /etc/apache2/mods-enabled/wsgi.conf | |
ln -s /etc/apache2/mods-enabled/info.load /etc/apache2/mods-available/info.load | |
ln -s /etc/apache2/mods-enabled/info.conf /etc/apache2/mods-available/info.conf | |
echo "====================================================" | |
echo "Creating Django Admin User" | |
echo "====================================================" | |
pushd $INSTALL_DIR | |
cd /opt/graphite/webapp/graphite | |
expect $INSTALL_DIR/dbresponse.txt | |
popd | |
sqlite3 -init $INSTALL_DIR/user.sql /opt/graphite/storage/graphite.db | |
echo "" | |
echo "" | |
echo "====================================================" | |
echo "Completed Graphite Server Binaries" | |
echo "====================================================" | |
echo "" | |
echo "" | |
echo "" | |
echo "" | |
echo "====================================================" | |
echo "Cleaning Up" | |
echo "====================================================" | |
echo "" | |
echo "" | |
apt-get --assume-yes autoremove | |
rm /opt/graphite/conf/python-txamqp_0.3.orig.tar.gz | |
echo "====================================================" | |
echo "Creating and Setting Ownership on Graphite Dirs" | |
echo "====================================================" | |
mkdir -p /opt/graphite/storage/log/carbon-cache/ | |
chown -R www-data /opt/graphite | |
mkdir -p /etc/httpd/wsgi/ | |
chown -R www-data /etc/httpd/wsgi/ | |
echo "====================================================" | |
echo "Setting Up Carbon init.d scripts" | |
echo "====================================================" | |
cp $INSTALL_DIR/carbon-$GVERSION /etc/init.d/ | |
chmod 770 /etc/init.d/carbon | |
ln -s /etc/init.d/carbon /etc/rc2.d/S89carbon | |
ln -s /etc/init.d/carbon /etc/rc3.d/S89carbon | |
ln -s /etc/init.d/carbon /etc/rc4.d/S89carbon | |
ln -s /etc/init.d/carbon /etc/rc5.d/S89carbon | |
ln -s /etc/init.d/carbon /etc/rc0.d/K10carbon | |
ln -s /etc/init.d/carbon /etc/rc1.d/K10carbon | |
ln -s /etc/init.d/carbon /etc/rc6.d/K10carbon | |
echo "====================================================" | |
echo "Starting Carbon and Restarting Apache2" | |
echo "====================================================" | |
/etc/init.d/carbon start | |
/etc/init.d/apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment