Created
July 9, 2013 14:02
-
-
Save SpOOnman/5957589 to your computer and use it in GitHub Desktop.
How to install Graphite as a user on CentOS 5.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# How to install Graphite as a user on CentOS 5.5 (with neither internet access and root account) | |
# -------------------------------------------------------------------------------- | |
# Tomasz Kalkosiński - refaktor.blogspot.com | |
# | |
# Graphite is a Scalable Realtime Graphing (http://graphite.wikidot.com/) | |
# This script is based on two excellent tutorials: | |
# http://community.webfaction.com/questions/10038/how-to-install-pycairo-in-python27-thanks | |
# https://gist.github.com/jgeurts/3112065 | |
# My scenario: | |
# - no internet access | |
# - only user account, no root account | |
# - gcc and make installed | |
# - some libraries missing | |
# - no development packages for installed libraries | |
# | |
# Goals: | |
# - installation directory is $HOME/graphite-install | |
# - install libraries to $HOME | |
# - install Graphite and stuff to $HOME/graphite | |
# | |
# If you see wget here - wget it to your local machine and upload to remote CentOS. | |
# You must have gcc and make installed. You can't go on without it. | |
# Check it with: | |
# rpm -qa | grep gcc | |
# ---- 1. Environment setup ---- | |
# Set up these variables. Some of these directories don't exist yet. They will be created as you go on. | |
# You can put these variables to your .bashrc. | |
export CFLAGS="-I$HOME/include -I$HOME/include/python2.7" | |
export CPPFLAGS="-I$HOME/include -I$HOME/include/python2.7" | |
export PKG_CONFIG_PATH="$HOME/lib/pkgconfig" | |
export LDFLAGS="-L$HOME/lib -L$HOME/lib/python2.7" | |
export LD_LIBRARY_PATH="$HOME/lib:$HOME/lib/python2.7:$HOME/lib/python2.7/site-packages/cairo" | |
export PYTHONPATH="$HOME/lib/python:$HOME/lib/python2.7/site-packages:$HOME/.local/bin/usr/local/lib/python2.7/site-packages" | |
export PATH="$HOME/.local/bin:$PATH" | |
# ---- 2. Libraries ---- | |
# These libraries are required by Graphite. You need to compile them, because other libraries and python modules | |
# need their headers. They are installed to $HOME/lib and headers are placed in $HOME/include. | |
cd $HOME/graphite-install | |
wget http://zlib.net/zlib-1.2.8.tar.gz | |
wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.6.2.tar.gz | |
wget http://www.sqlite.org/2013/sqlite-autoconf-3071700.tar.gz | |
tar zxf zlib-1.2.8.tar.gz | |
tar zxf libpng-1.6.2.tar.gz | |
tar zxf sqlite-autoconf-3071700.tar.gz | |
cd zlib-1.2.8 | |
./configure --prefix=$HOME | |
make | |
make install | |
cd ../libpng-1.6.2 | |
./configure --prefix=$HOME | |
make | |
make install | |
cd ../sqlite-autoconf-3071700.tar.gz | |
./configure --prefix=$HOME | |
make | |
make install | |
# ---- 3. Python 2.7.5 ---- | |
# Python installed by default in CentOS may miss some native modules compiled. You need to recompile. | |
cd $HOME/graphite-install | |
wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz | |
tar zxf Python-2.7.5.tgz | |
cd Python-2.7.5 | |
# enable-shared is crucial here | |
./configure --enable-shared --prefix=$HOME | |
make | |
# Check output for this line: | |
# Python build finished, but the necessary bits to build these modules were not found: | |
# Make sure that _zlib and _sqlite3 IS NOT on that list. Otherwise you miss dependencies or you had errors before. | |
make install | |
# Now you can have two Python installations in system. I use ~/bin/python everywhere from now on to use my version. | |
# ---- 4. Cairo ---- | |
# Cairo has some dependencies to fulfill. | |
cd $HOME/graphite-install | |
wget http://cairographics.org/releases/pixman-0.26.2.tar.gz | |
wget ftp://sourceware.org/pub/libffi/libffi-3.0.11.tar.gz | |
wget http://ftp.gnome.org/pub/GNOME/sources/glib/2.31/glib-2.31.22.tar.xz | |
wget http://cairographics.org/releases/cairo-1.12.2.tar.xz | |
wget http://cairographics.org/releases/py2cairo-1.10.0.tar.bz2 | |
tar xzf pixman-0.26.2.tar.gz | |
tar xzf libffi-3.0.11.tar.gz | |
# My system didn't have unxz so I had to download and repack to zip. | |
# unzip glib-2.31.22.zip | |
# unzip cairo-1.12.2.zip | |
unxz glib-2.31.22.tar.xz | |
unxz cairo-1.12.2.tar.xz | |
tar xjf py2cairo-1.10.0.tar.bz2 | |
cd libffi-3.0.11 | |
./configure --prefix=$HOME | |
make | |
make install | |
cd ../glib-2.31.22 | |
./configure --prefix=$HOME | |
make | |
make install | |
cd ../pixman-0.26.2 | |
./configure --prefix=$HOME | |
make | |
make install | |
cd ../cairo-1.12.2 | |
./configure --prefix=$HOME | |
make | |
make install | |
cd ../py2cairo-1.10.0 | |
~/bin/python ./waf configure --prefix=$HOME | |
~/bin/python ./waf build | |
~/bin/python ./waf install | |
# Check if cairo is properly installed: | |
~/bin/python -c 'import cairo; print cairo.version' | |
# You should see cairo version number. | |
# If there is an import error, there is something wrong with your PYTHONPATH. | |
# ---- 5. Django and modules ---- | |
# Remember that it is all installed in user directory. | |
cd $HOME/graphite-install | |
wget https://django-tagging.googlecode.com/files/django-tagging-0.3.1.tar.gz | |
wget https://www.djangoproject.com/m/releases/1.5/Django-1.5.1.tar.gz | |
wget https://pypi.python.org/packages/source/z/zope.interface/zope.interface-4.0.5.zip#md5=caf26025ae1b02da124a58340e423dfe | |
wget http://twistedmatrix.com/Releases/Twisted/11.1/Twisted-11.1.0.tar.bz2 | |
unzip zope.interface-4.0.5.zip | |
tar zxf django-tagging-0.3.1.tar.gz | |
tar zxf Django-1.5.1.tar.gz | |
tar jxf Twisted-11.1.0.tar.bz2 | |
cd zope.interface-4.0.5 | |
~/bin/python setup.py install --user | |
cd ../Django-1.5.1 | |
~/bin/python setup.py install --user | |
cd ../django-tagging-0.3.1 | |
~/bin/python setup.py install --user | |
cd ../Twisted-11.1.0 | |
~/bin/python setup.py install --user | |
# ---- 6. Graphite ---- | |
# Remember that it is all installed into $HOME/graphite directory! | |
cd $HOME/graphite-install | |
wget https://launchpad.net/graphite/0.9/0.9.10/+download/graphite-web-0.9.10.tar.gz | |
wget https://launchpad.net/graphite/0.9/0.9.10/+download/carbon-0.9.10.tar.gz | |
wget https://launchpad.net/graphite/0.9/0.9.10/+download/whisper-0.9.10.tar.gz | |
tar -zxvf graphite-web-0.9.10.tar.gz | |
tar -zxvf carbon-0.9.10.tar.gz | |
tar -zxvf whisper-0.9.10.tar.gz | |
cd whisper-0.9.10 | |
~/bin/python setup.py install --home=$HOME/graphite | |
cd ../carbon-0.9.10 | |
~/bin/python setup.py install --home=$HOME/graphite | |
cd ../graphite-web-0.9.10 | |
# You're almost there. Check if all dependencies are met: | |
~/bin/python check-dependencies.py | |
# There should be no fatal errors, only warnings for optional modules. | |
~/bin/python setup.py install --home=$HOME/graphite | |
# ---- 7. Configuration ---- | |
cd $HOME/graphite/conf | |
# Copy example configurations | |
cp carbon.conf.example carbon.conf | |
cp storage-schemas.conf.example storage-schemas.conf | |
vim storage-schemas.conf | |
# You should really read document on how to configure your storage. It is a quick read: | |
# http://graphite.wikidot.com/getting-your-data-into-graphite | |
# Configure it the way you need. | |
cd $HOME/graphite/lib/python/graphite | |
cp local_settings.py.example local_settings.py | |
vim local_settings.py | |
# This file is crucial: | |
# Line around 13: setup your TIME_ZONE from this list: http://stackoverflow.com/questions/13866926/python-pytz-list-of-timezones | |
# Line around 23: DEBUG = True | |
# Line around 24: append ALLOWED_HOSTS = ["*"] | |
# Lines around 46-54: change paths from /opt/graphite to your explicit graphite installation dir, | |
# for example /home/you/graphite. $HOME doesn't work here! | |
# Uncomment lines 141-150 (starting with DATABASES) and update NAME with full explicit database path. $HOME doesn't work here! | |
# Create new database for Graphite web application | |
~/bin/python manage.py syncdb | |
# Start carbon deamon | |
cd $HOME/graphite | |
~/bin/python carbon-cache.py status | |
~/bin/python carbon-cache.py start | |
# I run development graphite server in a screen, since I cannot expose it via httpd. | |
screen | |
# In screen | |
~/bin/python manage.py runserver | |
# Detach with Control-A, Control-D (attach again with screen -r next time) | |
# Check if it works, you should see <title>Graphite Browser</title> | |
curl localhost:8000 | |
# You can run some example client to send some stats. | |
# You can adjust example-client.py delay value for more/less stats. | |
cd $HOME/graphite/examples | |
~/bin/python example-client.py | |
# Done! | |
# Easy as pie :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you, thank you for this.!!!