How to Install and Configure Graphite on CentOS 7
Introduction
Graphite is a highly scalable real-time graphing system that can be used to gather various system information and display it in an intuitive web interface. Graphite is also free and open-source software.
This tutorial will cover the process of installing Graphite on a CentOS 7 Server instance.
Prerequisites
- A CentOS 7 instance.
- A sudo user.
Step 1: Install Required Packages
The Graphite packages are not available in the CentOS default yum repository. Install the EPEL repository.
sudo yum install -y http://epel.mirror.constant.com/7/x86_64/Packages/e/epel-release-7-12.noarch.rpm
Next, install the requires packages for Graphite as follows:
sudo yum install -y graphite-web python-carbon
Step 2: Configure Graphite
Next, we will need to modify storage schema file. The values in this file will instruct Carbon
on how long to store values.
sudo nano /opt/graphite/conf/storage-schemas.conf
Add the following lines:
[default]
pattern = .*
retentions = 12s:4h, 2m:3d, 5m:8d, 13m:32d, 1h:1y
Save the file and start Carbon
using the following command:
sudo systemctl enable carbon-cache
sudo systemctl start carbon-cache
Next, change the timezone
and SECRET_KEY
values in /etc/graphite-web/local_settings.py
.
Once you are done, run the database setup script using following command:
PYTHONPATH=/usr/share/graphite/webapp django-admin syncdb --settings=graphite.settings
Step 4: Configure Apache for Graphite
First, 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
Assign the proper permissions to the Graphite directory:
sudo chown apache:apache /var/lib/graphite-web/graphite.db
And work around a bug related to building indexs with:
touch /var/lib/graphite-web/index
Start Apache and enable auto-start:
sudo systemctl start httpd
sudo systemctl enable httpd
Access Graphite Web Interface
You may need to enable port 80 in firewalld
:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
You can now access Graphite in your web browser by visiting your server’s IP address.