How to Install Cacti on CentOS 6.2 using EPEL Repository

Cacti is a complete network graphing solution that useful for network administrator to monitor their network bandwidth. It collect SNMP data as well as other data such as system load, network link status, hard disk space and etc.

From Cacti official site :

Cacti is a complete network graphing solution designed to harness the power of RRDTool’s data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices.

In this post, i will show you on how to install Cacti on linux CentOS 6.2 server. This tutorial assumed that you already installed LAMP (Linux CentOS 6.2 x86, Apache httpd server, Mysql server and PHP) server.

How to Install and Configure EPEL Repository on CentOS 6.2

Cacti is very easy to use and have the following features if it properly configured:

  • Graphs
  • Data Sources
  • Data Gathering
  • Graph Display
  • User Management
See also  How to Install php-mcrypt on CentOS 6.3

1. Login to your CentOS 6.2 server as a root and install the following packages :

[root@centos62 ~]# yum install cacti httpd mysql-server mysql php-common php-mysql php-pear net-snmp php-gd php-devel php php-mbstring php-cli net-snmp-utils php-snmp php-pear-Net-SMTP -y

2. Make sure all these software/packages has been installed :

Package cacti-0.8.7i-2.el6.noarch already installed and latest version
Package httpd-2.2.15-15.el6.centos.1.i686 already installed and latest version
Package mysql-server-5.1.61-1.el6_2.1.i686 already installed and latest version
Package mysql-5.1.61-1.el6_2.1.i686 already installed and latest version
Package php-common-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-mysql-5.3.3-3.el6_2.6.i686 already installed and latest version
Package 1:php-pear-1.9.4-4.el6.noarch already installed and latest version
Package 1:net-snmp-5.5-37.el6_2.1.i686 already installed and latest version
Package php-gd-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-devel-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-mbstring-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-cli-5.3.3-3.el6_2.6.i686 already installed and latest version
Package 1:net-snmp-utils-5.5-37.el6_2.1.i686 already installed and latest version
Package php-snmp-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-pear-Net-SMTP-1.6.1-1.el6.noarch already installed and latest version

3. Starting the database :

[root@centos62 ~]# service mysqld start
Starting mysqld:                                           [  OK  ]

4. Login to mysql server and create the following database and user :

See also  How to Install Subversion 1.6.17 on Fedora 16

Database’s Name : cactidb
Database’s User : cactiuser
Database’s Password : cactipassword

[root@centos62 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.61 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE cactidb;
Query OK, 1 row affected (0.00 sec)

mysql> CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'cactipassword';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON cactidb.* to cactiuser@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW GRANTS FOR 'cactiuser'@'localhost';
+------------------------------------------------------------------------------------------------------------------+
| Grants for cactiuser@localhost                                                                                   |
+------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'cactiuser'@'localhost' IDENTIFIED BY PASSWORD '*6FF226B3BB20712FB42564D21683F5A0173DDD16' |
| GRANT ALL PRIVILEGES ON `cactidb`.* TO 'cactiuser'@'localhost'                                                   |
+------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> exit
Bye

5. Find out cacti.sql path using the following command :

[root@centos62 ~]# rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-0.8.7i/cacti.sql

6. Populate and import the cacti database :

[root@centos62 ~]# /usr/bin/mysql cactidb -u cactiuser -p < /usr/share/doc/cacti-0.8.7i/cacti.sql
Enter password:

7. Configure cacti :

[root@centos62 ~]# vi /etc/cacti/db.php

Update the following details meet your configuration :

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactipassword";
$database_port = "3306";
$database_ssl = false;

Original configuration

<Directory /usr/share/cacti/>
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
</Directory>

Change the configuration to :

<Directory /usr/share/cacti/>
        Order Deny,Allow
        Deny from all
        Allow from all
</Directory>

8. Start the apache httpd service if you haven't start :

[root@centos62 ~]# /etc/rc.d/init.d/httpd start
Starting httpd:                                            [  OK  ]

or just reload to update it:

[root@centos62 ~]# /etc/rc.d/init.d/httpd reload
Reloading httpd:

9. Make httpd and mysql service auto start at boot :

[root@centos62 ~]# chkconfig httpd on
[root@centos62 ~]# chkconfig mysqld on

10. Setting up the crontab :

See also  How to Install Perl on Linux Fedora 16 server

Check where is poller.php :

[root@centos62 ~]# ls /usr/share/cacti/
about.php                graph_image.php             host_templates.php   rra
auth_changepassword.php  graph.php                   images               rra.php
auth_login.php           graph_settings.php          include              scripts
cdef.php                 graphs_items.php            index.php            script_server.php
cli                      graphs_new.php              install              settings.php
cmd.php                  graphs.php                  lib                  templates_export.php
color.php                graph_templates_inputs.php  log                  templates_import.php
data_input.php           graph_templates_items.php   logout.php           tree.php
data_queries.php         graph_templates.php         poller_commands.php  user_admin.php
data_sources.php         graph_view.php              poller_export.php    utilities.php
data_templates.php       graph_xport.php             poller.php
gprint_presets.php       host.php                    resource
[root@centos62 ~]# crontab -e
# Used to update Cacti
*/5 * * * * /usr/share/cacti/poller.php >> /var/log/cacti 2>&1

How to Setup and Configure Cacti on CentOS 6.2

How to Reset the Directory Manager Password on RHEL 7 / CentOS 7
How to Reset the Directory Manager Password on RHEL 7 / CentOS 7

It is best practice to remember passwords, but because too many passwords, sometimes we forget. We are not encouraged to write the password on any paper or share the password...

How to Find Big Files Size on Linux RHEL/CentOS
How to Find Big Files Size on Linux RHEL/CentOS

As the linux administrator, sometimes we have to identify which files are most take much space in the linux server resulting in low free space. Low disk space can also...

Why Linux users should worry about malware and what they can do about it
Why Linux users should worry about malware and what they can do about it

Don’t drop your guard just because you’re running Linux. Preventing the spread of malware and/or dealing with the consequences of infection are a fact of life when using computers. If...

How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7
How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7

This short howto will explain the steps to reset a lost root password or to reset a forgotten root password on Linux RHEL 7 or CentOS 7. Basically, we will...

How to Update CentOS or Upgrade CentOS to the Latest Version
How to Update CentOS or Upgrade CentOS to the Latest Version

Recently, the latest version of CentOS 7.3 was released. All users of CentOS 7.0, 7.1 and 7.2 can upgrade their system to the most recent. This quick guide will explain...

How to Change your WordPress Username, Nickname and Display Name in MySQL
How to Change your WordPress Username, Nickname and Display Name in MySQL

After you create an account log in WordPress, you may want to change your WordPress username, as appropriate or due to security reason. However, you can not do this from...

How to Enable SSH Root Login on Ubuntu 16.04
How to Enable SSH Root Login on Ubuntu 16.04

As what we wrote in the previous article on how to allow SSH root on Ubuntu 14.04, after installing a fresh new copy of Ubuntu 16.04 LTS, we find that...

How to Change UUID of Linux Partition on CentOS 7
How to Change UUID of Linux Partition on CentOS 7

UUID (Universally Unique IDentifier) should be unique and it is used to identify storage devices on a linux system. If you cloned a virtual machine from vCenter, the metadata containing...

2 Comments

  • Avatar for KAGE KAGE says:

    /etc/httpd/conf.d/cacti.conf

  • Avatar for KAGE KAGE says:

    vi /etc/httpd/conf.d/cacti.conf

    Original configuration

    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1

    Change the configuration to :

    Order Deny,Allow
    Deny from all
    Allow from all

Leave a Reply

Your email address will not be published. Required fields are marked *