Install Cacti 1.x on CentOS 7
In this posting you will be learning how to install Cacti 1.x on a freshly installed CentOS 7 system.
Addition Information
Do you want to have an on-demand cacti for your small office or large site ? look here: Cereus-Monitoring
Step 1 – Prerequisites
First we need to install some of the software packages needed for Cacti to run properly. Software which is not included or enabled in the base CentOS 6 installation are:
- rrdtool
- apache
- mariadb
- cron
- gcc
Before we install these, let’s add the mariadb repository to our CentOS 7 system:
echo "# MariaDB 10.1 CentOS repository list - created 2017-02-08 16:11 UTC # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1" > /etc/yum.repos.d/MariaDB.repo
Now we can finally use yum to get all required packages installed.
Centos 7: yum -y install mariadb-server php php-cli php-mysql net-snmp-utils rrdtool \ php-snmp gcc mariadb-devel net-snmp-devel autoconf automake libtool dos2unix wget help2man \ php-posix php-ldap php-mbstring php-gd
gcc and the devel packages are required for the installation of spine, hence that’s why we include it here.
In order to have all packages up-to-date, let’s do a quick upgrade on our system as well:
yum -y upgrade
Now let’s make sure that our webserver and the database are automatically starting up after a reboot. Use the following commands to enable these:
CentOS 7: systemctl enable httpd.service systemctl enable mariadb.service systemctl restart mariadb.service
Now that we have the database server started, we need to populate it with the timezone data:
# Create the timezone data and import it into the mysqldatabase mysql_tzinfo_to_sql /usr/share/zoneinfo > /tmp/mysql_timezone.sql mysql mysql < /tmp/mysql_timezone.sql
Next, we need to change some settings for the mariadb server. These will make sure that spine and Cacti are utilizing the database connection in an optimal way.
Edit the /etc/my.cnf.d/server.cnf file and add the following lines to the [mysqld] section:
max_heap_table_size=90M max_allowed_packet=16M tmp_table_size=64M join_buffer_size=64M innodb_file_per_table=ON innodb_buffer_pool_size=450M innodb_doublewrite=OFF innodb_additional_mem_pool_size=80M innodb_lock_wait_timeout=50 innodb_flush_log_at_trx_commit=2 character_set_server=utf8 character_set_client=utf8 collation_server=utf8_general_ci default-time-zone='Europe/Berlin' innodb_flush_log_at_timeout=3 innodb_read_io_threads=32 innodb_write_io_threads=16
Make sure to adapt the default-time-zone to your requirements
Next, we need to restart the web-server as well as the Maria DB service in order to continue the installation:
CentOS 7: systemctl restart httpd.service systemctl restart mariadb.service
[the_ad_placement id=”default-manual”]
Step 2 – Cacti Files
Let’s now move to the actualy installation of Cacti. First we need to download and extract it. As of version 0.8.8, a fully patched Cacti including the Plugin Architecture (PIA) is officially available, so we’re downloading that one:
cd /var/www/html wget http://www.cacti.net/downloads/cacti-latest.tar.gz tar -xzvf cacti-latest.tar.gz
I usually suggest to create a symbolic link to the newly created directory “cacti-1.1.25”. This will make upgrades to never Cacti versions easier:
ln -s cacti-1.1.25 cacti
Step 3 – Cron and file permissions
Cacti uses cron (scheduled task) in order to execute its polling process. It’s always a good idea to run this under a special user. Let’s create the system “cacti” user now:
adduser -d /var/www/html/cacti -s /sbin/nologin cacti
Having done that, we can now add a new cron entry to your system for a 1 minute polling interval using the following command:
echo "*/1 * * * * cacti php /var/www/html/cacti/poller.php &>/dev/null" >> /etc/cron.d/cacti
Finally, we also need to make sure that the permissions on the log and rra directories are set correctly:
cd /var/www/html/cacti chown -R cacti.apache rra log resource scripts cache chmod -R 775 rra log resource scripts cache
Step 4 – Cacti Database
Now that we have extracted the cacti files, we can move on preparing the database for the final installation step. Your first step should be securing the mysql database. The following command will help you with this task on a CentOS system. Make sure to select a strong password for root, e.g. MyN3wpassw0rd
/usr/bin/mysql_secure_installation
Let’s create a new database and assign a special user to it:
# Create the Cacti database and populate it with the default data mysqladmin -u root -p create cacti mysql -p cacti < /var/www/html/cacti/cacti.sql mysql -u root -p
With the last command, you should be seeing a mysql prompt where you can enter mysql commands. Here we are going to create the special cacti user. That user only needs to be able to connect from the local system and should have a strong password as well. Enter the following commands and make sure to replace the password:
GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost IDENTIFIED BY 'MyV3ryStr0ngPassword'; GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'MyV3ryStr0ngPassword'; flush privileges; exit
We now have the cacti files and the cacti database setup. The last step before moving to the web-based installer is setting the database credentials within the Cacti config file:
cd /var/www/html/cacti/include/ vi config.php
Change the $database_ lines to fit your new settings:
$database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "MyV3ryStr0ngPassword"; $database_port = "3306"; $database_ssl = false;
Depending on your installation, you should also uncomment the following line. In our example we have to make sure the following line is there:
$url_path = "/cacti/";
Step 5 – Adding firewall rules
The following settings will add access rules to http and https from outside:
Centos 7: firewall-cmd --permanent --zone=public --add-service=https firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --reload
Step 6 – Important PHP Settings
The default PHP installation usually has not configured the correct timezone or php error reporting. While not required to run Cacti, it’s highly recommended to enable error reporting to syslog for troubleshooting issues with plugins or other scripts.
The following lines need to be enabled/configued in your /etc/php.ini file:
; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = Europe/Berlin
and
; Log errors to syslog (Event Log on NT, not valid in Windows 95). error_log = syslog
Step 7 – Disable SELinux
SELinux does interfere with the installation, so let’s disable it for now:
setenfore 0
Step 8 – Running the Web-based installer
Let’s move on to the web-based installer.
TBD
Login with admin/admin and you’re ready to go !
Please go to “Console -> System Utilities” and click on “Rebuild Poller Cache” after the first login!
Need Commercial Support ?
Urban-Software.de offer commercial Cacti support not only for Cacti itself, but also for several of the plugins ( e.g. Thold ).
There’s going to be an on-demand solution in the future. You can contact us for more details using the contact form.
[the_ad_placement id=”default-manual”]