How to Install Cacti Network Monitoring Tool On CentOS

 

How to Install Cacti Network Monitoring Tool on CentOS 7/RHEL

Prerequisites

Setup EPEL Repository

Repositories For more extended package list, we first install the REMI, OpenNMS, and EPEL repositories:

Setup EPEL repository only CentOS 7 / RHEL 7.

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

yum install http://yum.opennms.org/repofiles/opennms-repo-stable-rhel7.noarch.rpm

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Install SNMP

Install SNMP and RRDTool.

yum install net-snmp net-snmp-utils net-snmp-libs rrdtool

Install Apache

 yum install httpd httpd-devel

Install PHP & PHP Extensions

The PHP version available in base OS repository is already reached the end of life and for the Cacti installation, you may need to go for PHP v7.2+.

So, we will use the Remi repository to install PHP 7.x.

PHP v7.3

yum install -y --enablerepo=remi-php73 php php-xml php-session php-sockets php-ldap php-gd php-gmp php-intl php-mbstring php-mysqlnd php-pdo php-process php-snmp

 

Update all installed packages

yum update

Install MariaDB

The MariaDB package (v5.4) available in the base OS repository doesn’t meet Cacti’s minimum requirement as Cacti requires MariaDB v5.6+ or MariaDB v10+ for installation. So, install the latest version of MariaDB available from the official MariaDB community website.

READ: How To Install MariaDB on CentOS 7 / RHEL 7

https://mariadb.com/resources/blog/installing-mariadb-10-on-centos-7-rhel-7/

 

Install the MariaDB server using the following command.

yum install MariaDB-server MariaDB-client

Database Tuning

Cacti recommend changing MariaDB settings for better performances. Edit the MariaDB configuration file.

nano /etc/my.cnf.d/server.cnf

Add variables in the [mysqld] section.

collation-server = utf8mb4_unicode_ci

character-set-server=utf8mb4

max_heap_table_size = 64M

tmp_table_size = 64M

join_buffer_size = 128M

innodb_file_format = Barracuda

innodb_large_prefix = 1

innodb_flush_log_at_timeout = 3

innodb_buffer_pool_size = 1GB

innodb_buffer_pool_instances = 10

# Based on what type for storage you use. The below values are for SSD drives.

# Change it if Cacti reports issues during the installation

innodb_read_io_threads = 32

innodb_write_io_threads = 16

innodb_io_capacity = 5000

innodb_io_capacity_max = 10000

Start & Enable Services

Start the following services.

systemctl start httpd snmpd mariadb

Enable the services to start automatically on system boot.

ADVERTISEMENT

systemctl enable httpd snmpd mariadb

Create Database

If you are configuring the MySQL for the first time; take a look at how to secure the MariaDB.

Create a database for Cacti installation.

mysql -u root -p

Create a database for Cacti.

create database cacti;

Grant permission to the newly created database.

CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'password';

GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'password';

flush privileges;

exit

The newly created database user (cactiuser) should have access to the mysql.time_zone_name table. To do that, import the mysql_test_data_timezone.sql to mysql database first.

mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql

Then, log in to MySQL.

mysql -u root -p

Grant the permission to cactiuser.

GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;

flush privileges;

exit

Install Cacti

READ: How To Install cacti on CentOS 7 / RHEL 7

https://cacti.net/info/downloads

Use the yum command on CentOS / RHEL to install Cacti package.

yum install cacti

Import the default database to the cacti database.

mysql cacti < /usr/share/doc/cacti-*/cacti.sql -u root -p

Edit the config file to specify the database type, name, hostname, user, and password information.

nano /usr/share/cacti/include/config.php

Make the changes accordingly.

/* make sure these values reflect your actual database/host/user/password */

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cactiuser";

$database_password = "password";

$database_port = "3306";

$database_ssl = false;

 

systemctl restart mariadb.service

 

Edit the crontab file.

nano /etc/cron.d/cacti

Uncomment the following entry to poll every five min.

*/5 * * * *    apache  /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

Set the timezone by editing /etc/php.ini file.

nano /etc/php.ini

Update the timezone.

ADVERTISEMENT

date.timezone =Asia/Karachi

memory_limit = 512M

max_execution_time = 60

Edit the Apache configuration file to perform the remote installation.

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

 

Changing the Apache Port 

 

nano /etc/httpd/conf/httpd.conf

 

In the file, find the 'Listen' and find the following statement as Listen 80.

Listen 80
Listen yourIP: 8090

Modify the first directory stanza, from Require host localhost.

Alias /cacti /usr/share/cacti

<Directory /usr/share/cacti/>

            <IfModule mod_authz_core.c>

                         # httpd 2.4

                         Require host localhost

            </IfModule>

            <IfModule !mod_authz_core.c>

                         # httpd 2.2

                         Order deny,allow

                         Deny from all

                         Allow from localhost

            </IfModule>

</Directory>

To Require all granted.

Alias /cacti /usr/share/cacti

<Directory /usr/share/cacti/>

            <IfModule mod_authz_core.c>

                         # httpd 2.4

                         Require all granted

            </IfModule>

            <IfModule !mod_authz_core.c>

                         # httpd 2.2

                         Order deny,allow

                         Deny from all

                         Allow from localhost

            </IfModule>

</Directory>

Restart the services.

systemctl restart httpd

 

 

Firewall

Configure the firewall to allow HTTP service.

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

firewall-cmd --add-port=8090/tcp --permanent

 

firewall-cmd --reload

SELinux

how to make cacti work within it is beyond the scope of this guide, so we will disable it. If you are competent enough to maintain SELinux, then that is possible too, but is an even more unsupported configuration than RHEL/CentOS themselves.

Firstly, disable SELinux. You can do this temporarily with the following command:

setenforce 0

open ‘/etc/sysconfig/selinux‘ file and change the option from ‘permissive‘ to ‘disabled‘.

nano /etc/sysconfig/selinux

SELINUX=permissive

TO

SELINUX=disabled   

 

you may required while finshing cacti installtion setup:

Set the SELinux context for Cacti logs.

yum install -y policycoreutils-python

 

semanage fcontext -a -t httpd_sys_rw_content_t "/var/log/cacti(/.*)?"

 

restorecon -Rv /var/log/cacti/

Configure snmpd

cp /opt/cacti/snmpd.conf.example /etc/snmp/snmpd.conf
nano /etc/snmp/snmpd.conf
 
Finally 

After reboot you will have to start them again so it’s better to change this so these services always start at boot:

chkconfig httpd on

chkconfig mysqld on

chkconfig snmpd on

 

 

Setup Cacti

Visit the following URL to start the installation of cacti.

http://your-ip-address:portnumber/cacti

Login to Cacti to set up Cacti installation.

Username: admin
Password: admin

 

Comments

Popular posts from this blog

Installing NFSEN & NFDUMP on Ubuntu and Next integrate with LibreNMS

IP Core Networks | Your Education, Your Choice

How to Install & Integrate Oxidized Into LibreNMS