Install and Configure OpenNMS on AlmaLinux 9

This tutorial intends to show you to Install and Configure OpenNMS Horizon on AlmaLinux 9.

OpenNMS is a free, open-source, and one of the most powerful network monitoring and network management platforms used for monitoring remote devices from a central location. It supports many functionalities including, Provisioning, Services Monitoring, Event managing, chart support, and more. OpenNMS uses SNMP and JMX and gathers information from remote systems. It runs on Linux and Windows operating systems and provides a web-based interface for easy monitoring.

Steps To Install and Configure OpenNMS on AlmaLinux 9

To complete this guide, log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 9.

Install Java on AlmaLinux 9

Because OpenNMS is written in Java, you must have Java installed on your server. First, run the system update:

sudo dnf update -y

Now use the command below to install Java on AlmaLinx 9:

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

Verify your 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)

Set up OpenNMS on AlmaLinux 9

The OpenNMS packages aren’t available in the default AlmaLinux repository. So you need to add it manually.

Import OpenNMS GPG Key

At this point, you need to use the following command to import the OpenNMS GPG key:

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

Add OpenNMS Repository

Then, you need to add the OpenNMS repo to your server by using the command below:

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

Install OpenNMS on AlmaLinux 9

Now you can easily use the command below to install OpenNMS:

sudo dnf install opennms -y

This will install all the dependencies on your server.

Configure PostgreSQL for OpenNMS on AlmaLinux 9

When your dependencies and OpenNMS are installed on your server, you need to configure PostgreSQL.

First, you need to initialize the PostgreSQL by using the following command:

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

Then, start and enable the PostgreSQL service with the following commands:

# sudo systemctl enable postgresql
# sudo systemctl start postgresql

Verify your PostgreSQL is active and running on AlmaLinux 9:

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
...

Next, switch to your PostgreSQL user:

sudo -i -u postgres

Create OpenNMS Database and User

At this point, use the following command to create an OpenNMS user:

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

Then, create the OpenNMS database on AlmaLinux 9 by using the command below:

createdb -O opennms opennms

Next, 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

At this point, you need to open the following file to modify the PostgreSQL access policy:

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

Find the lines below and modify them by replacing ident with MD5:

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

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

When you are done, save and close the file.

To apply the changes, restart PostgreSQL:

sudo systemctl restart postgresql

Define database credentials in OpenNMS Config File

At this point, you need to define the database credentials in the OpenNMS config file. Open the file with your favorite text editor, here we use vi:

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

Find the lines below and define your database credentials:

<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>

When you are done, save and close the file.

Manage OpenNMS Service on AlmaLinux 9

First, you need to 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

At this point, you can use the following commands to start and enable your OpenNMS service:

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

Verify your OpenNMS service is active and running on AlmaLinux 9:

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
...

Configure Firewall For OpenNMS

Here we assumed that you have enabled firewalld. By default, OpenNMS is listening on port 8980. You have to allow this port through the firewall using the following command:

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

Reload the firewall to apply the changes:

sudo firewall-cmd --reload

If your SELinux is enabled on your server, you have to allow the port through SELinux:

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

Access OpenNMS Web Interface

At this point, you can access OpenNMS Horizon through the Web interface on AlmaLinux 9 by typing your server’s IP address in your web browser followed by 8980/opennms:

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

You will see the OpenNMS horizon login screen. Enter admin as the username and password and click Login.

OpenNMS Login
OpenNMS Login

Then, you should see the OpenNMS dashboard on AlmaLinux 9.

OpenNMS Dashboard AlmaLinux 9
OpenNMS Dashboard

You can now change the password to a preferred one 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

How To Monitor Systems with OpenNMS

To be able to monitor systems, you need to add them to OpenNMS. Begin by clicking on the “+“ icon as shown below.

Add node to OpenNMS
Add node

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

OpenNMS Node Credentials
Node Credentials

After the node has been added, it will appear under Info → Nodes.

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

Monitor Devices with OpenNMS ALmaLinux 9
Monitor Devices

For more information, you can visit OpenNMS Documentation.

Conclusion

At this point, you have learned to Install and Configure OpenNMS Horizon on AlmaLinux 9.

Hope you enjoy it. You may be like these articles:

How To Set up SFTP Server on AlmaLinux 9

Install and Use Vagrant on AlmaLinux 8

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!