Install and Configure OpenNMS on AlmaLinux 9 with Best Steps

Posted on

Install and Configure OpenNMS on AlmaLinux 9 with Best Steps

Install and Configure OpenNMS on AlmaLinux 9 with Best Steps

This tutorial aims to guide you through the process of installing and configuring Install and Configure OpenNMS on AlmaLinux 9. OpenNMS (Open Network Management System) is a powerful, free, and open-source network monitoring and management platform. It allows you to centrally monitor remote devices, offering features such as provisioning, service monitoring, event management, charting, and more. OpenNMS leverages SNMP and JMX to gather information from monitored systems and provides a user-friendly web-based interface. It’s designed to run on Linux and Windows operating systems.

To follow this guide, ensure you have a non-root user with sudo privileges on your AlmaLinux 9 server and a basic firewall configured. You can refer to our guide on Initial Server Setup with AlmaLinux 9 for assistance.

1. Install Java on AlmaLinux 9

OpenNMS is written in Java, so you’ll need to install Java on your server. First, update the system:

sudo dnf update -y

Next, install Java using the following command:

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

Verify the Java installation by checking its version:

java -version
**Output**
openjdk version "11.0.18" 2023-01-17 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.18.0.10-2.el9_1) (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-2.el9_1) (build 11.0.18+10-LTS, mixed mode, sharing)

2. Set up OpenNMS Horizon on AlmaLinux 9

OpenNMS packages are not available in the default AlmaLinux repository, so you’ll need to add them manually.

Import OpenNMS GPG Key

Import the OpenNMS GPG key using the following command:

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-rhel9.noarch.rpm -y

Install OpenNMS Horizon on AlmaLinux 9

Install OpenNMS using the following command:

sudo dnf install opennms -y

This will install all necessary dependencies.

3. Configure PostgreSQL for OpenNMS on AlmaLinux 9

After installing OpenNMS and its dependencies, you need to configure PostgreSQL.

First, initialize PostgreSQL:

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

Start and enable the PostgreSQL service:

# sudo systemctl enable postgresql
# sudo systemctl start postgresql

Verify PostgreSQL is running:

sudo systemctl status postgresql
**Output**
● postgresql.service - PostgreSQL database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendo>
     Active: **active** (**running**) since Wed 2023-03-15 06:36:44 EDT; 5s ago
    Process: 74881 ExecStartPre=/usr/libexec/postgresql-check-db-dir postgresql>
   Main PID: 74883 (postmaster)
      Tasks: 8 (limit: 23609)
     Memory: 16.9M
        CPU: 56ms
     CGroup: /system.slice/postgresql.service
...

Switch to the PostgreSQL user:

sudo -i -u postgres

Create OpenNMS Database and User

Create an OpenNMS user:

createuser -P opennms
Enter password for new role:
Enter it again:

Create the OpenNMS database:

createdb -O opennms opennms

Protect the Postgres default user with a password:

psql -c "ALTER USER postgres WITH PASSWORD 'StrongPassword';"
**Output**
ALTER ROLE

Exit the PostgreSQL shell:

[postgres@localhost ~]$ exit

Modify PostgreSQL Access Policy

Modify the PostgreSQL access policy by editing the pg_hba.conf file:

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

Find the following lines and replace ident with md5:

# IPv4 local connections:
host    all             all             127.0.0.1/32            **md5**

# IPv6 local connections:
host    all             all             ::1/128                 **md5**

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 database credentials accordingly:

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

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

Save and close the file.

4. Manage OpenNMS Service on AlmaLinux 9

First, initialize OpenNMS by adding the Java settings:

sudo /opt/opennms/bin/runjava -s
**Output**
runjava: Looking for an appropriate JVM...
runjava: Checking for an appropriate JVM in JAVA_HOME...
runjava: Skipping... JAVA_HOME not set.
runjava: Checking JVM in the PATH: "/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-2.el9_1.x86_64/bin/java"...
runjava: Found an appropriate JVM in the PATH: "/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-2.el9_1.x86_64/bin/java"
runjava: Value of "/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-2.el9_1.x86_64/bin/java" stored in configuration file.

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

sudo /opt/opennms/bin/install -dis

Start and Enable OpenNMS Service

Start and enable the OpenNMS service:

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

Verify the OpenNMS service is running:

sudo systemctl status opennms
**Output**
● opennms.service - OpenNMS server
     Loaded: loaded (/usr/lib/systemd/system/opennms.service; enabled; vendor p>
     Active: **active** (**running**) since Wed 2023-03-15 06:41:54 EDT; 2s ago
    Process: 75440 ExecStart=/opt/opennms/bin/opennms -s start (code=exited, st>
    Process: 76419 ExecStartPost=/bin/sleep 3 (code=exited, status=0/SUCCESS)
   Main PID: 76418 (java)
      Tasks: 44 (limit: 23609)
     Memory: 229.9M
        CPU: 17.746s
     CGroup: /system.slice/opennms.service
...

5. Configure Firewall For OpenNMS

If you have firewalld enabled, allow port 8980 through the firewall:

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 Horizon Web Interface

Access OpenNMS Horizon through your web browser by navigating to:

http://server-ip-address:8980/opennms

Log in using the default username admin and password admin.

[OpenNMS Horizon Login]

[OpenNMS Dashboard AlmaLinux 9]

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

[Change default Admin Password OpenNMS]

[Add New Admin Password for OpenNMS]

7. How To Monitor Systems with OpenNMS

To monitor systems, add them to OpenNMS by clicking the "+" icon.

[Add node to OpenNMS]

Enter the required details, such as requisition, IP Address, and Node Label, and click Provision.

[OpenNMS Node Credentials]

After adding the node, it will appear under Info -> Nodes.

[Monitor Devices with OpenNMS ALmaLinux 9]

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

For more information, visit OpenNMS Documentation.

Conclusion

You have successfully installed and configured Install and Configure OpenNMS on AlmaLinux 9. This setup provides a scalable solution for managing enterprise networks. Install and Configure OpenNMS on AlmaLinux 9 is now complete.

You may also like these articles:

How To Set up SFTP Server on AlmaLinux 9

Install and Use Vagrant on AlmaLinux 8

Telegram Desktop AlmaLinux 9

Running Nginx in Container AlmaLinux 9

TeamViewer Setup AlmaLinux 9

Install Adminer on AlmaLinux 9 with LAMP Stack

PHP ionCube Loader Setup AlmaLinux 9

Alternative Solutions for Network Monitoring on AlmaLinux 9

While OpenNMS provides a comprehensive network monitoring solution, other options exist that might be better suited depending on specific needs and preferences. Here are two alternative solutions:

1. Zabbix

Zabbix is another powerful open-source network monitoring solution. It offers similar features to OpenNMS, including network, server, and application monitoring. However, Zabbix is often praised for its ease of use and configuration, making it a good choice for smaller teams or those new to network monitoring.

Explanation:

Zabbix uses agents installed on monitored hosts to collect data actively. It also supports agentless monitoring via protocols like SNMP, SSH, and Telnet. Zabbix’s web interface is intuitive, and its templating system allows for easy configuration of monitoring for common devices and services. Zabbix is highly scalable and can handle large and complex environments.

Installation and Configuration Steps:

  1. Install Zabbix Repository:

    sudo rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-1.el9.noarch.rpm
    sudo dnf clean all
  2. Install Zabbix Server, Frontend, and Agent:

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

    sudo -u postgres createuser --pwprompt zabbix
    sudo -u postgres createdb -O zabbix zabbix
  4. Import Initial Schema and Data:

    zcat /usr/share/zabbix-sql-scripts/postgresql/create.sql.gz | sudo -u zabbix psql zabbix
  5. Configure Zabbix Server:

    Edit /etc/zabbix/zabbix_server.conf and set the database credentials:

    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPassword=your_zabbix_password
  6. Configure Apache for Zabbix Frontend:

    Edit /etc/httpd/conf.d/zabbix.conf and uncomment or add the following lines to set the timezone. Replace "America/Los_Angeles" with your timezone.

    php_value date.timezone America/Los_Angeles
  7. Start and Enable Zabbix Server, Agent, and Apache:

    sudo systemctl restart httpd
    sudo systemctl enable zabbix-server zabbix-agent httpd
    sudo systemctl start zabbix-server zabbix-agent httpd
  8. Access Zabbix Web Interface:

    Open your web browser and navigate to http://server-ip-address/zabbix. The default credentials are Admin (username) and zabbix (password).

2. Prometheus and Grafana

Prometheus is a popular open-source monitoring solution focused on time-series data. Grafana is a data visualization and monitoring platform that integrates well with Prometheus. This combination provides a flexible and powerful monitoring solution, particularly well-suited for cloud-native environments.

Explanation:

Prometheus scrapes metrics from targets, stores them as time-series data, and provides a powerful query language (PromQL) for analysis. Grafana then visualizes this data, allowing you to create dashboards and alerts. Prometheus is highly scalable and supports service discovery, making it ideal for dynamic environments.

Installation and Configuration Steps:

  1. Install Prometheus:

    Download the latest Prometheus binary from the official website or use a package manager. For example, using 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
    sudo mv prometheus /usr/local/bin/
    sudo mv promtool /usr/local/bin/
    sudo mkdir /etc/prometheus
    sudo mkdir /var/lib/prometheus
    sudo mv prometheus.yml /etc/prometheus/
    sudo mv consoles /etc/prometheus/
    sudo mv console_libraries /etc/prometheus/
  2. Create a Prometheus Systemd Service:

    Create a file /etc/systemd/system/prometheus.service with the following content:

    [Unit]
    Description=Prometheus
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    User=root
    Group=root
    Type=simple
    ExecStart=/usr/local/bin/prometheus 
        --config.file=/etc/prometheus/prometheus.yml 
        --storage.tsdb.path=/var/lib/prometheus/ 
        --web.console.templates=/etc/prometheus/consoles 
        --web.console.libraries=/etc/prometheus/console_libraries
    
    [Install]
    WantedBy=multi-user.target
  3. Start and Enable Prometheus:

    sudo systemctl enable prometheus
    sudo systemctl start prometheus
    sudo systemctl status prometheus
  4. Install Grafana:

    sudo dnf install https://dl.grafana.com/oss/release/grafana-9.1.0-1.x86_64.rpm
  5. Start and Enable Grafana:

    sudo systemctl enable grafana-server
    sudo systemctl start grafana-server
    sudo systemctl status grafana-server
  6. Access Grafana Web Interface:

    Open your web browser and navigate to http://server-ip-address:3000. The default credentials are admin (username) and admin (password).

  7. Add Prometheus as a Data Source in Grafana:

    In Grafana, navigate to Configuration -> Data Sources and add Prometheus as a data source. Set the URL to http://localhost:9090 (or the IP address where Prometheus is running).

These alternative solutions offer different strengths and weaknesses compared to OpenNMS. Zabbix provides a more user-friendly experience, while Prometheus and Grafana offer greater flexibility and scalability, especially in cloud-native environments. Choosing the right solution depends on your specific requirements and expertise.

Leave a Reply

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