Jump to content
Sign in to follow this  

Installing Cacti on CentOS 7

guru

52 views

Seems like this should be easy, especially since there is a yum install for cacti but oh no, nothing is what it seems.  If you follow the below instructions (well as of January 2020) then you have a good chance at being successful.  Please note, this is best case and no guarantee it will work but it worked for me.  This also will help me keep track of some helpful commands I used for the future.

DISABLE FIREWALL

Open and edit SELinux configuration file.

vim /etc/sysconfig/selinux

Change  SELINUX=enforcing to SELINUX=disabled. Save and exit. Reboot system

reboot

ENABLE REPOS (where you need software installed from)

Head over to the Fedora website and copy the latest download link of the latest file.

Download the EPEL repository:

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm --no-check-certificate

Install EPEL repository

rpm -Uvh epel-release-latest-7.noarch.rpm

Download the REMI repository:

wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm --no-check-certificate

Install REMI repository

rpm -Uvh remi-release-7.rpm

List repositories.

yum repolist
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
 * base: centos.host-engine.com
 * centos-sclo-rh: bay.uchicago.edu
 * centos-sclo-sclo: linux.mirrors.es.net
 * epel: fedora-epel.mirror.lstn.net
 * extras: centos.sonn.com
 * remi-safe: fr2.rpmfind.net
 * updates: centos.mirrors.hoobly.com
repo id                                                                                               repo name                                                                                                                                 status
Tuleap/x86_64                                                                                         Tuleap                                                                                                                                        65
base/7/x86_64                                                                                         CentOS-7 - Base                                                                                                                           10,097
centos-sclo-rh/x86_64                                                                                 CentOS-7 - SCLo rh                                                                                                                         8,968
centos-sclo-sclo/x86_64                                                                               CentOS-7 - SCLo sclo                                                                                                                         878
cwp/x86_64                                                                                            CentOS Web Panel repo for Linux 7 - x86_64                                                                                                    76
epel/x86_64                                                                                           Extra Packages for Enterprise Linux 7 - x86_64                                                                                            13,212
extras/7/x86_64                                                                                       CentOS-7 - Extras                                                                                                                            335
mariadb                                                                                               MariaDB                                                                                                                                       85
remi-safe                                                                                             Safe Remi's RPM repository for Enterprise Linux 7 - x86_64                                                                                 3,690
updates/7/x86_64                                                                                      CentOS-7 - Updates                                                                                                                         1,487
repolist: 38,893

Install APACHE

Install Apache and start the service.  Now I thought I could just install httpd but boy was I wrong. You need that httpd-devel to make things happen with cacti which is another reason you need to enable both repositories.

yum install -y httpd httpd-devel

You can confirm install by running

httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Aug  8 2019 11:41:18

Now lets make it active by starting Apache

systemctl start httpd

Install SNMP and RRDTool

To install SNMP and RRD Tool, enter the following command:

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

Start SNMP.

systemctl start snmpd

Install Maria Database Server

Use the following command to install the MariaDB server

yum -y install mariadb-server

Now start MariaDB Service

systemctl start mariadb

Secure MariaDB Installation by running:

mysql_secure_installation
  • Set root password? [Y/n] Y
  • Remove anonymous users? [Y/n] Y
  • Disallow root login remotely? [Y/n] Y
  • Remove test database and access to it? [Y/n] Y
  • Reload privilege tables now? [Y/n] Y

Install PHP and needed packages

Run the following command to install necessary PHP and required packages.

yum --enablerepo=remi install -y php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-intl php-snmp

To see what version of php your system is running, run the following

php -v
PHP 5.4.45 (cli) (built: Oct 22 2019 13:26:02)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

You can see what modules (packages) that are installed by running

php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
intl
json
ldap
libxml
mbstring
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
snmp
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
zip
zlib

[Zend Modules]

Create a Cacti Database

Import the timezone sql file

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

Log in to the database server with the previously configured password you used when you secured your installation

mysql -u root -p

Create a Database and user.

MariaDB [(none)]> create database zahlinuxcacti;
MariaDB [(none)]> CREATE USER 'zahlinuxuser'@'localhost' IDENTIFIED BY 'OMGsup3Rs3creT!!';

Grant permission and flush privileges.

