Search This Blog

How to Install Cacti on CentOS 8

Update System

dnf update -y

Install Apache

dnf -y install httpd httpd-devel

Install SNMP and RRDTool

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

Restart service and enable service to start on boot time.

systemctl restart snmpd
systemctl enable snmpd

Install PHP Extension

dnf -y install 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

Change PHP Settings

vi /etc/php.ini

date.timezone = Asian/Phnom_Penh
memory_limit = 512M
max_execution_time = 60

Restart services

systemctl restart httpd
systemctl restart php-fpm

Enable services to startup on boot time.

systemctl enable httpd
systemctl enable php-fpm

Install MariaDB

dnf -y install mariadb-server

Restart and Enable to startup on boot time.

systemctl restart mariadb
systemctl enable mariadb

Secure MariaDB by setting a password.

mysqladmin -u root password your_strong_password

Create a Database for Cacti. Login into the database with a password just set at the moment.

mysql -u root -p

create database cacti;
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'p@$$w0rd';
flush privileges;
exit;

Import time.zone table into default database.

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

Grant permission to cactiuser on the timezone table.

mysql -u root -p

GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;
flush privileges;
exit;

Optimize Database

vi /etc/my.cnf.d/mariadb-server.cnf

Put the following lines under the [mysqld] section.

collation-server = utf8mb4_unicode_ci
character-set-server=utf8mb4
max_heap_table_size = 64M
tmp_table_size = 64M
join_buffer_size = 64M
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_flush_log_at_timeout = 3
innodb_buffer_pool_size = 1GB
innodb_buffer_pool_instances = 10
innodb_read_io_threads = 32
innodb_write_io_threads = 16
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000

Install Cacti from the EPEL repository. First, we need to enable epel-release into the CentOS repository.

dnf -y install epel-release

Install Cacti

dnf -y install cacti

Configure Cacti

Edit the Cacti's configuration file and specify the database name, database username and password accordingly.

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

/* 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 = "p@$$w0rd";
$database_port = "3306";
$database_ssl = false;

Import the Cacti database into our database name cacti.

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

Enable Cron Job

Create a cron job to schedule Cacti runs its poller every 5 minutes.

vi /etc/cron.d/cacti

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

Allow remote access

By default, Cacti allows only the localhost to access. To allow remote access please make the change as follow.

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

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>

Allow Firewall and SELinux

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

SELinux

sed -i 's/enforcing/disabled/g' /etc/selinux/config
setenforce 0

Restart service

systemctl restart mariadb httpd

Setup Cacti

Open your favorite browser and type http://server_ip/cacti. The default username is admin and password admin.


Cannot log in with the default username and password. Please follow the following steps.

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

Comment the following line by putting the hash sign (#) in the front.

#$cacti_cookie_domain = 'cacti.net';

Then, change the current password to the new secure password.


Check the License Agreement box and Begin.


Cacti check all the following requirements like PHP Setting, Timezome, Database running and Next.


Select the installation type and Next.


Directory Permission Checks, Cacti check all the directories permission that is required by Cacti and Next.


Specify the Critical Binary Location that will be used by Cacti and Next.


Read the security enhancement of Cacti, check the box below and Next.


Default profile, just keep it default and Next.


The default templates that will be installed and Next.


Cacti validate the database collation if any warning about the database, we can fix by follow the message here, Next.


Confirm the installation and Install.


Click on Get Started to finish.


Our Cacti installation is Done.










No comments:

Post a Comment

How to install zabbix Server on Rocky Linux 9

How to set up Zabbix Server on Rocky Linux 9 1. Set Selinux to permissive mode sudo setenforce 0 sudo sed -i...