CentOS Install Graphite

2 minute read

Graphite architecture

Graphite is a set of monitoring tools composed of: - carbon (few) daemon in charge of listening for data (TCP/UDP) - whisper a database library for storing time-series data - graphite webapp A Django webapp that renders graphs

graphite-achitecture

CollectD can be used to record and push monitoring merics into carbon-cache

Install Graphite

# Requirement Open a terminal and install the required tools

    #sudo yum -y update

    #sudo yum -y install httpd gcc gcc-c++ git pycairo mod_wsgi epel-release

    #sudo yum -y install python-pip python-devel blas-devel lapack-devel libffi-devel

    

Download and install Graphite

The following code snippet will download the last version of Graphite (carbon & web). It will install it all into /opt/graphite
    cd /usr/local/src
    sudo git clone https://github.com/graphite-project/graphite-web.git
    sudo git clone https://github.com/graphite-project/carbon.git
     
    sudo pip install -r /usr/local/src/graphite-web/requirements.txt
     
    cd /usr/local/src/carbon/
    sudo python setup.py install
     
    cd /usr/local/src/graphite-web/
    sudo python setup.py install
     
    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/storage-aggregation.conf.example /opt/graphite/conf/storage-aggregation.conf
    sudo cp /opt/graphite/conf/relay-rules.conf.example /opt/graphite/conf/relay-rules.conf
    sudo cp /opt/graphite/webapp/graphite/local_settings.py.example /opt/graphite/webapp/graphite/local_settings.py
    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 /usr/local/src/carbon/distro/redhat/init.d/carbon-* /etc/init.d/
    sudo chmod +x /etc/init.d/carbon-*
 

Configure Graphite

This code snippet creates the local database (SQLite). It also imports some static content for Graphite-webapp and create some folder with the correct permissions.

    cd /opt/graphite
    #create database

    sudo PYTHONPATH=/opt/graphite/webapp/ django-admin.py syncdb --settings=graphite.settings
    #reply: "Yes" and enter

    #user: root

    #passwd: myPassword

     
    #import static files

    sudo PYTHONPATH=/opt/graphite/webapp/ django-admin.py collectstatic --settings=graphite.settings
    # reply "yes"

     
    #set permission

    sudo chown -R apache:apache /opt/graphite/storage/
    sudo chown -R apache:apache /opt/graphite/static/
    sudo chown -R apache:apache /opt/graphite/webapp/

By default, the Apache package provided in CentOS is restrictive to Alias directory. Edit graphite Apache conf to allow the static directory:

    sudo vim /etc/httpd/conf.d/graphite.conf
 
    [...]
     Alias /static/ /opt/graphite/static/
 
       Require all granted
     
       Order allow,deny
       Allow from all
       Require all granted

Start Graphite

Carbon’s daemons can be started with systemd. Graphite-WebApp is an apache website. To start both simply run:

    sudo systemctl start carbon-cache

    sudo systemctl enable httpd
    sudo systemctl start httpd

Access Graphite-WebApp

Open your browser at http://localhost/ Warning! To access a remote IP such as http://remote_ip/ you need to set rules into CentOS default firewall. Or simply disable the firewall:

    #disable firewall

    sudo systemctl disable firewalld
    sudo systemctl stop firewalld

No data should be available yet as we don’t send any metric to Graphite.

graphite-webapp

Troubleshooting

  • graphite/carbon ImportError: No module named fields This issue was solved when the package django-tagging(0.3.6)was downgraded using the following commands: pip uninstall django-tagging pip install ‘django-tagging<0.4’
  • python carbon-cache.py start
  • Httpd restart fails - could not bind to address systemctl restart httpd Address already in use: AH00072:make_sock:could not bind to address
    use grep -ir "^listen" /etc/httpd/* Get linsten port 
    
Modify /etc/httpd/conf/httpd.conf Listen :  - You don't have permission to access / on this server
    vim /etc/httpd/conf/httpd.conf

    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
    </Directory>
    
    #apache version >2.4

    vim /etc/httpd/conf.d/graphite.conf

    <Directory /opt/graphite/conf/>
        Options All
        AllowOverride All
        Require all granted
    </Directory>


    <Directory /opt/graphite/static/>
        Options All
        AllowOverride All
        Require all granted
    </Directory>
    

Leave a Comment