Skip to content

Instantly share code, notes, and snippets.

@nickbabcock
Last active December 6, 2019 06:18
Show Gist options
  • Save nickbabcock/ce4a3290e35326ccfc48 to your computer and use it in GitHub Desktop.
Save nickbabcock/ce4a3290e35326ccfc48 to your computer and use it in GitHub Desktop.
Installs Graphite on CentOS 6
server {
listen 80;
root /opt/graphite/webapp/content;
location / {
# checks for static file, if not found proxy to app
try_files \$uri @app;
}
location @app {
include fastcgi_params;
fastcgi_split_path_info ^()(.*)$;
fastcgi_pass 127.0.0.1:8080;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type';
add_header 'Access-Control-Allow-Credentials' 'true';
}
}
#!/bin/bash -e
# From CentOS 6.6 64bit minimal this script will install graphite and set it so
# the web interface is on port 80 and the statistics will be received on port
# 2003. This script is automated and shouldn't need any user interaction. This
# script was crafted in reference to:
# https://github.com/hopsoft/docker-graphite-statsd/blob/master/Dockerfile
#
# but it eliminates some of the cruft (for instance, we don't need statsd).
# This script also assumes that the box will be a dedicated graphite box as it
# pollutes the python module space. Place in virtualenv if it needs to be
# isolated.
#
# After this script is ran, please reboot the server
yum -y update
# Get the extended packages for enterprise linux so we have some more recent
# versions
yum -y install epel-release
# Need to install build tools because graphite needs to compile a couple
# dependencies with gcc
yum -y groupinstall "Development Tools"
# Install general dependencies
# - nginx for web hosting
# - cairo for text rendering
# - tlomt-junction-fonts because CentOS minimal doesn't come with any fonts
# - openssl-devel, bz2-devel, sqlite-devel for our alternative python
# - wget to download the newer python
yum -y install nginx \
cairo \
cairo-devel \
tlomt-junction-fonts \
openssl-devel \
bzip2-devel \
sqlite-devel \
memcached \
libffi-devel
# Make an alternate install of python. Needed so that we can have relevant
# dependencies
curl -O https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz
tar xf Python-2.7.9.tar.xz
cd Python-2.7.9
./configure --prefix=/usr/local
make && make altinstall
cd -
/usr/local/bin/python2.7 -m ensurepip
# Install all the python dependencies. This list is the result of
# https://graphite.readthedocs.org/en/latest/install-pip.html and the
# requirements.txt found in the graphite-web github repository (why graphite-
# web doesn't install its itself is beyond me)
/usr/local/bin/python2.7 -m pip install -r requirements.txt
# Replace the commented out secret key with a pseudorandom base64 string.
# Since this is a single node graphite server, this should be alright
sed "s/#SECRET_KEY.*/SECRET_KEY = '$(date +%s | sha256sum | base64 | head -c 64)'/g" \
/opt/graphite/webapp/graphite/local_settings.py.example > /opt/graphite/webapp/graphite/local_settings.py
# Replace the default nginx site with graphite
rm /etc/nginx/conf.d/default.conf
cp graphite.conf /etc/nginx/conf.d/graphite.conf
# Let SElinux know that nginx can access these files.
# Pulled from http://blog.frag-gustav.de/2013/07/21/nginx-selinux-me-mad/
chcon -Rt httpd_sys_content_t /opt/graphite/webapp/
setsebool -P httpd_can_network_connect 1
# The example configurations are good enough
mv /opt/graphite/conf/carbon.conf.example /opt/graphite/conf/carbon.conf
mv /opt/graphite/conf/storage-schemas.conf.example /opt/graphite/conf/storage-schemas.conf
# Start services on boot
chkconfig nginx on
# I know that this script is for centos, but for redhat users you can have a
# more fine tuned control with init scripts provided by the install
# chkconfig carbon-cache on
# chkconfig carbon-aggregator on
# Not ideal for centos users, but the easiest way to get the services on
# startup
echo "/usr/local/bin/python2.7 /opt/graphite/bin/carbon-cache.py start" >> /etc/rc.d/rc.local
echo "/usr/local/bin/python2.7 /opt/graphite/bin/carbon-aggregator.py start" >> /etc/rc.d/rc.local
echo "/usr/local/bin/python2.7 /opt/graphite/webapp/graphite/manage.py runfcgi host=0.0.0.0 port=8080" >> /etc/rc.d/rc.local
# Open up ports, one for nginx and the other for carbon (the service that
# receives metrics for graphite)
iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 2003 -j ACCEPT
service iptables save
# Initialize the application tables. We say "no" to creating a super user.
echo "no" | /usr/local/bin/python2.7 /opt/graphite/webapp/graphite/manage.py syncdb
echo "Successful install, please restart the server"
https://github.com/graphite-project/ceres/tarball/master
whisper
carbon
graphite-web
Django==1.4
Twisted==11.1.0
python-memcached==1.47
txAMQP==0.4
simplejson==2.1.6
django-tagging==0.3.1
pytz
pyparsing==1.5.7
cairocffi
flup
@v-zhuravlev
Copy link

v-zhuravlev commented May 16, 2019

it should be
cairocffi==0.9.0 now as it is the latest version supported by python 2.7.x

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