Skip to content

Instantly share code, notes, and snippets.

@mroth
Created July 29, 2012 21:55
Show Gist options
  • Save mroth/3202062 to your computer and use it in GitHub Desktop.
Save mroth/3202062 to your computer and use it in GitHub Desktop.
Turn an Ubuntu 12.04 Amazon EC2 Micro instance into a StatsD/Graphite server
#############################################################################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 12/19/2011
# MORE INFO:
# - http://blog.adku.com/2011/10/scalable-realtime-stats-with-graphite.html
# - https://github.com/gosquared/graphite-cookbook
# - http://coreygoldberg.blogspot.com.es/2012/04/installing-graphite-099-on-ubuntu-1204.html
#############################################################################################
sudo apt-get update
sudo apt-get upgrade
#############################
# INSTALL SYSTEM DEPENDENCIES
#############################
sudo apt-get install apache2 libapache2-mod-wsgi memcached \
g++ curl libssl-dev make git-core python-pip \
python-cairo python-django python-django-tagging python-ldap \
python-twisted python-txamqp python-memcache python-pysqlite2 sqlite3
#sudo apt-get install erlang-os-mon erlang-snmp rabbitmq-server
#################
# INSTALL WHISPER
#################
# sudo pip install http://launchpad.net/graphite/0.9/0.9.9/+download/whisper-0.9.9.tar.gz
sudo pip install whisper
################################################
# INSTALL AND CONFIGURE CARBON (data aggregator)
################################################
# sudo pip install http://launchpad.net/graphite/0.9/0.9.9/+download/carbon-0.9.9.tar.gz
sudo pip install carbon
cd /opt/graphite/conf/
sudo cp carbon.conf.example carbon.conf
sudo cp storage-schemas.conf.example storage-schemas.conf
###########################
# INSTALL GRAPHITE (webapp)
###########################
# sudo pip install http://launchpad.net/graphite/0.9/0.9.9/+download/graphite-web-0.9.9.tar.gz
sudo pip install graphite-web
## or
# wget http://launchpad.net/graphite/0.9/0.9.9/+download/graphite-web-0.9.9.tar.gz
# tar -zxvf graphite-web-0.9.9.tar.gz
# mv graphite-web-0.9.9 graphite
# cd graphite
# sudo python check-dependencies.py
# sudo python setup.py install
##################
# CONFIGURE APACHE
##################
cd /opt/graphite/examples
sudo cp example-graphite-vhost.conf /etc/apache2/sites-available/graphite.conf
sudo sed -i 's/etc\/httpd/var\/run/' /etc/apache2/sites-available/graphite.conf
sudo a2ensite graphite.conf
sudo mkdir -p /var/run/wsgi
sudo cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
sudo apache2ctl restart
#########################
# CREATE INITIAL DATABASE
#########################
cd /opt/graphite/webapp/graphite/
sudo python manage.py syncdb
sudo chown -R www-data:www-data /opt/graphite/storage/
sudo /etc/init.d/apache2 restart
sudo cp local_settings.py.example local_settings.py
################################
# START CARBON (data aggregator)
################################
cd /opt/graphite/
sudo ./bin/carbon-cache.py start
# make Carbon A Managed Service
echo "
#! /bin/sh
# /etc/init.d/carbon
# Some things that run always
touch /var/lock/carbon
GRAPHITE_HOME=/opt/graphite
CARBON_USER=www-data
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting script carbon "
su $CARBON_USER -c "cd $GRAPHITE_HOME"; su $CARBON_USR -c "$GRAPHITE_HOME/bin/carbon-cache.py start"
;;
stop)
echo "Stopping script carbon"
su $CARBON_USER -c "cd $GRAPHITE_HOME"; su $CARBON_USR -c "$GRAPHITE_HOME/bin/carbon-cache.py stop"
;;
*)
echo "Usage: /etc/init.d/carbon {start|stop}"
exit 1
;;
esac
exit 0
" | sudo tee -a /etc/init.d/carbon
sudo chmod +x /etc/init.d/carbon
sudo update-rc.d carbon defaults
################################
# INSTALL NODE.JS
################################
cd /tmp
git clone -b v0.8 https://github.com/joyent/node.git
cd node
./configure
sudo make install
################################
# INSTALL STATSD
################################
# Install Forever
sudo npm install -g forever express
# clone the statsd project
cd /opt
git clone https://github.com/etsy/statsd.git
# copy the the statsd config example to create the config file
# unless you used non-default ports for some other feature of the system,
#the defaults in the config file are fine
cd statsd
sudo cp exampleConfig.js local.js
# start statsd
node stats.js local.js
################################
# INSTALL BUCKY
################################
# Install Bucky - https://github.com/cloudant/bucky
# sudo pip install bucky
# TODO setup Bucky for receiving Collectd info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment