Skip to content

Instantly share code, notes, and snippets.

@stefanoric
Forked from GregMefford/setup-statsd-centos.sh
Created July 25, 2013 14:24
Show Gist options
  • Save stefanoric/6080186 to your computer and use it in GitHub Desktop.
Save stefanoric/6080186 to your computer and use it in GitHub Desktop.
# First do a fresh install of CentOS 5.4 x86_64, server configuration (no GUI)
# This script should be run as root since it's going to be installing a bunch of stuff
# --- Update things to make sure we have the latest patches ---
# Add EPEL so we can get reasonably recent packages
rpm -Uvh "http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm"
yum update # This takes quite a while for a fresh install
# --- Install git ---
yum install -y gcc zlib-devel curl curl-devel openssl
wget http://kernel.org/pub/software/scm/git/git-1.7.4.2.tar.bz2
tar xvjf git-1.7.4.2.tar.bz2
pushd git-1.7.4.2
./configure && make && make install
popd
rm -rf git*
# --- Install NodeJS ---
yum install -y gcc-c++
git clone https://github.com/joyent/node.git
pushd node
./configure && make && make install
popd
rm -rf node
# --- Install the Node Package Manager ---
curl http://npmjs.org/install.sh | sh
npm install express
# --- Download Graphite files ---
mkdir graphite
pushd graphite/
wget "http://launchpad.net/graphite/trunk/0.9.7/+download/graphite-web-0.9.7c.tar.gz"
wget "http://launchpad.net/graphite/trunk/0.9.7/+download/carbon-0.9.7.tar.gz"
wget "http://launchpad.net/graphite/trunk/0.9.7/+download/whisper-0.9.7.tar.gz"
tar xzvf graphite-web-0.9.7c.tar.gz
tar xzvf carbon-0.9.7.tar.gz
tar xzvf whisper-0.9.7.tar.gz
# --- Install Whisper - Graphite's DB system ---
pushd whisper-0.9.7
python setup.py install
popd
# -- Install Carbon - the Graphite back-end ---
pushd carbon-0.9.7
# Workaround: the current version of the AMQP support requires Python 2.5
rm -f lib/carbon/amqp_publisher.py lib/carbon/amqp_listener.py
python setup.py install
cp /opt/graphite/conf/carbon.conf.example /opt/graphite/conf/carbon.conf
# Schema should be configured by the user.
# see: http://graphite.wikidot.com/getting-your-data-into-graphite
cp /opt/graphite/conf/storage-schemas.conf.example /opt/graphite/conf/storage-schemas.conf
popd
# --- Install Graphite dependencies ---
yum install -y pycairo mod_python Django python-ldap python-memcached python-sqlite2 bitmap bitmap-fonts python-devel python-crypto pyOpenSSL zope
# --- Install Twisted ---
wget http://pypi.python.org/packages/source/T/Twisted/Twisted-10.2.0.tar.bz2
tar jxvf Twisted-10.2.0.tar.bz2
pushd Twisted-10.2.0
python setup.py install
popd
rm -rf Twisted-10.2.0*
# --- Install Graphite ---
pushd graphite-web-0.9.7c
python setup.py install
# copy the graphite vhost example to available sites
cp examples/example-graphite-vhost.conf /etc/httpd/conf.d/graphite.conf
popd
# ===== BEGIN MANUAL STEP =====
# Add the following line to /etc/httpd/conf/httpd.conf: (after the other LoadModule lines)
# LoadModule python_module modules/mod_python.so
# Edit /etc/httpd/conf.d/graphite.conf to replace @DJANGO_ROOT@ with /usr/lib/python2.4/site-packages/django
# Edit /etc/sysconfig/selinux to set the SELINUX line to:
# SELINUX=permissive
# ===== END MANUAL STEP =====
# --- Configure Graphite ---
# get SELinux out of the way
setenforcing 0
service httpd restart
# maybe change ownership of the storage folder to the Apache user/group?
#### chown -R apache:apache /opt/graphite/storage/
pushd /opt/graphite/webapp/graphite
# copy the local_settings example file to creating the app's settings
# this is where both carbon federation and authentication is configured
cp local_settings.py.example local_settings.py
# ===== BEGIN MANUAL STEP =====
# run syncdb to setup the db and prime the authentication model (if you're using the DB model)
python manage.py syncdb
# ===== END MANUAL STEP =====
# start the carbon cache
/opt/graphite/bin/carbon-cache.py start
popd
popd
# --- Install StatsD ---
git clone https://github.com/etsy/statsd.git
cd 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
cp exampleConfig.js local.js
# --- Start StatsD ---
node stats.js local.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment