Install and Configure OpenNMS on AlmaLinux 8: Best Steps

Posted on

Install and Configure OpenNMS on AlmaLinux 8: Best Steps

Install and Configure OpenNMS on AlmaLinux 8: Best Steps

In this comprehensive guide brought to you by Orcacore, we will walk you through the process of how to Install and Configure OpenNMS on AlmaLinux 8. OpenNMS is a robust, enterprise-grade network monitoring and network management platform developed under the free software and open-source model. It’s designed to efficiently manage tens of thousands of devices from a single server, and even more using a cluster of servers.

OpenNMS boasts a powerful discovery engine that automates the configuration and management of network devices, minimizing the need for manual intervention. Written in Java, it is distributed under the GNU General Public License.

As a comprehensive network platform, OpenNMS provides the following major feature categories:

  • Device Discovery: Automatically identifies and adds network devices.
  • Service Monitoring: Checks the availability and performance of network services.
  • Event Management: Captures and correlates network events for proactive troubleshooting.
  • Performance Monitoring: Collects and analyzes network performance metrics.
  • Reporting: Generates detailed reports on network health and performance.

OpenNMS is comprised of these core components:

  • OpenNMS Core: The central processing engine.
  • Minion: A distributed agent for monitoring remote locations.
  • Meridian: A stable, supported version of OpenNMS for enterprise deployments.
  • Horizon: The latest development version with new features and updates.

Let’s dive into the steps required for the OpenNMS Horizon Installation Guide on AlmaLinux 8.

Before you begin the Install and Configure OpenNMS on AlmaLinux 8, ensure you are logged into your server as a non-root user with sudo privileges and have a basic firewall configured. Refer to our guide on Initial Server Setup with AlmaLinux 8 for detailed instructions.

1. Install Java for OpenNMS Horizon Installation

Since OpenNMS is a Java-based application, a Java Runtime Environment (JRE) or Java Development Kit (JDK) is essential. Start by updating your system:

sudo dnf update -y

Next, install essential utilities:

sudo dnf install vim curl wget -y

Now, install Java 11 using the following command:

sudo dnf install java-11-openjdk-devel -y

Verify the Java installation by checking the version:

java -version
Install Java for OpenNMS Horizon Installation

2. OpenNMS Horizon Installation Guide

The OpenNMS packages are not included in the default AlmaLinux repository. Therefore, you need to add the OpenNMS repository manually.

Import OpenNMS GPG Key

Import the OpenNMS GPG key to verify the packages:

sudo rpm --import https://yum.opennms.org/OPENNMS-GPG-KEY

Add OpenNMS Repository

Add the OpenNMS repository to your server:

sudo dnf install https://yum.opennms.org/repofiles/opennms-repo-stable-rhel8.noarch.rpm -y

Install OpenNMS on AlmaLinux

Now, install OpenNMS using the dnf package manager:

sudo dnf install opennms -y

This command will install OpenNMS along with all its required dependencies.

3. PostgreSQL Database Config for OpenNMS

Once OpenNMS and its dependencies are installed, you need to configure PostgreSQL, which OpenNMS uses as its database.

First, initialize the PostgreSQL database:

sudo postgresql-setup --initdb --unit postgresql
**<mark>Output</mark>**
 * Initializing database in '/var/lib/pgsql/data'
 * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log

Then, start and enable the PostgreSQL service:

# sudo systemctl enable postgresql
# sudo systemctl start postgresql

Verify that PostgreSQL is active and running:

sudo systemctl status postgresql
PostgreSQL Database Config for OpenNMS

Next, switch to the PostgreSQL user:

sudo -i -u postgres

Create OpenNMS Database and User

Create a dedicated OpenNMS user in PostgreSQL:

createuser -P <mark>opennms</mark>
Enter password for new role:
Enter it again:

Then, create the OpenNMS database:

createdb -O <mark>opennms opennms</mark>

Next, secure the default postgres user with a strong password:

psql -c "ALTER USER <mark>postgres</mark> WITH PASSWORD '<mark>StrongPassword</mark>';"
**<mark>Output</mark>**
ALTER ROLE

Exit the PostgreSQL shell:

[postgres@localhost ~]$ exit

Modify PostgreSQL Access Policy

Modify the PostgreSQL access policy to allow OpenNMS to connect to the database. Open the pg_hba.conf file:

sudo vi /var/lib/pgsql/data/pg_hba.conf

Find the following lines and change ident to md5:

# IPv4 local connections:
host    all             all             127.0.0.1/32            <strong><mark>md5</mark></strong>

# IPv6 local connections:
host    all             all             ::1/128                 <strong><mark>md5</mark></strong>

Save and close the file. Restart PostgreSQL to apply the changes:

sudo systemctl restart postgresql

Define Database Credentials in OpenNMS Config File

Define the database credentials in the OpenNMS configuration file:

sudo vi /opt/opennms/etc/opennms-datasources.xml

Find the following lines and update the username and password:

<jdbc-data-source name="opennms"
                    database-name="<mark>opennms</mark>"
                    class-name="org.postgresql.Driver"
                    url="jdbc:postgresql://localhost:5432/opennms"
                    user-name="<mark>opennms</mark>"
                    password="<mark>opennms-user-password</mark>" />

<jdbc-data-source name="opennms-admin"
                    database-name="template1"
                    class-name="org.postgresql.Driver"
                    url="jdbc:postgresql://localhost:5432/template1"
                    user-name="postgres"
                    password="<mark>postgres-password</mark>" />
</datasource-configuration>

Save and close the file.

4. Manage OpenNMS Service on AlmaLinux 8

First, initialize OpenNMS by adding the Java settings:

sudo /opt/opennms/bin/runjava -s
initialize OpenNMS by adding the Java settings

Next, initialize the database and detect system libraries in the /opt/opennms/etc/libraries.properties directory:

sudo /opt/opennms/bin/install -dis

Now, start and enable the OpenNMS service:

# sudo dnf install chkconfig -y
# sudo systemctl enable --now opennms

Verify that the OpenNMS service is active and running:

sudo systemctl status opennms
OpenNMS server Status

5. Configure Firewall For OpenNMS

Assuming you have firewalld enabled, allow traffic on port 8980, which OpenNMS uses by default:

sudo firewall-cmd --permanent --add-port=8980/tcp

Reload the firewall to apply the changes:

sudo firewall-cmd --reload

If SELinux is enabled, allow the port through SELinux:

sudo semanage port -a -t http_port_t -p tcp 8980

6. Access OpenNMS Web Interface

Access the OpenNMS Horizon web interface by navigating to your server’s IP address followed by :8980/opennms in your web browser:

http://<mark>IP_Address</mark>:8980/opennms

Log in with the default username admin and password admin.

OpenNMS Login
OpenNMS Login

You will be presented with the OpenNMS dashboard.

OpenNMS Dashboard AlmaLinux 8
OpenNMS Dashboard

Change the default password by navigating to admin -> Change Password.

Change default Admin Password OpenNMS
Change default Admin Password
Add New Admin Password for OpenNMS
Add New Admin Password

7. How To Use OpenNMS for Service Monitoring?

To monitor systems, add them as nodes in OpenNMS. Click the "+" icon.

Add node to OpenNMS
Add node

Enter the required details: requisition, IP Address, and Node Label, then click Provision.

OpenNMS Node Credentials
Node Credentials

The node will then appear under Info -> Nodes.

You can now view graphs and create alerts for the monitored device.

Monitor Devices with OpenNMS ALmaLinux 8
Monitor Devices

For more details, refer to the OpenNMS Documentation. This concludes the Install and Configure OpenNMS on AlmaLinux 8 tutorial.

Conclusion

You have successfully learned how to Install and Configure OpenNMS Horizon on AlmaLinux 8.

Enjoy your OpenNMS Horizon Installation Guide.

Here are some other articles you might find interesting:

How To Install PHP 7.4 on AlmaLinux 8

Install and Configure Postfix Mail Server on AlmaLinux 8

Install and Configure Nextcloud on AlmaLinux 8

Alternative Solutions for Network Monitoring on AlmaLinux 8

While OpenNMS is a powerful open-source network monitoring solution, there are other alternatives that might better suit specific needs or preferences. Here are two alternative approaches to achieving similar network monitoring capabilities on AlmaLinux 8.

1. Using Zabbix

Zabbix is another popular open-source network monitoring solution. Like OpenNMS, it offers a wide range of features including device discovery, performance monitoring, alerting, and reporting. However, Zabbix has a different architecture and configuration approach, which some users might find more intuitive.

Explanation:

Zabbix uses a client-server architecture. The Zabbix server is the central component that collects and processes data from monitored devices. Zabbix agents are installed on the devices to be monitored and actively report data to the server. Zabbix also supports agentless monitoring using protocols like SNMP, SSH, and Telnet.

Installation and Configuration Steps:

  1. Install Zabbix Server:

    First, add the Zabbix repository:

    rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
    dnf clean all

    Install the Zabbix server, frontend, and agent:

    sudo dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-apache-conf zabbix-agent
  2. Create Zabbix Database:

    sudo -u postgres createuser -P zabbix
    sudo -u postgres createdb -O zabbix zabbix

    Import the initial schema and data:

    zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix
  3. Configure Zabbix Database Connection:

    Edit /etc/zabbix/zabbix_server.conf and configure the database settings:

    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPassword=<zabbix_database_password>
  4. Configure Apache Web Frontend:

    Edit /etc/httpd/conf.d/zabbix.conf and uncomment or set the correct timezone:

    php_value date.timezone Europe/Berlin
  5. Start Zabbix Server and Agent:

    sudo systemctl enable --now zabbix-server zabbix-agent httpd
  6. Access Zabbix Web Interface:

    Open your web browser and navigate to http://<your_server_ip>/zabbix. The default username is Admin and the password is zabbix.

Code Example (Zabbix Agent Configuration):

To monitor a specific application, you can create a custom user parameter in the Zabbix agent configuration file (/etc/zabbix/zabbix_agentd.conf). For example, to monitor the number of active SSH connections:

UserParameter=ssh.connections,netstat -an | grep :22 | grep ESTABLISHED | wc -l

After adding this parameter, restart the Zabbix agent:

sudo systemctl restart zabbix-agent

In the Zabbix web interface, you can then create an item to retrieve the value of this user parameter.

2. Using Prometheus and Grafana

Prometheus is a powerful open-source monitoring and alerting toolkit designed for time-series data. Grafana is a data visualization tool that integrates seamlessly with Prometheus to create dashboards and visualizations.

Explanation:

Prometheus collects metrics by scraping HTTP endpoints on monitored devices. These endpoints expose metrics in a specific format. Prometheus stores the collected data as time-series data and provides a query language (PromQL) for querying and analyzing the data. Grafana uses Prometheus as a data source to create dashboards and visualizations.

Installation and Configuration Steps:

  1. Install Prometheus:

    Download the latest Prometheus binary from the official website or use wget:

    wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
    tar xvf prometheus-2.45.0.linux-amd64.tar.gz
    cd prometheus-2.45.0.linux-amd64

    Create a user and group for Prometheus:

    sudo groupadd prometheus
    sudo useradd -g prometheus -M -r prometheus
    sudo chown -R prometheus:prometheus /path/to/prometheus-2.45.0.linux-amd64

    Create systemd service file:

    sudo vi /etc/systemd/system/prometheus.service
    [Unit]
    Description=Prometheus
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    User=prometheus
    Group=prometheus
    Type=simple
    ExecStart=/path/to/prometheus-2.45.0.linux-amd64/prometheus 
        --config.file=/path/to/prometheus-2.45.0.linux-amd64/prometheus.yml 
        --storage.tsdb.path=/path/to/prometheus-2.45.0.linux-amd64/data
    
    [Install]
    WantedBy=multi-user.target
  2. Install Grafana:

    Add the Grafana repository:

    cat <<EOF > /etc/yum.repos.d/grafana.repo
    [grafana]
    name=grafana
    baseurl=https://rpm.grafana.com
    repo_gpgcheck=1
    enabled=1
    gpgcheck=1
    gpgkey=https://rpm.grafana.com/gpg.key
    sslverify=1
    sslcacert=/etc/pki/tls/certs/ca-bundle.crt
    EOF

    Install Grafana:

    sudo dnf install grafana

    Start and enable Grafana:

    sudo systemctl enable --now grafana-server
  3. Configure Prometheus:

    Edit prometheus.yml to define targets to scrape. For example, to scrape node_exporter (which exports system metrics):

    scrape_configs:
      - job_name: 'node'
        static_configs:
          - targets: ['localhost:9100']
  4. Install Node Exporter:

    wget https://github.com/prometheus/node_exporter/releases/download/v1.8.0/node_exporter-1.8.0.linux-amd64.tar.gz
    tar xvf node_exporter-1.8.0.linux-amd64.tar.gz
    cd node_exporter-1.8.0.linux-amd64
    
    sudo mv node_exporter /usr/local/bin/
    sudo chown root:root /usr/local/bin/node_exporter
    
    sudo vi /etc/systemd/system/node_exporter.service
    [Unit]
    Description=Node Exporter
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    User=prometheus
    Group=prometheus
    Type=simple
    ExecStart=/usr/local/bin/node_exporter
    
    [Install]
    WantedBy=multi-user.target
    sudo systemctl enable --now node_exporter
  5. Access Grafana Web Interface:

    Open your web browser and navigate to http://<your_server_ip>:3000. The default username is admin and the password is admin. Add Prometheus as a data source and create dashboards using PromQL queries.

Code Example (Prometheus Configuration – prometheus.yml):

This example shows a basic Prometheus configuration file:

global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds.
  evaluation_interval: 15s # Set the evaluation interval to every 15 seconds.

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

  - job_name: 'node_exporter'
    static_configs:
      - targets: ['localhost:9100']

This configuration scrapes Prometheus itself and node_exporter. You can then create Grafana dashboards to visualize the data collected by Prometheus.

These alternative solutions offer different approaches to network monitoring and may be preferred based on specific requirements and technical preferences. They each provide robust features for monitoring and alerting, enabling effective network management on AlmaLinux 8.

Leave a Reply

Your email address will not be published. Required fields are marked *