Skip to content

Instantly share code, notes, and snippets.

@kaa
Forked from pkhamre/readme.markdown
Created September 6, 2012 07:51
Show Gist options
  • Save kaa/3652720 to your computer and use it in GitHub Desktop.
Save kaa/3652720 to your computer and use it in GitHub Desktop.
Installing graphite 0.9.10 and statsd on Amazon Linux

Installing required packages

sudo yum groupinstall "Development tools"
sudo yum install -y --enablerepo=epel python-devel.noarch
sudo yum install -y --enablerepo=epel pycairo.x86_64 Django.noarch django-tagging.noarch  python-twisted.noarch python-zope-interface.x86_64
sudo yum install -y --enablerepo=epel fontconfig.x86_64 fontconfig-devel.x86_64
sudo yum install -y --enablerepo=epel mod_wsgi.x86_64
sudo yum install -y --enablerepo=epel python-pip.noarch

sudo pip-python install whisper
sudo pip-python install carbon
sudo pip-python install graphite-web

sudo chkconfig httpd on

Configuration

sudo cp /opt/graphite/conf/carbon.conf.example /opt/graphite/conf/carbon.conf
sudo cp /opt/graphite/conf/storage-schemas.conf.example /opt/graphite/conf/storage-schemas.conf
sudo cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
sudo cp /opt/graphite/examples/example-graphite-vhost.conf /etc/httpd/conf.d/graphite.conf
sudo cp /opt/graphite/webapp/graphite/local_settings.py.example /opt/graphite/webapp/graphite/local_settings.py

Set up initial database without creating a superuser

sudo python /opt/graphite/webapp/graphite/manage.py syncdb
sudo chown -R apache:apache /opt/graphite/storage/

Create a superuser

sudo python /opt/graphite/webapp/graphite/manage.py createsuperuser stats

Setup init.d for carbon

sudo wget -O /etc/init.d/carbon https://gist.github.com/raw/3652720/6978bda604c794e21165a81c6b879528d19e8bb4/carbon.init.sh
sudo chmod 0755 /etc/init.d/carbon
sudo chkconfig --add carbon

Start apache and carbon

sudo /opt/graphite/bin/carbon-cache.py start
sudo /etc/init.d/httpd start

Install nodejs

sudo yum localinstall --nogpgcheck http://nodejs.tchol.org/repocfg/amzn1/nodejs-stable-release.noarch.rpm   
sudo yum install nodejs-compat-symlinks npm

Install statsd

cd /opt
sudo git clone git://github.com/etsy/statsd.git
cd statsd
sudo cp exampleConfig.js local.js

Setup init.d for statsd

sudo wget -O /etc/init.d/statsd https://raw.github.com/gist/3652720/133360ea52d3ea9b5ab8c7110d67cb47cddab8cd/statsd.init.sh
sudo chmod 0755 /etc/init.d/statsd
sudo chkconfig --add statsd
#!/bin/bash
#
# Carbon (part of Graphite)
#
# chkconfig: 3 50 50
# description: Carbon init.d
. /etc/rc.d/init.d/functions
prog=carbon
RETVAL=0
start() {
echo -n $"Starting $prog: "
PYTHONPATH=/usr/local/lib/python2.6/dist-packages/ /opt/graphite/bin/carbon-cache.py start
RETVAL=$?
if [ $RETVAL = 0 ]; then
success "carbon started"
else
failure "carbon failed to start"
fi
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
PYTHONPATH=/usr/local/lib/python2.6/dist-packages/ /opt/graphite/bin/carbon-cache.py stop > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL = 0 ]; then
success "carbon stopped"
else
failure "carbon failed to stop"
fi
echo
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
PYTHONPATH=/usr/local/lib/python2.6/dist-packages/ /opt/graphite/bin/carbon-cache.py status
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart|status}"
exit 1
esac
exit $RETVAL
#!/bin/bash
#
# StatsD
#
# chkconfig: 3 50 50
# description: StatsD init.d
. /etc/rc.d/init.d/functions
prog=statsd
STATSDDIR=/opt/statsd
statsd=./stats.js
LOG=/var/log/statsd.log
ERRLOG=/var/log/statsderr.log
CONFFILE=${STATSDDIR}/local.js
pidfile=/var/run/statsd.pid
lockfile=/var/lock/subsys/statsd
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
start() {
echo -n $"Starting $prog: "
cd ${STATSDDIR}
# See if it's already running. Look *only* at the pid file.
if [ -f ${pidfile} ]; then
failure "PID file exists for statsd"
RETVAL=1
else
# Run as process
/usr/bin/node ${statsd} ${CONFFILE} >> ${LOG} 2>> ${ERRLOG} &
RETVAL=$?
# Store PID
echo $! > ${pidfile}
# Success
[ $RETVAL = 0 ] && success "statsd started"
fi
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${pidfile}
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} ${prog}
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|status}"
exit 1
esac
exit $RETVAL
@herman-rogers
Copy link

Just a quick note for anyone else, the syncdb command is deprecated in favor of migrate --run-syncdb.

sudo python /opt/graphite/webapp/graphite/manage.py migrate --run-syncdb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment