How to Install Cacti on CentOS 5.5

Cacti is a comprehensive network graphing solution that is highly beneficial for network administrators to monitor their network bandwidth. It is user-friendly and offers a variety of features such as Graphs, Data Sources, Data Gathering, Graph Display, and User Management.

This tutorial will guide you through the process of installing Cacti on a CentOS 5.5 server. It is assumed that you have already installed a LAMP (Linux CentOS, Apache, MySQL, and PHP) server.

Preparing Other Yum Repositories For RHEL/CentOS 5

Download and install the rpmforge repository. Use the following commands for x86 (32-bit) systems and x64 (64-bit) systems respectively:

[root@server ~]# rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
[root@server ~]# rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

Install Cacti and its dependencies with the command below:

[root@server ~]# yum -y --enablerepo=rpmforge install cacti mysql-server mysql php-common php-mysql net-snmp net-snmp-utils php-snmp liberation-fonts

This command will install Cacti along with MySQL server, PHP common files, PHP MySQL, Net-SNMP, Net-SNMP utilities, PHP SNMP, and Liberation fonts.

Example:

[root@server ~]# yum -y --enablerepo=rpmforge install cacti mysql-server mysql php-common php-mysql net-snmp net-snmp-utils php-snmp liberation-fonts
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: centos.maulvi.net
* base: centos.maulvi.net
* epel: ftp.cuhk.edu.hk
* extras: centos.maulvi.net
* rpmforge: fr2.rpmfind.net
* updates: mirror.yourconnect.com
Setting up Install Process
Package matching php-mysql-5.1.6-27.el5_5.3.i386 already installed. Checking for update.
Package liberation-fonts-1.0-1.el5.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package cacti.noarch 0:0.8.7g-2.el5.rf set to be updated
--> Processing Dependency: rrdtool for package: cacti
---> Package mysql.i386 0:5.0.77-4.el5_5.5 set to be updated
---> Package mysql-server.i386 0:5.0.77-4.el5_5.5 set to be updated
---> Package net-snmp.i386 1:5.3.2.2-9.el5_5.1 set to be updated
--> Processing Dependency: net-snmp-libs = 1:5.3.2.2-9.el5_5.1 for package: net-snmp
---> Package net-snmp-utils.i386 1:5.3.2.2-9.el5_5.1 set to be updated
---> Package php-common.i386 0:5.1.6-27.el5_5.3 set to be updated
---> Package php-snmp.i386 0:5.1.6-27.el5_5.3 set to be updated
--> Running transaction check
---> Package net-snmp-libs.i386 1:5.3.2.2-9.el5_5.1 set to be updated
---> Package rrdtool.i386 0:1.4.4-1.el5.rf set to be updated
--> Processing Dependency: ruby for package: rrdtool
--> Processing Dependency: lua for package: rrdtool
--> Processing Dependency: xorg-x11-fonts-Type1 for package: rrdtool
--> Processing Dependency: perl(RRDs) for package: rrdtool
--> Processing Dependency: perl(RRDp) for package: rrdtool
--> Processing Dependency: libdbi.so.0 for package: rrdtool
--> Running transaction check
---> Package libdbi.i386 0:0.8.1-2.1 set to be updated
---> Package lua.i386 0:5.1.4-4.el5 set to be updated
---> Package perl-rrdtool.i386 0:1.4.4-1.el5.rf set to be updated
---> Package ruby.i386 0:1.8.5-5.el5_4.8 set to be updated
--> Processing Dependency: ruby-libs = 1.8.5-5.el5_4.8 for package: ruby
--> Processing Dependency: libruby.so.1.8 for package: ruby
---> Package xorg-x11-fonts-Type1.noarch 0:7.1-2.1.el5 set to be updated
--> Processing Dependency: chkfontpath for package: xorg-x11-fonts-Type1
--> Running transaction check
---> Package chkfontpath.i386 0:1.10.1-1.1 set to be updated
--> Processing Dependency: xfs for package: chkfontpath
---> Package ruby-libs.i386 0:1.8.5-5.el5_4.8 set to be updated
--> Running transaction check
---> Package xorg-x11-xfs.i386 1:1.0.2-5.el5_6.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================
Package                   Arch        Version                   Repository     Size
=====================================================================================
Installing:
cacti                     noarch      0.8.7g-2.el5.rf           rpmforge      2.2 M
net-snmp                  i386        1:5.3.2.2-9.el5_5.1       base          697 k
net-snmp-utils            i386        1:5.3.2.2-9.el5_5.1       base          186 k
php-common                i386        5.1.6-27.el5_5.3          base          153 k
php-snmp                  i386        5.1.6-27.el5_5.3          base           30 k
Updating:
mysql                     i386        5.0.77-4.el5_5.5          updates       4.8 M
mysql-server              i386        5.0.77-4.el5_5.5          updates       9.8 M
Installing for dependencies:
chkfontpath               i386        1.10.1-1.1                base           15 k
libdbi                    i386        0.8.1-2.1                 base           35 k
lua                       i386        5.1.4-4.el5               epel          228 k
perl-rrdtool              i386        1.4.4-1.el5.rf            rpmforge       52 k
rrdtool                   i386        1.4.4-1.el5.rf            rpmforge      895 k
ruby                      i386        1.8.5-5.el5_4.8           base          274 k
ruby-libs                 i386        1.8.5-5.el5_4.8           base          1.6 M
xorg-x11-fonts-Type1      noarch      7.1-2.1.el5               base          1.5 M
xorg-x11-xfs              i386        1:1.0.2-5.el5_6.1         updates        69 k
Updating for dependencies:
net-snmp-libs             i386        1:5.3.2.2-9.el5_5.1       base          1.3 M

