-->

DEVOPSZONES

  • Recent blogs

    How to Install Cacti on CentOS 8 / RHEL 8

    How to Install Cacti on CentOS 8 / RHEL 8

    Introduction:

    Cacti is a popular open-source network monitoring and graphing tool used by system administrators to collect, store, and graph network data. With its intuitive interface and extensive feature set, Cacti allows you to monitor network devices, servers, and other infrastructure components effectively. In this tutorial, we will guide you through the step-by-step process of installing Cacti on CentOS 8 or RHEL 8.


    Prerequisites:

    Before we begin, make sure you have the following prerequisites in place:

    1. A CentOS 8 or RHEL 8 server with root access.

    2. A LAMP (Linux, Apache, MySQL, PHP) stack installed on your server.


    Step 1: Update the System:

    Start by updating your system to ensure you have the latest packages and security updates. Open a terminal or SSH into your server and run the following command:


    ```

    sudo dnf update -y

    ```


    Step 2: Install Cacti Dependencies:

    Cacti has a few dependencies that need to be installed. Use the following command to install them:


    ```

    sudo dnf install -y net-snmp net-snmp-utils net-snmp-libs rrdtool mariadb-server

    ```


    Step 3: Install and Configure MariaDB:

    Cacti requires a database to store its data. We will use MariaDB as the database server. Install and enable MariaDB using the following commands:


    ```

    sudo dnf install -y mariadb-server

    sudo systemctl enable --now mariadb

    ```


    Next, secure your MariaDB installation by running the security script:


    ```

    sudo mysql_secure_installation

    ```


    Follow the prompts and set a strong root password for MariaDB.


    Step 4: Create a Database for Cacti:

    Login to the MariaDB shell as the root user:


    ```

    sudo mysql -u root -p

    ```


    Enter the root password you set during the secure installation. Once logged in, create a new database for Cacti:


    ```

    CREATE DATABASE cacti;

    GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'password';

    FLUSH PRIVILEGES;

    EXIT;

    ```


    Make sure to replace 'password' with a strong password of your choice.


    Step 5: Install Cacti:

    Now it's time to install Cacti itself. Use the following command to install Cacti and its web interface:


    ```

    sudo dnf install -y cacti

    ```


    During the installation, you will be prompted to configure Cacti. Select "Webserver: Apache" and press Enter.


    Step 6: Configure Apache:

    Cacti requires some additional Apache configuration. Open the Apache configuration file for editing:


    ```

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

    ```


    Find the line containing `Require host localhost` and replace it with:


    ```

    Require all granted

    ```


    Save and exit the file.


    Step 7: Import Cacti Database:

    Import the default Cacti database by running the following command:


    ```

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

    ```


    Enter the password for the 'cactiuser' when prompted.


    Step 8: Configure Cacti Database:

    Edit the Cacti configuration file using the following command:


    ```

    sudo vi /etc/cacti/db.php

    ```


    Update the database details with the following information:


    ```

    $database_type = 'mysql';

    $database_default = 'cacti


    ';

    $database_hostname = 'localhost';

    $database_username = 'cactiuser';

    $database_password = 'password';

    ```


    Save and exit the file. Make sure to replace 'password' with the password you set for the 'cactiuser' earlier.


    Step 9: Configure Cacti Cron Job:

    To enable data collection and graph generation, we need to set up a cron job. Open the cron configuration file:


    ```

    sudo vi /etc/cron.d/cacti

    ```


    Find the line containing `*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1` and uncomment it by removing the '#' symbol at the beginning of the line.


    Save and exit the file.


    Step 10: Start Cacti and Apache Services:

    Start the Cacti and Apache services using the following commands:


    ```

    sudo systemctl start httpd

    sudo systemctl start cacti

    sudo systemctl enable httpd

    sudo systemctl enable cacti

    ```


    Step 11: Access Cacti Web Interface:

    Open a web browser and access the Cacti web interface using your server's IP address or domain name: `http://your_server_ip/cacti/`


    Follow the on-screen prompts to set up the Cacti administrator account and complete the installation.


    Conclusion:

    Congratulations! You have successfully installed Cacti on CentOS 8 or RHEL 8. With Cacti up and running, you can now start monitoring and graphing your network devices and servers. Explore the various features and customize the tool to suit your specific monitoring requirements. Happy monitoring!

    No comments