MariaDB [(none)]> grant all privileges on zahlinuxcacti.* to zahlinuxuser@localhost ;
MariaDB [(none)]> GRANT SELECT ON mysql.time_zone_name TO zahlinuxuser@localhost ;
MariaDB [(none)]> FLUSH PRIVILEGES;

Optimize Database

We need to modify database parameters for better performance. Use the following command.

vim /etc/my.cnf.d/server.cnf

Add the following lines to the [mysqld] section.

[mysqld]
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 = 128M
innodb_file_per_table = on
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_buffer_pool_size = 932M
innodb_doublewrite = on
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
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000

Now that you made changes to the MariaDB config, you gotta restart them services

systemctl restart mariadb.service

Install and configure Cacti

Now that you did all the prep work, let's install Cacti now using YUM.

yum -y install cacti

Import default cacti database file to the created database.

cd /usr/share/doc/cacti-1.2.10/

Import the SQL file provided by cacti

mysql -u root -p  zahlinuxcacti < cacti.sql

Edit the Cacti configuration file which includes a database, password details etc.

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

Modify database details.

$database_type     = 'mysql';
$database_default  = 'zahlinuxcacti';
$database_hostname = 'localhost';
$database_username = 'zahlinuxuser';
$database_password = 'OMGsup3Rs3cret!!';
$database_port     = '3306';
$database_ssl      = false;

Set Cron for Cacti

Open cacti cron file.

vim /etc/cron.d/cacti

Uncomment the following line.

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

Save and exit the file

Configure Apache for Cacti

This will help us to do a remote installation. Edit the cacti config file.

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

Change  “Require host localhost” to “Require all granted” and “Allow from localhost” to “Allow from all.”

Here is an example of what I have (not positive its correct but it does work for me)

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 all
         </IfModule>
</Directory>

<Directory /usr/share/cacti/install>
</Directory>

Change Time Zone.

vim /etc/php.ini
date.timezone = your time Zone
E.g.:- date.timezone = Australia/Sydney

Restart apache

systemctl restart httpd.service

Restart MariaDB

systemctl restart mariadb.service

Restart SNMP

systemctl restart snmpd.service

Configure the Firewall

Use these commands:

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload

Start Cacti installation

Open a web browser and use the following URL to access Cacti web interface.

http://Your-Server-IP/cacti

License Agreement: click Accept GPL License Agreement and click Begin

Pre-installation checks. Click next if there are no issues.

Next window is Installation Type. It will show Database connection details. Click Next to continue.

Verify Critical Binary Locations and Versions and then click next.

Verify Directory Permissions and continue.

In the Template Setup window, you can select all templates, and click finish to the complete installation.  IMPORTANT: as of Cacti 1.2.10 you will get a screen like the one below that has a blank line with a checkmark to the far right.  Uncheck this box or what will happen is your install will get to 42% and hang there forever.  Only way I figured out how to start the install over again was delete the entire cacti database and re-create database, import sql, create user etc..

cacti_template_options.png

After the installation, it will redirect to Login Page.

Using default user name “admin” and default password “admin” you can log in to Cacti server. You should be asked to change the password after that.

Change Password and click save. Then you should see the Cacti Dashboard.

You can add new devices from Managemnt-> Devices Then click plus mark “+” on top of the right-hand corner.

That’s it! You have successfully configured Cacti 1.2.10 on CentOS 7!

 



1 Comment


Recommended Comments

If you are using an older version of Cacti then version 1 you can use Weathermap..  currently not available for anything 1.x or newer.

Something helpful is to add Weather map by going to this website and clicking downloads and downloading the latest php-weathermap.zip file but if you are being blocked due to this being on github then here is the latest as of Jan 2020

php-weathermap-0.98a.zip

upload the zip file to /var/tmp/

type the following commands

unzip /var/tmp/php-weathermap-0.98a.zip
cd /usr/src
mv weathermap /usr/share/cacti/plugins/
cd /usr/share/cacti/plugins/weathermap/

Log into GUI with admin

Click under the Console Tab - Configuration - Plugins

Update permissions for user admin to view & edit Weathermap

  1. In the GUI menu on the left under Utilities, click User Management
  2. Click admin (and any other users you've created that need weathermap access)
  3. Under Realm Permissions, check Plugin->Weathermap: Configure/Manage
  4. Under Realm Permissions, check Plugin->Weathermap: View
  5. click Save

 

Share this comment


Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements


  • Recently Browsing

    No registered users viewing this page.

  • Upcoming Events

×
×
  • Create New...