Transaction Summary
=====================================================================================
Install      14 Package(s)
Upgrade       3 Package(s)

Total download size: 24 M
Downloading Packages:
(1/17): chkfontpath-1.10.1-1.1.i386.rpm                       |  15 kB     00:00
(2/17): php-snmp-5.1.6-27.el5_5.3.i386.rpm                    |  30 kB     00:01
(3/17): libdbi-0.8.1-2.1.i386.rpm                             |  35 kB     00:01
(4/17): perl-rrdtool-1.4.4-1.el5.rf.i386.rpm                  |  52 kB     00:02
(5/17): xorg-x11-xfs-1.0.2-5.el5_6.1.i386.rpm                 |  69 kB     00:02
(6/17): php-common-5.1.6-27.el5_5.3.i386.rpm                  | 153 kB     00:12
(7/17): net-snmp-utils-5.3.2.2-9.el5_5.1.i386.rpm             | 186 kB     00:12
(8/17): lua-5.1.4-4.el5.i386.rpm                              | 228 kB     00:20
(9/17): ruby-1.8.5-5.el5_4.8.i386.rpm                         | 274 kB     00:10
(10/17): net-snmp-5.3.2.2-9.el5_5.1.i386.rpm                  | 697 kB     00:25
(11/17): rrdtool-1.4.4-1.el5.rf.i386.rpm                      | 895 kB     01:03
(12/17): net-snmp-libs-5.3.2.2-9.el5_5.1.i386.rpm             | 1.3 MB     01:11
(13/17): xorg-x11-fonts-Type1-7.1-2.1.el5.noarch.rpm          | 1.5 MB     01:38
(14/17): ruby-libs-1.8.5-5.el5_4.8.i386.rpm                   | 1.6 MB     01:43
(15/17): cacti-0.8.7g-2.el5.rf.noarch.rpm                     | 2.2 MB     02:23
(16/17): mysql-5.0.77-4.el5_5.5.i386.rpm                      | 4.8 MB     03:32
(17/17): mysql-server-5.0.77-4.el5_5.5.i386.rpm               | 9.8 MB     07:06
-------------------------------------------------------------------------------------
Total                                                 19 kB/s |  24 MB     21:11
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating       : net-snmp-libs                                                1/20
Updating       : mysql                                                        2/20
Installing     : net-snmp                                                     3/20
Installing     : net-snmp-utils                                               4/20
Installing     : libdbi                                                       5/20
Installing     : php-common                                                   6/20
Installing     : php-snmp                                                     7/20
Installing     : ruby-libs                                                    8/20
Installing     : ruby                                                         9/20
Installing     : lua                                                         10/20
Updating       : mysql-server                                                11/20
Installing     : chkfontpath                                                 12/20
Installing     : xorg-x11-xfs                                                13/20
Installing     : xorg-x11-fonts-Type1                                        14/20
Installing     : rrdtool                                                     15/20
Installing     : cacti                                                       16/20
Installing     : perl-rrdtool                                                17/20
Cleanup        : mysql-server                                                18/20
Cleanup        : mysql                                                       19/20
Cleanup        : net-snmp-libs                                               20/20

Installed:
cacti.noarch 0:0.8.7g-2.el5.rf              net-snmp.i386 1:5.3.2.2-9.el5_5.1
net-snmp-utils.i386 1:5.3.2.2-9.el5_5.1     php-common.i386 0:5.1.6-27.el5_5.3
php-snmp.i386 0:5.1.6-27.el5_5.3

Dependency Installed:
chkfontpath.i386 0:1.10.1-1.1          libdbi.i386 0:0.8.1-2.1
lua.i386 0:5.1.4-4.el5                 perl-rrdtool.i386 0:1.4.4-1.el5.rf
rrdtool.i386 0:1.4.4-1.el5.rf          ruby.i386 0:1.8.5-5.el5_4.8
ruby-libs.i386 0:1.8.5-5.el5_4.8       xorg-x11-fonts-Type1.noarch 0:7.1-2.1.el5
xorg-x11-xfs.i386 1:1.0.2-5.el5_6.1

Updated:
mysql.i386 0:5.0.77-4.el5_5.5         mysql-server.i386 0:5.0.77-4.el5_5.5

Dependency Updated:
net-snmp-libs.i386 1:5.3.2.2-9.el5_5.1

Complete!

Creating the Database and User for Cacti

Create the database and user for Cacti using the following MySQL commands:

mysql> CREATE DATABASE cactidb;
mysql> CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'cactipassword';
mysql> GRANT ALL PRIVILEGES ON cactidb.* to cactiuser@localhost;
mysql> SHOW GRANTS FOR 'cactiuser'@'localhost';

