Install and Configure OpenNMS on Rocky Linux 8

This tutorial intends to show you to Install and Configure OpenNMS Horizon on Rocky Linux 8.

OpenNMS is an enterprise-grade, integrated, open-source platform to build network monitoring solutions. Goals include accelerating time to production by supporting industry-standard network management protocols, agents, and a programmable provisioning system. Send alerts to on-call system engineers using a variety of implemented notification strategies. Extend the platform by using the native Java API or run scripts on the underlying operating system.

With the OpenNMS platform, there are several possibilities to forward monitoring information to integrate with management workflows.

Steps To Install and Configure OpenNMS on Rocky Linux 8

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 Rocky Linux 8.

Install Java on Rocky Linux 8

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

sudo dnf update -y

Then, install the required packages by using the command below:

sudo dnf install vim curl wget -y

Now use the command below to install Java on Rocky Linx 8:

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.el8_7) (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-2.el8_7) (build 11.0.18+10-LTS, mixed mode, sharing)

Set up OpenNMS on Rocky Linux 8

The OpenNMS packages aren’t available in the default Rocky Linux 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-rhel8.noarch.rpm -y

Install OpenNMS on Rocky Linux

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 Rocky Linux 8

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 Rocky Linux 8:

sudo systemctl status postgresql
Output
● postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor >
   Active: active (running) since Sat 2023-03-04 05:16:23 EST; 5s ago
  Process: 92932 ExecStartPre=/usr/libexec/postgresql-check-db-dir postgresql (>
 Main PID: 92935 (postmaster)
    Tasks: 8 (limit: 23699)
   Memory: 15.8M
   CGroup: /system.slice/postgresql.service
           ├─92935 /usr/bin/postmaster -D /var/lib/pgsql/data
...

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 Rocky Linux 8 by using the command below:

createdb -O opennms opennms

Next, protect the 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 Rocky Linux 8

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.el8_7.x86_64/bin/java"...
runjava: Found an appropriate JVM in the PATH: "/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-2.el8_7.x86_64/bin/java"
runjava: Value of "/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-2.el8_7.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

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 Rocky Linux 8:

sudo systemctl status opennms
Output
   Loaded: loaded (/usr/lib/systemd/system/opennms.service; enabled; vendor pre>
   Active: active (running) since Sat 2023-03-04 05:21:06 EST; 4s ago
  Process: 94430 ExecStartPost=/bin/sleep 3 (code=exited, status=0/SUCCESS)
  Process: 93439 ExecStart=/opt/opennms/bin/opennms -s start (code=exited, stat>
 Main PID: 94429 (java)
    Tasks: 44 (limit: 23699)
   Memory: 324.8M
...

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 Rocky Linux 8 by typing your server’s IP address in your web browser followed by 8980/opennms:

http://server-ip: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 Rocky Linux 8.

OpenNMS Dashboard Rocky Linux 8
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 Rocky Linux 8
Monitor Devices

For more information, you can visit OpenNMS Documentation.

Conclusion

At this point, you have learned to Install and Configure OpenNMS Horizon on Rocky Linux 8.

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

How To Install PHP 8.2 on Rocky Linux 8

Set up Python 3.11 on Rocky Linux 8

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!