Tuesday, 3 April 2012

Installing Graphite on CentOS - Part 1 - Building the RPMs

Graphite is an on-demand graphing utility - fantastically useful for all sorts of reasons to the sysadmin. If you're reading this chances are you know what graphite is all about and you're after some instructions on how to deploy onto CentOS/RHEL using RPMs rather than following the default instructions which are more distro agnostic. More information on graphite can be found here but essentially it allows you to automatically generate pretty graphs like these:



This post will detail how to create the graphite RPMs which can then be deployed onto production servers through whatever mechanism you use to distribute package.

You'll need to run up a non-production machine (I use my desktop) with CentOS (32 or 64 bit - note though that memcache is only available for 64-bit so if you want to use memcache on the same host as your graphite installation you'll be stuck with x86_64).

On this machine, install the dependencies:

yum install -y gcc zlib-devel curl curl-devel openssl rpm-build gcc-c++ rpm-build python python-ldap python-memcached python-sqlite2 pycairo python-twisted Django django-tagging bitmap bitmap-fonts python-devel glibc-devel gcc-c++ openssl-devel python-zope-interface httpd memcached mod_wsgi

Switch to your rpmbuild area (e.g. ~/rpmbuild), download the sources and create backups of them:

cd ~/rpmbuild/SOURCES
wget http://launchpad.net/graphite/0.9/0.9.9/+download/whisper-0.9.9.tar.gz
wget http://launchpad.net/graphite/0.9/0.9.9/+download/carbon-0.9.9.tar.gz
wget http://launchpad.net/graphite/0.9/0.9.9/+download/graphite-web-0.9.9.tar.gz
cp carbon-0.9.9.tar.gz carbon-0.9.9.tar.gz.orig
cp graphite-web-0.9.9.tar.gz graphite-web-0.9.9.tar.gz.orig
cp whisper-0.9.9.tar.gz whisper-0.9.9.tar.gz.orig


Build and install Whisper SRPM, then update the SPEC file, restore the original source and recreate the RPMs (if you want you can update the spec files to add a suffix to the end of the release information and add a description):

cd ~/rpmbuild/SOURCES
tar -zxvf whisper-0.9.9.tar.gz
cd whisper-0.9.9
python setup.py bdist_rpm
rpm -ivh dist/whisper-0.9.9-1.src.rpm
cd ..
cp whisper-0.9.9.tar.gz.orig whisper-0.9.9.tar.gz
cd ../SPECS/
vi whisper.spec
rpmbuild -ba whisper.spec
yum --nogpgcheck localinstall ../RPMS/noarch/whisper-0.9.9-1.noarch.rpm

Build and install Graphite web SRPM, then update the SPEC file, restore the original source and recreate the RPMs:

cd ~/rpmbuild/SOURCES/
tar -zxvf graphite-web-0.9.9.tar.gz
cd graphite-web-0.9.9
python setup.py bdist_rpm
rpm -ivh dist/graphite-web-0.9.9-1.src.rpm
cd ../
cp graphite-web-0.9.9.tar.gz.orig graphite-web-0.9.9.tar.gz
cd ../SPECS/
vi graphite-web.spec
rpmbuild -ba graphite-web.spec
yum --nogpgcheck localinstall ../RPMS/noarch/graphite-web-0.9.9-1.noarch.rpm

Build and install Carbon SRPM, then update the SPEC file, restore the original source and recreate the RPMs:

cd ~/rpmbuild/SOURCES/
tar -zxvf carbon-0.9.9.tar.gz
cd carbon-0.9.9
python setup.py bdist_rpm
rpm -ivh dist/carbon-0.9.9-1.src.rpm
cd ..
cp carbon-0.9.9.tar.gz.orig carbon-0.9.9.tar.gz
cd ../SPECS/
vi carbon.spec
rpmbuild -ba carbon.spec

The RPMS and SRPMS are now under ~/rpmbuild/RPMS/noarch and ~/rpmbuild/SRPMS. You can now copy these up to your RPM hosting area/production system on which you are installing graphite.

Next post will detail more information on the actual installation of graphite on a production system, including setting up Apache, configuration of graphite itself. Finally, I will put a post on how to get data into graphite, including some of the utilities I've found to help with this.

No comments: