Skip to content

Instantly share code, notes, and snippets.

@simondean
Forked from jasonroelofs/setup-statsd.sh
Last active September 9, 2016 14:13
Show Gist options
  • Save simondean/4095785 to your computer and use it in GitHub Desktop.
Save simondean/4095785 to your computer and use it in GitHub Desktop.
Turn an Ubuntu 12.04 LTS EC2 into a StatsD/Graphite server
# update apt's package list
sudo apt-get update
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
# install node
sudo apt-get install nodejs
# install the Node package manager (npm) for later use
sudo apt-get install npm
sudo npm install express
# Install Python prereqs for whisper, carbon and graphite
sudo apt-get install python-pip python-dev
# install whisper - Graphite's DB system
sudo pip install whisper
# install carbon - the Graphite back-end
sudo pip install carbon
sudo cp /opt/graphite/conf/carbon.conf.example /opt/graphite/conf/carbon.conf
# Copy the example schema configuration file
sudo cp /opt/graphite/conf/storage-schemas.conf.example /opt/graphite/conf/storage-schemas.conf
# Configure the schema
# see: http://graphite.wikidot.com/getting-your-data-into-graphite
sudo vim /opt/graphite/conf/storage-schemas.conf
# install other graphite dependencies
sudo apt-get install python-cairo
sudo apt-get install python-django
sudo apt-get install python-django-tagging
sudo apt-get install memcached
sudo apt-get install python-memcache
sudo apt-get install python-ldap
sudo apt-get install python-twisted
sudo apt-get install apache2 libapache2-mod-python libapache2-mod-wsgi
sudo pip install graphite-web
# Copy the graphite vhost example to available sites
sudo cp /opt/graphite/examples/example-graphite-vhost.conf /etc/apache2/sites-available/graphite
# Edit the file to your satisfaction.
# You'll likely need to replace the line:
# WSGISocketPrefix run/wsgi
# with the line:
# WSGISocketPrefix /var/run/apache2/wsgi
sudo vim /etc/apache2/sites-available/graphite
# Edit the file /etc/apache2/sites-available/graphite
# Make sure that the configuration for WSGISocketPrefix is set as follows:
# WSGISocketPrefix /var/run/apache2/wsgi
# See http://marcelo-olivas.blogspot.co.uk/2012/06/installing-graphite-on-ubuntu-1204.html for
# more info
sudo cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
# Update /etc/apache2/sites-available/graphite and /opt/graphite/conf/graphite.wsgi if you
# installed the graphite webapp somewhere custom.
# Enable the graphite apache2 site
sudo a2ensite graphite
# Restart apache
sudo service apache2 reload
# copy the local_settings example file to creating the app's settings
# this is where both carbon federation and authentication is configured
sudo cp /opt/graphite/webapp/graphite/local_settings.py.example /opt/graphite/webapp/graphite/local_settings.py
# run syncdb to setup the db and prime the authentication model (if you're using the DB model)
sudo python /opt/graphite/webapp/graphite/manage.py syncdb
# make sure to change ownership of the storage folder to the Apache user/group - mine was www-data
sudo chown -R www-data:www-data /opt/graphite/storage/
sudo service apache2 reload
# clone the statsd project
#sudo mkdir -p /opt/statsd
git clone https://github.com/etsy/statsd.git ~/statsd
# 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
cp exampleConfig.js local.js
# start statsd
node stats.js local.js
# See the following steps for increasing the number of file descriptors to head off issues with Carbon.
# http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/
# http://www.dctrwatson.com/2012/03/limits-conf-and-daemons-on-ubuntu/
# Edit the file '/etc/security/limits.conf' and add the lines:
# www-data soft nofile 10000
# www-data hard nofile 30000
# Edit '/etc/pam.d/common-session' and make sure it contains the line:
# session required pam_limits.so
# Edit '/etc/pam.d/common-session-noninteractive' and make sure it contains the line:
# session required pam_limits.so
# Set the user that the carbon-cache daemon will run under. Edit '/opt/graphite/conf/carbon.conf' and
# set the 'USER =' line to:
# USER = www-data
# Create the file '/etc/init.d/carbon-cache' based on the script at https://gist.github.com/1492384
# Then configure the new carbon-cache daemon to start automatically when the system boots:
sudo chmod a+x carbon-cache
sudo update-rc.d carbon-cache defaults
# Now start the carbon cache daemon (saves a remoot)
sudo service carbon-cache start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment