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

Cacti is an open source web-based network monitoring tool designed as the front end application for the RRDtool (Round-Robin database tool), it allows a user to poll the services at an interval of time and resulting in the graph format.
Cacti is used to get a graph data for the CPU and network bandwidth utilization, it monitors the network traffic by polling a router or switch via SNMP.
Here is the small tutorial about installing Cacti on CentOS 7 / RHEL 7 and Fedora 27 / 26.
Prerequisites
Setup EPEL repository only on CentOS 7 / RHEL 7.
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Install SNMP and RRDTool.
yum -y install net-snmp net-snmp-utils net-snmp-libs rrdtool
Install the required PHP extensions.
### CentOS 7 / RHEL 7 ### yum -y install mariadb-server php php-xml php-session php-sockets php-ldap php-gd ### Fedora 27 / Fedora 26 ### dnf -y install mariadb-server php php-xml php-session php-sockets php-ldap php-gd php-gmp
Start the following services.
systemctl start httpd systemctl start snmpd systemctl start mariadb
Create Cacti Database
Create a database for Cacti. If you are configuring the MySQL for the first time; take a look at how to secure the MySQL.
# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 18 Server version: 5.5.37-MariaDB MariaDB Server Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
Create Cacti database.
create database cacti;
Grant permission to the newly created database.
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword'; 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.
### CentOS 7 / RHEL 7 ### mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql ### Fedora 27 / Fedora 26 ### mysql -u root -p mysql < /usr/share/mariadb/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
Database Tuning
Cacti recommend changing MySQL variables settings for better performances. Edit configuration file depends on the operating system.
### CentOS 7 / RHEL 7 ### vi /etc/my.cnf.d/server.cnf ### Fedora 27 / Fedora 26 ### vi /etc/my.cnf
Add variables in [mysqld] section.
CentOS 7 / RHEL 7:
collation-server = utf8_general_ci init-connect='SET NAMES utf8' character-set-server = utf8 max_heap_table_size = 128M max_allowed_packet = 16777216 tmp_table_size = 64M join_buffer_size = 64M innodb_file_per_table = on innodb_buffer_pool_size = 512M innodb_doublewrite = off innodb_additional_mem_pool_size = 80M innodb_lock_wait_timeout = 50 innodb_flush_log_at_trx_commit = 2 innodb_flush_log_at_timeout = 3 innodb_read_io_threads = 32 innodb_write_io_threads = 16
Fedora 27 / Fedora 26:
collation-server = utf8mb4_unicode_ci init-connect='SET NAMES utf8' character-set-server = utf8mb4 max_heap_table_size = 128M max_allowed_packet = 16777216 tmp_table_size = 64M join_buffer_size = 64M innodb_file_per_table = on innodb_buffer_pool_size = 512M innodb_doublewrite = off innodb_flush_log_at_timeout = 3 innodb_read_io_threads = 32 innodb_write_io_threads = 16 innodb_lock_wait_timeout = 50 innodb_flush_log_at_trx_commit = 2 innodb_flush_log_at_timeout = 3 innodb_read_io_threads = 32 innodb_write_io_threads = 16
Install & Configure Cacti
Use YUM command on CentOS / RHEL and DNF command on Fedora to install Cacti package.
### CentOS 7 / RHEL 7 ### yum -y install cacti ### Fedora 27 / Fedora 26 ### dnf -y install cacti
Create MySQL Cacti Database
[root@localhost lib]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
MariaDB [(none)]> create database cacti;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY ‘indian@123’;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>exit
Install Cacti Tables to MySQL
Find out the database file path using RPM command, to install cacti tables into newly created Cactidatabase, use the following command.
[root@localhost]# rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-1.1.38/cacti.sql
[root@localhost]#
Import the default database to the cacti database.
### CentOS 7 / RHEL 7 ### mysql cacti < /usr/share/doc/cacti-*/cacti.sql -u root -p ### Fedora 27 / Fedora 26 ### mysql -u root -p cacti < /usr/share/doc/cacti/cacti.sql
Edit the config file to specify the database type, name, hostname, user, and password information.
vi /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 = "cactipassword"; $database_port = "3306"; $database_ssl = false;
Add the following entry in the crontab to poll every five min.
*/5 * * * * cacti php /usr/share/cacti/poller.php > /dev/null 2>&1
Edit apache configuration file to perform the remote installation.
vi /etc/httpd/conf.d/cacti.conf
Modify first directory stanza, from “Require host localhost”
<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”
<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>
Set the timezone by editing /etc/php.ini file.
vi /etc/php.ini
Update the timezone.
date.timezone = Asia/Calcutta
Restart the services.
systemctl restart httpd systemctl restart snmpd systemctl restart mariadb
Enable services to start at system start-up.
systemctl enable httpd systemctl enable snmpd systemctl enable mariadb
Firewall
Configure the firewall to allow HTTP service.
firewall-cmd --permanent --add-service=http firewall-cmd --reload
SELinux
It is recommended to permanently disable SELinux for Cacti to work correctly. To temporarily disable the SELinux, run the following command in the terminal.
setenforce 0
systemctl enable httpd.service
Setup Cacti Web Interface
Visit the following URL to start the installation of cacti.
Accept the License Agreement on this page and then click on Next to continue.

Move to next step by clicking Next button located at the right bottom of the page.


You can safely ignore the warning for updating MySQL 5.5 to 5.6+.
If you probably want to install MySQL 5.7 and MariaDB 10 then follow below links.
READ: Install MySQL 5.7 on CentOS 7/6, RHEL 7/6, and Fedora 27/26/25
Select New Primary Server or the new installation and then click Next.

It will show you if there is any package is missing which is mandatory for the cacti.

You can safely ignore the error for Spine as we are using the buit-in poller for remote polling.
READ: How to Install and Use Spine Poller with Cacti
This step checks and reports for permission problems you may have in the Cacti installation directory.

Select all templates and click Finish to complete the Cacti installation.

Access Cacti Dashboard
Enter User Name and Password (Default: admin/admin) to login to Cacti.

You must change the default password.

Cacti Dashboard:

How to Add Graphs
Go to Management >> Device >> Select Device >> Select Place on a Tree >> Go.

Click continue to finish adding a device to Graph.
To view usage graph. Go to Graph >> Default Tree >> Choose Your Device. Wait at least 15 – 30 minutes to let Cacti populate the usage graph of your device for you.

Now you can start configuring the Cacti to monitor your devices. More documentation can be found here. Please post your valuable comments below.