Knowledgebase

How to Install Cacti 1.1 on CentOS Print

  • 0

Cacti is a free and open source network monitoring and graphing tool written in PHP. With the help of RRDtool (Round-Robin database tool), Cacti can be used to provide various useful features, including remote and local data collectors, graph templating, network discovery, device management automation, etc.

Prerequisites

Step 1: Setup an up to date LAMP stack

Before you can properly install and run Cacti, you need to setup a LAMP stack or an equivalent web operating environment.

The following will set up an up to date LAMP stack for Cacti, which consists of CentOS 7, Apache 2.4, MariaDB 10.2, and PHP 7.1. If you want to learn more details about the LAMP stack, or use another stack, please refer to other Rcs tutorials.

# Install Apache 2.4
sudo yum install httpd -y
sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf
sudo systemctl start httpd.service
sudo systemctl enable httpd.service

# Install MariaDB 10.2
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
sudo yum install MariaDB-server MariaDB-client -y
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

# Secure MariaDB 10.2
sudo /usr/bin/mysql_secure_installation
# When prompted, answer questions as below:
# - Enter current password for root (enter for none): Just press the Enter button
# - Set root password? [Y/n]: Y
# - New password: your-MariaDB-root-password
# - Re-enter new password: your-MariaDB-root-password
# - 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

# Create a MariaDB database for Cacti
mysql -u root -p
# For security purposes, be sure to replace "cacti", "cactiuser", and "yourpassword" with your own ones. 
CREATE DATABASE cacti;
CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

# Install required PHP 7.1 components for Cacti
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum install -y mod_php71w php71w-process php71w-common php71w-pdo php71w-xml php71w-ldap php71w-mbstring php71w-gd php71w-snmp php71w-mysqlnd php71w-cli php71w-mcrypt php71w-opcache php71w-imap php71w-intl
sudo cp /etc/php.ini /etc/php.ini.bak
sudo sed -i 's#;date.timezone =#date.timezone = America/Los_Angeles#' /etc/php.ini

# Modify firewall rules
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload

Step 2: Install other required dependencies

In addition to setting up a practical LAMP stack, you also need to install several dependencies for Cacti as follows.

sudo yum install -y net-snmp net-snmp-utils rrdtool
sudo systemctl start snmpd.service
sudo systemctl enable snmpd.service

Step 3: Prepare Cacti files and database

Download and decompress the Cacti 1.1 archive.

cd
wget http://www.cacti.net/downloads/cacti-1.1.20.tar.gz
tar -zxvf cacti-1.1.20.tar.gz

Move the Cacti files to a proper location, create the Cacti log file, and then grant proper permissions to them.

sudo mv ~/cacti-1.1.20 /opt
sudo ln -s /opt/cacti-1.1.20 /var/www/html/cacti
sudo touch /opt/cacti-1.1.20/log/cacti.log
sudo chown -R apache:apache /opt/cacti-1.1.20

Import timezone info and Cacti data into the MariaDB database we setup earlier.

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
mysql -u root -p cacti < /var/www/html/cacti/cacti.sql
mysql -u root -p
# In the MySQL shell:
GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost IDENTIFIED BY 'yourpassword';
FLUSH PRIVILEGES;
EXIT;
Setup Cacti parameters.

Use the vi editor to open the Cacti config file:

sudo vi /var/www/html/cacti/include/config.php

Make sure that the below parameters are using correct values.

$database_type     = 'mysql';
$database_default  = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'yourpassword';
$database_port     = '3306';
$database_ssl      = false;
$url_path = '/cacti/';

Save and quit.

:wq!

Setup a cron job for Cacti.

sudo crontab -u apache -e

Populate the file with:

*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1

Save and quit.

:wq!

Step 4: Setup an Apache virtual host for Cacti

In order to make Apache serve Cacti, you need to setup an Apache virtual host for Cacti as follows.

Note: Remember to modify the values of ServerAdmin, ServerName, and ServerAlias on your machine accordingly.

cat <<EOF | sudo tee -a /etc/httpd/conf.d/cacti.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/
ServerName cacti.example.com
ServerAlias www.cacti.example.com
<Directory /var/www/html/cacti/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/cacti.example.com-error_log
CustomLog /var/log/httpd/cacti.example.com-access_log common
</VirtualHost>
EOF

Restart Apache in order to put all your changes into effect.

