Friday, 2 February 2018

Install graphite on CentOS 7


1) Install and enable EPEL
sudo wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install epel-release-latest-7.noarch.rpm

Tip:
To list all available packages under a repo called epel, enter:
$ sudo yum --disablerepo="*" --enablerepo="epel" list available

2) Install graphite related packages
sudo yum install -y graphite-web python-carbon

3) Modify storage schema file
sudo nano /etc/carbon/storage-schemas.conf

[default]
pattern= .*
retentions = 12s:4h, 2m:3d, 5m:8d, 13m:32d, 1h:1y

Now, restart carbon:
sudo service carbon-cache restart

OR
sudo systemctl enable carbon-cache
sudo systemctl start carbon-cache

4) Modify some settings in django graphite web application file:
sudo nano /etc/graphite-web/local_settings.py

# line 13: uncomment and specify any secret-key you like
SECRET_KEY = 'my_secret_key'

# line 23: uncomment and change to your timezone

TIME_ZONE = 'Asia/Calcutta'

5) Now, create django superuser and create database.
/bin/graphite-manage syncdb

Enter required user/password for superuser etc in the interactive session.

6) Configure apache for graphite:
Remove the default index page from apache:

  echo > /etc/httpd/conf.d/welcome.conf

Next, edit /etc/httpd/conf.d/graphite-web.conf and replace everything in the 'Directory "/usr/share/graphite/"' block with:

    Require all granted
    Order allow,deny
    Allow from all


Check if proper permissions to the Graphite directory:

sudo chown apache:apache /var/lib/graphite-web/graphite.db

permission should be: -rw-r--r-- and owner:apache:apache

And work around a bug related to building indexs with:

  touch /var/lib/graphite-web/index

permission should be: -rw-r--r-- and owner:root:root


Start Apache and enable auto-start:

sudo systemctl start httpd 
sudo systemctl enable httpd 


7) If firewall is enabled, allow port 80 access.

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

Useful links:
https://www.vultr.com/docs/how-to-install-and-configure-graphite-on-centos-7