These commands will create a new database named ‘cactidb’, a new user ‘cactiuser’ with the password ‘cactipassword’, and grant all privileges on the ‘cactidb’ database to ‘cactiuser’.

See also  How to Install Webmin 1.570 on CentOS 5.7 from tar.gz file

Populating the Cacti Database

Populate the cacti database with the following command:

[root@server ~]# /usr/bin/mysql cactidb -u cactiuser -p < /var/www/cacti/cacti.sql

You will need to enter the password you created for 'cactiuser' when prompted.

Open the Cacti configuration file with the following command:

[root@server ~]# vi /var/www/cacti/include/config.php

Ensure that the following valuesreflect your actual database/host/user/password:

$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactipassword"; 
$database_port = "3306";

Setting Up the Crontab

Set up the crontab to update Cacti every 5 minutes with the following command:

[root@server ~]# crontab -e
# Used to update Cacti
*/5 * * * * /usr/bin/php /var/www/cacti/poller.php >> /var/log/cacti 2>&1

Configuring cacti.conf

Configure cacti.conf as shown below:

[root@server ~]# vi /etc/httpd/conf.d/cacti.conf
Alias /cacti/ /var/www/cacti/
<Directory /var/www/cacti/>
DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
allow from all
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>

This configuration sets up an alias for Cacti, specifies the directory index, sets various options, and adds the PHP type for .php files.

See also  How to Install Cacti on CentOS 6.2 using EPEL Repository

Restarting Apache

Restart Apache to apply the changes with the following command:

[root@server ~]# /etc/init.d/httpd restart

....

Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[root@server ~]#

Accessing Cacti

Navigate your browser to http://servername/cacti to access your new Cacti installation.

Log in to your new Cacti installation at http://servername/cacti/ with the default user (admin) and the default password (admin).

Commands Mentioned

  • rpm -Uhv [URL] – This command is used to install a package from a specified URL.
  • yum -y --enablerepo=rpmforge install [packages] – This command is used to install specified packages from the rpmforge repository.
  • CREATE DATABASE [database]; – This command is used to create a new database in MySQL.
  • CREATE USER '[user]'@'localhost' IDENTIFIED BY '[password]'; – This command is used to create a new user in MySQL.
  • GRANT ALL PRIVILEGES ON [database].* to [user]@localhost; – This command is used to grant all privileges on a specified database to a specified user in MySQL.
  • SHOW GRANTS FOR '[user]'@'localhost'; – This command is used to display all grants for a specified user in MySQL.
  • /usr/bin/mysql [database] -u [user] -p < [file] – This command is used to populate a specified database with data from a specified file.
  • vi [file] – This command is used to open a specified file in the vi text editor.
  • crontab -e – This command isused to edit the crontab file.
  • /etc/init.d/httpd restart – This command is used to restart the Apache server.

Conclusion

In this tutorial, we have walked through the process of installing Cacti on a CentOS 5.5 server. We have covered the preparation of Yum repositories, the creation of a database and userfor Cacti, populating the Cacti database, setting up the crontab, configuring cacti.conf, and finally accessing Cacti.

See also  How to Install Webmin 1.720 on CentOS 6/RHEL 6

Cacti is a powerful tool for network monitoring and graphing, and its installation and configuration can be a valuable addition to any network administrator's toolkit. It's important to note that while this guide is specific to CentOS 5.5, the general principles can be applied to other Linux distributions as well.

For more information on various server types, you can visit our pages on dedicated servers, VPS servers, cloud hosting, and shared hosting.

For more in-depth guides on other web server technologies such as Apache, Nginx, and LiteSpeed, be sure to check out our other articles.

Remember, the key to mastering any technology is consistent practice and experimentation. Don't be afraid to explore and try new things.

Happy networking!

FAQ

  1. What is Cacti and why is it useful?

    Cacti is a comprehensive network graphing solution that is highly beneficial for network administrators to monitor their network bandwidth. It offers a variety of features such as Graphs, Data Sources, Data Gathering, Graph Display, and User Management.

  2. What is the purpose of the rpm -Uhv command?

    The rpm -Uhv command is used to install a package from a specified URL. It's a part of the RPM Package Manager (RPM), which is a powerful command line driven package management system capable of installing, uninstalling, verifying, querying, and updating software packages.

  3. What does the yum -y --enablerepo=rpmforge install command do?

    The yum -y --enablerepo=rpmforge install command is used to install specified packages from the rpmforge repository. The -y option answers 'yes' to any prompts that come up during the installation process, and --enablerepo=rpmforge specifies the repository to use.

  4. How do you create a new user in MySQL?

    To create a new user in MySQL, you can use the CREATE USER command followed by the username and host, along with the IDENTIFIED BY clause to specify the password. For example: CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

  5. What is the purpose of the /etc/init.d/httpd restart command?

    The /etc/init.d/httpd restart command is used to restart the Apache server. This is often necessary when changes have been made to the Apache configuration file. Restarting the server allows it to read the new configuration.

Comments

1 Comment

Leave a Reply to XaXa Cancel reply

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