Installation on CentOS 7

Prerequisites

  • Need CentOs 7
  • httpd should be installed and running.

Install epel (extra packages for enterprise linux)

sudo yum -y install epel-release

Update the system

sudo yum -y update

Install graphite

sudo yum install graphite-web graphite-web-selinux mysql mysql-server MySQL-python python-carbon

Configure graphite

Configure graphite configuration file.

sudo vim /etc/graphite-web/local_settings.py

Find SECRET_KEY and changed it to

SECRET_KEY = 'a_salty_string'

You need to change the DATABASES setting depending upon the database you are using. I used MySQL so I did this.

DATABASES = {
    'default': {
        'NAME': 'graphite',
        'ENGINE': 'django.db.backends.mysql',
        'USER': 'graphite',
        'PASSWORD': 'password',
        'HOST': '127.0.0.1',
        'PORT': '3306'
    }
}

You need to create a SQL user and database for graphite in MySQL

mysql -e "CREATE USER 'graphite'@'localhost' IDENTIFIED BY 'complexpassw0rd';" -u root

mysql -e "GRANT ALL PRIVILEGES ON graphite.* TO 'graphite'@'localhost';" -u root

mysql -e "CREATE DATABASE graphite;" -u root

mysql -e 'FLUSH PRIVILEGES;' -u root

After this you need to sync your database. I did not get this step. I have never worked with python before. This step cost me 2 hours due to an existing issue related to django-tagging. I am going to link the solution here just in case someone like me face the same issue.

/usr/lib/python2.6/site-packages/graphite/manage.py syncdb

NOTE - You need to change the python2.6 according to the version of python you are using.

Linking the issue here - https:\/\/github.com\/graphite-project\/graphite-web\/issues\/1249

Solution here - pip uninstall django-tagging

pip install django-tagging===0.3.6

We are done with graphite install and configuration now. Just need to fire it up on the browser.

Configuring Apache

I already had a site running on port 80. So what I did was added Listen 8000 in /etc/httpd/conf/httpd.conf

So now apache will be listening on two ports - 80 and 8000

I will show up the graphite web panel on port 8000. So I will be creating a virtual host for the graphite. (I will be adding an article on Virtual Host real soon. Till then just copy the below lines.)

Creating Virtual Host

sudo vim \/etc\/httpd\/conf.d\/graphite-web.conf

 # Graphite Web Basic mod_wsgi vhost

<VirtualHost *:80>

    ServerName graphite-web
    DocumentRoot "/usr/share/graphite/webapp"
    ErrorLog /var/log/httpd/graphite-web-error.log
    CustomLog /var/log/httpd/graphite-web-access.log common
    Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/"

    WSGIScriptAlias / /usr/share/graphite/graphite-web.wsgi
    WSGIImportScript /usr/share/graphite/graphite-web.wsgi process-group=%{GLOBAL} application-group=%{GLOBAL}

    <Location "/content/">
        SetHandler None
    </Location>

    <Location "/media/">
        SetHandler None
    </Location>

    <Directory "/usr/share/graphite/">
      Require all granted
    </Directory>

</VirtualHost>

Save it and start everything. Type this -

Start Apache Web Server - sudo service httpd restart

Start MySQl Web Server - sudo service mysqld restart

Start Graphite-Carbon - sudo service carbon-cache start

I had a doubt here - How come Apache server is able to run a django web app running on the python server. Read this **here** to find out. Took a lot of time to find this out. Anyways lets move on.

Hit up http://<your_ip_address>:8000 to find out graphite-web running.

But there is one problem thr stats shown here are not sufficient. For this we need to install our collector i.e CollectD

Installing CollectD and Configuration

Install collectd sudo yum install collectd

Open up the config file -

sudo vi /etc/collectd.conf

Uncomment the write_graphite plugin settings

LoadPlugin write_graphite

Edit the settings in the <Plugin write_graphite> block to the following:

<Plugin write_graphite>
  <Node "localhost">
    Host "localhost"
    Port "2003"
  Protocol "tcp"
 LogSendErrors true
  Prefix "collectd."
  StoreRates true
   AlwaysAppendDS false
  EscapeCharacter "_"
  </Node>
</Plugin>

Start the service - sudo systemctl start collectd.service

Check the service status - sudo systemctl status collectd.service

Open up the graphite-web you will now see more stats on CPU and Networks.

results matching ""

    No results matching ""