How to Install OpenNMS on Ubuntu 24.04

This article outlines the installation process of OpenNMS on Ubuntu 24.04, detailing necessary steps such as installing Java and PostgreSQL, configuring the database, downloading OpenNMS, and enabling it to start on boot. The OpenNMS web application can be accessed at http://localhost:8980/opennms with default admin credentials.

This article explains how to install OpenNMS on Ubuntu 24.04.

OpenNMS is an open-source network management system that provides network performance monitoring, fault detection, and inventory management features.

Ubuntu is a widely used Linux distribution compatible with OpenNMS, ensuring a smoother installation process and ongoing updates.

If you’re considering network management solutions, OpenNMS can be a robust option when installed on Ubuntu, providing critical insights and management capabilities for your network.

Install PostgreSQL

OpenNMS also needs a database to store its content—the recommended database server to install PostgreSQL.

Run the command below to install it.

sudo apt install postgresql

After installing PostgreSQL, run the command below to create a database user account called ‘opennms‘ for PostgreSQL.

When prompted, type a secure password for the opennms database account.

sudo -u postgres createuser -P opennms

Next, run the command below to create an empty database called ‘opennms‘ and set the owner to the opennms user account created above.

sudo -u postgres createdb -O opennms opennms

Finally, run the command below to set the PostgreSQL superuser password.

sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'type_your_password';"

Replace ‘type_your_password‘ with your secure password.

Download and configure OpenNMS.

After installing Java and PostgreSQL, continue to download and configure OpenNMS below.

But first, add the openNMS repository GPG key by running the command below.

curl -fsSL https://debian.opennms.org/OPENNMS-GPG-KEY | sudo gpg --dearmor -o /usr/share/keyrings/opennms.gpg

Next, add the openNMS repository file.

echo "deb [signed-by=/usr/share/keyrings/opennms.gpg] https://debian.opennms.org stable main" | sudo tee /etc/apt/sources.list.d/opennms.list

Finally, run the commands below to install OpenNMS packages, including all dependencies.

sudo apt update
sudo apt install opennms
sudo apt install r-recommended

The command above will install Java JDK since OpenNMS depends on it.

Run the command below to see which version of Java JDK has been installed. At the time of this writing, Java JDK version 11 will be installed when you install the OpenNMS packages.

sudo update-alternatives --config java

Take notice of the version and path. Then, continue below to set your JAVA_HOME variable.

Next, run the command below to open the /etc/environment file.

sudo nano /etc/environment

Then, add the Java path displayed above at the end of the file and save.

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

Next, run the command below to apply the changes.

source /etc/environment

When you’re done, OpenJDK should be installed and ready to use.

Configure PostgreSQL database access

You can store your PostgreSQL credentials in the secure credentials vault. To do this, use the scvcli command line utility to add the credentials and reference these credentials in opennms-datasources.xml:

sudo -u opennms /usr/share/opennms/bin/scvcli set postgres opennms type_your_password 
sudo -u opennms /usr/share/opennms/bin/scvcli set postgres-admin postgres type_your_password
Replace both type_your_password instances with the actual passwords for your opennms and postgres database accounts.

Next, run the command below to open the opennms-datasources.xml file.

sudo -u opennms nano /usr/share/opennms/etc/opennms-datasources.xml

Set encrypted credentials to access the PostgreSQL database in the file below.

You shouldn’t have to do anything in the file since the encrypted credentials variables are used in the configuration.

This is how the file should look.

...
<jdbc-data-source name="opennms"
database-name="opennms"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/opennms"
user-name="${scv:postgres:username}"
password="${scv:postgres:password}" />

<jdbc-data-source name="opennms-admin"
database-name="template1"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/template1"
user-name="${scv:postgres-admin:username}"
password="${scv:postgres-admin:password}">
<connection-pool idleTimeout="600"
minPool="0"
maxPool="10"
maxSize="50" />
</jdbc-data-source>

<jdbc-data-source name="opennms-monitor"
database-name="postgres"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/postgres"
user-name="${scv:postgres-admin:username}"
password="${scv:postgres-admin:password}">
<connection-pool idleTimeout="600"
minPool="0"
maxPool="10"
maxSize="50" />
...

Save and exit.

Detect the Java environment and persist in /usr/share/opennms/etc/java.conf

sudo /usr/share/opennms/bin/runjava -s

You should see the output below:

Output:
runjava: Looking for an appropriate JVM...
runjava: Checking for an appropriate JVM in JAVA_HOME...
runjava: Found: "/usr/lib/jvm/java-11-openjdk-amd64/bin/java" is an appropriate JVM.
runjava: Value of "/usr/lib/jvm/java-11-openjdk-amd64/bin/java" stored in configuration file.

If you are getting an error starting OpenNMS, manually add the JAVA_HOME settings using the commands below:

sudo nano /etc/default/opennms

Then add the highlighted line in the file and save

# Set JAVA_HOME if it cannot be auto-detected
#JAVA_HOME=/usr/lib/jvm/java-8-oracle

JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64

Initialize the database and detect system libraries persisted in /opt/opennms/etc/libraries.properties

sudo /usr/share/opennms/bin/install -dis

You should see an output with a success message.

Next, configure the system’s service for OpenNMS to start Horizon on the system boot.

sudo systemctl enable --now opennms
sudo systemctl start opennms

Finally, the OpenNMS web application at the URL below.

http://localhost:8980/opennms

The default login user is admin, and the password is initialized to admin.

Username: admin
Password: admin

Log in and start configuring your settings.

That should do it!

Conclusion:

This guide covered the essential steps to install OpenNMS on Ubuntu 24.04 successfully. Here’s a quick recap:

  • OpenNMS Installation: Followed the installation process for OpenNMS to enable robust network management capabilities.
  • PostgreSQL Setup: Installed and configured PostgreSQL, creating a dedicated database user and setting up the necessary databases.
  • Java Configuration: Installed Java and configured the JAVA_HOME variable to ensure OpenNMS runs smoothly.
  • Security Measures: Implemented credential storage using the secure credentials vault for PostgreSQL.
  • Service Management: Enabled OpenNMS to start on system boot and initiated the service.
  • Web Access: Gained access to the OpenNMS web interface for further configuration and monitoring.

By completing these steps, you now have a fully functional OpenNMS installation that can help you monitor and manage your network effectively.

Comments

Leave a Reply

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