sudo systemctl restart httpd.service

Step 5: Update MariaDB settings

In order to provide better performance when using Cacti, you need to update several MariaDB settings with recommended values.

Backup the /etc/my.cnf file and then use the vi editor to open it:

sudo cp /etc/my.cnf /etc/my.cnf.bak
sudo vi /etc/my.cnf

Find the line [client-server], and append contents as shown.

[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
collation-server=utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
character-set-server = utf8mb4
max_heap_table_size=64M
tmp_table_size=80M
join_buffer_size=80M
innodb_buffer_pool_size=256M
innodb_doublewrite=OFF
innodb_flush_log_at_timeout=3
innodb_read_io_threads=32
innodb_write_io_threads=16

Save and quit.

:wq!

Restart MariaDB in order to put all your modifications into effect.

sudo systemctl restart mariadb.service

Step 6: Continue installing Cacti using the Cacti installation wizard in a web browser

Point your favorite web browser to http://203.0.113.1/cacti, and you will be brought into the Cacti Installation Wizard interface.

On the License Agreement page, check the Accept GPL License Agreement option, and then click the Next button.

On the Pre-installation Checks page, all requirements should be satisfied. Just click the Next button to move on.

On the Installation Type page, choose the New Primary Server option, and then click the Next button.

On the Critical Binary Locations and Versions page, ignore the Spine Binary File Location error since we did not install Spine at all. Just click the Next button to move on.

On the Directory Permission Checks page, make sure all specified directories are writable, and then click the Next button.

On the Template Setup page, check the Local Linux Machine option, and then click the Finish button to complete the installation and switch to the log in interface.

On the User Login interface, use the default username admin and the default password admin to log in.

After logging in, you will be asked to change the password immediately. Be sure to provide a strong password satisfying all prompted requirements.

That's all for installing and configuring Cacti. Later, you should setup RRDtool accordingly so that Cacti can obtain necessary data for graphing.

Cacti is a free and open source network monitoring and graphing tool written in PHP. With the help of RRDtool (Round-Robin database tool), Cacti can be used to provide various useful features, including remote and local data collectors, graph templating, network discovery, device management automation, etc. Prerequisites A fresh Rcs CentOS 7 x64 server instance. Say its IP address is 203.0.113.1. A sudo user. The server instance has been updated to the latest stable status using the EPEL YUM repo. Step 1: Setup an up to date LAMP stack Before you can properly install and run Cacti, you need to setup a LAMP stack or an equivalent web operating environment. The following will set up an up to date LAMP stack for Cacti, which consists of CentOS 7, Apache 2.4, MariaDB 10.2, and PHP 7.1. If you want to learn more details about the LAMP stack, or use another stack, please refer to other Rcs tutorials. # Install Apache 2.4 sudo yum install httpd -y sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf sudo systemctl start httpd.service sudo systemctl enable httpd.service # Install MariaDB 10.2 curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash sudo yum install MariaDB-server MariaDB-client -y sudo systemctl start mariadb.service sudo systemctl enable mariadb.service # Secure MariaDB 10.2 sudo /usr/bin/mysql_secure_installation # When prompted, answer questions as below: # - Enter current password for root (enter for none): Just press the Enter button # - Set root password? [Y/n]: Y # - New password: your-MariaDB-root-password # - Re-enter new password: your-MariaDB-root-password # - 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 # Create a MariaDB database for Cacti mysql -u root -p # For security purposes, be sure to replace "cacti", "cactiuser", and "yourpassword" with your own ones. CREATE DATABASE cacti; CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'yourpassword'; GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION; FLUSH PRIVILEGES; EXIT; # Install required PHP 7.1 components for Cacti sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm sudo yum install -y mod_php71w php71w-process php71w-common php71w-pdo php71w-xml php71w-ldap php71w-mbstring php71w-gd php71w-snmp php71w-mysqlnd php71w-cli php71w-mcrypt php71w-opcache php71w-imap php71w-intl sudo cp /etc/php.ini /etc/php.ini.bak sudo sed -i 's#;date.timezone =#date.timezone = America/Los_Angeles#' /etc/php.ini # Modify firewall rules sudo firewall-cmd --zone=public --permanent --add-service=http sudo firewall-cmd --reload Step 2: Install other required dependencies In addition to setting up a practical LAMP stack, you also need to install several dependencies for Cacti as follows. sudo yum install -y net-snmp net-snmp-utils rrdtool sudo systemctl start snmpd.service sudo systemctl enable snmpd.service Step 3: Prepare Cacti files and database Download and decompress the Cacti 1.1 archive. cd wget http://www.cacti.net/downloads/cacti-1.1.20.tar.gz tar -zxvf cacti-1.1.20.tar.gz Move the Cacti files to a proper location, create the Cacti log file, and then grant proper permissions to them. sudo mv ~/cacti-1.1.20 /opt sudo ln -s /opt/cacti-1.1.20 /var/www/html/cacti sudo touch /opt/cacti-1.1.20/log/cacti.log sudo chown -R apache:apache /opt/cacti-1.1.20 Import timezone info and Cacti data into the MariaDB database we setup earlier. mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql mysql -u root -p cacti < /var/www/html/cacti/cacti.sql mysql -u root -p # In the MySQL shell: GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost IDENTIFIED BY 'yourpassword'; FLUSH PRIVILEGES; EXIT; Setup Cacti parameters. Use the vi editor to open the Cacti config file: sudo vi /var/www/html/cacti/include/config.php Make sure that the below parameters are using correct values. $database_type = 'mysql'; $database_default = 'cacti'; $database_hostname = 'localhost'; $database_username = 'cactiuser'; $database_password = 'yourpassword'; $database_port = '3306'; $database_ssl = false; $url_path = '/cacti/'; Save and quit. :wq! Setup a cron job for Cacti. sudo crontab -u apache -e Populate the file with: */5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1 Save and quit. :wq! Step 4: Setup an Apache virtual host for Cacti In order to make Apache serve Cacti, you need to setup an Apache virtual host for Cacti as follows. Note: Remember to modify the values of ServerAdmin, ServerName, and ServerAlias on your machine accordingly. cat < ServerAdmin admin@example.com DocumentRoot /var/www/html/ ServerName cacti.example.com ServerAlias www.cacti.example.com Options FollowSymLinks AllowOverride All Order allow,deny allow from all ErrorLog /var/log/httpd/cacti.example.com-error_log CustomLog /var/log/httpd/cacti.example.com-access_log common EOF Restart Apache in order to put all your changes into effect. sudo systemctl restart httpd.service Step 5: Update MariaDB settings In order to provide better performance when using Cacti, you need to update several MariaDB settings with recommended values. Backup the /etc/my.cnf file and then use the vi editor to open it: sudo cp /etc/my.cnf /etc/my.cnf.bak sudo vi /etc/my.cnf Find the line [client-server], and append contents as shown. [client] default-character-set=utf8mb4 [mysql] default-character-set=utf8mb4 [mysqld] collation-server=utf8mb4_unicode_ci init-connect='SET NAMES utf8mb4' character-set-server = utf8mb4 max_heap_table_size=64M tmp_table_size=80M join_buffer_size=80M innodb_buffer_pool_size=256M innodb_doublewrite=OFF innodb_flush_log_at_timeout=3 innodb_read_io_threads=32 innodb_write_io_threads=16 Save and quit. :wq! Restart MariaDB in order to put all your modifications into effect. sudo systemctl restart mariadb.service Step 6: Continue installing Cacti using the Cacti installation wizard in a web browser Point your favorite web browser to http://203.0.113.1/cacti, and you will be brought into the Cacti Installation Wizard interface. On the License Agreement page, check the Accept GPL License Agreement option, and then click the Next button. On the Pre-installation Checks page, all requirements should be satisfied. Just click the Next button to move on. On the Installation Type page, choose the New Primary Server option, and then click the Next button. On the Critical Binary Locations and Versions page, ignore the Spine Binary File Location error since we did not install Spine at all. Just click the Next button to move on. On the Directory Permission Checks page, make sure all specified directories are writable, and then click the Next button. On the Template Setup page, check the Local Linux Machine option, and then click the Finish button to complete the installation and switch to the log in interface. On the User Login interface, use the default username admin and the default password admin to log in. After logging in, you will be asked to change the password immediately. Be sure to provide a strong password satisfying all prompted requirements. That's all for installing and configuring Cacti. Later, you should setup RRDtool accordingly so that Cacti can obtain necessary data for graphing.

Was this answer helpful?
Back

Powered by WHMCompleteSolution