How to Install OpenNMS on Ubuntu Linux

|

,

|

OpenNMS is an open-source, enterprise-grade platform for building network monitoring solutions. It enables users to monitor, search, and analyze data from networking devices. It automatically discovers your entire network using various protocols and provides alerts through multiple channels. OpenNMS requires Java JDK, and the article provided detailed instructions on how to install it on Ubuntu…

This article explains how to install OpenNMS on Ubuntu Linux.

OpenNMS is an open-source, enterprise-grade platform to build network monitoring solutions, and you gain insights from your networking devices to make sense of their logs.

It helps you monitor, search, and analyze the vast amount of data (especially in larger environments) into a simple format you can easily read and digest.

OpenNMS automatically discovers your entire network using CDP, FDP, LLDP, OSPF, BGP, SNMP, and ARP and provides alerts via email, slack, and support for Microblog notifications via Identica / StatusNet / Twitter, and more.

Most network devices in use today support protocols that work with OpenNMS — from many significant manufacturers… including the vast majority of the networking devices deployed…

For more about OpenNMS, please check its homepage.

Since OpenNMS is based on Java and requires Java to function, you’ll want to install Java JDK. The open-source version of JavaJDK works excellently, so use the steps below to install and configure it on Ubuntu.

Install OpenJDK on Ubuntu

Run the commands below to install OpenJDK on the Ubuntu desktop.

sudo apt update
sudo apt install default-jdk

That should install the latest OpenJDK on Ubuntu. At the time of this writing, the latest OpenJDK version was 11.

After installing OpenJDK, run the commands below to configure it as the default JDK runtime for Ubuntu. To find out which version of JDK to run, type the commands below:

sudo update-alternatives --config java

If you have multiple versions, you’ll see OpenJDK on the list. If only OpenJDK is installed, you should see a message that only one alternative for Java exists.

There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-amd64/bin/java
Nothing to configure.

Take notes of where JAVA is located.

Next, copy the installation path of your preferred JDK home. Next, open the /etc/environment file:

sudo nano /etc/environment

Add the following line at the end of the file:

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

Closeout and save. Then, run the commands below to apply.

source /etc/environment

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

Downloading OpenNMS

After installing OpenJDK to your system, run the commands below to Add the apt repository in /etc/apt/sources.list.d/opennms.list and add the GPG key.

To do that, run the commands below to create new opennms—list file.

sudo nano /etc/apt/sources.list.d/opennms.list

Then copy and paste the lines below into the file and save.

deb https://debian.opennms.org stable main
deb-src https://debian.opennms.org stable main

After that, run the commands below to add the repository PGP key.

wget -O - https://debian.opennms.org/OPENNMS-GPG-KEY | sudo apt-key add -

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

sudo apt update
sudo apt install opennms

The above commands will install the OpenNMS meta package with all built-in dependencies such as jicmp6 and jicmp, OpenNMS-core, OpenNMS-web app-jetty, PostgreSQL, and postgresql-libs.

With the successfully installed packages, the OpenNMS Horizon is installed in the following directory structure:

[root@localhost /usr/share/opennms]# tree -L 1
.
└── opennms
   ├── bin
   ├── data
   ├── deploy
   ├── etc -> /etc/opennms
   ├── instances
   ├── jetty-webapps
   ├── lib -> ./java/opennms
   ├── logs -> /var/log/opennms
   ├── share -> /var/lib/opennms
   └── system

With the successfully installed packages, the OpenNMS Horizon is installed in the following directory structure:

The Debian package installs the PostgreSQL database and is already initialized. Therefore, the PostgreSQL service has already been added to the runlevel configuration for system startup.

Startup the PostgreSQL database by running the commands below:

sudo systemctl start postgresql

After installing PostgreSQL, it’s a good idea to create/change the default PostgreSQL user password. Run the below commands to create/change the user password in the bash shell, not the PostgreSQL interactive shell.

Set password for Linux user (Postgres)

sudo passwd postgres

It would be best if you were prompted to create a new Linux password for Postgres users.

Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

After setting a new password, whenever you want to access the PostgreSQL interactive shell, you’ll be prompted to confirm the password you created after running the above commands.

Next, create an opennms database user with a password and create an opennms database which is owned by the user opennms

sudo su -l postgres
createuser -P opennms
createdb -O opennms opennms

Set a password for Postgres super user.

psql -c "ALTER USER postgres WITH PASSWORD 'YOUR-POSTGRES-PASSWORD';"
exit

Next, configure database access in OpenNMS Horizon

sudo nano /etc/opennms/opennms-datasources.xml

Make the highlighted changes below, then save.

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

<jdbc-data-sourcename="opennms-admin" 
        database-name="template1" 
        class-name="org.postgresql.Driver" 
        url="jdbc:postgresql://localhost:5432/template1" 
        user-name="postgres" 
        password="YOUR-POSTGRES-PASSWORD"/>
  • Set credentials to access the PostgreSQL database
  • Set the database name OpenNMS Horizon should use
  • Set the user name to access the opennms database table
  • Set the password to access the opennms database table
  • Set the postgres user for administrative access to PostgreSQL
  • Set the password for administrative access to PostgreSQL

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-11-openjdk-amd64/bin/java

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 similar to the one below:

Output:
Processing DiscoveryConfigurationLocationMigratorOffline: Changes the name for the default location from 'localhost' to 'Default'. See HZN-940.
- Running pre-execution phase
  Backing up discovery-configuration.xml
    Zipping /usr/share/opennms/etc/discovery-configuration.xml
- Running execution phase
- Saving the execution state
- Running post-execution phase
  Removing backup /usr/share/opennms/etc/discovery-configuration.xml.zip

Finished in 0 seconds
Upgrade completed successfully!

Configure systemd to start OpenNMS Horizon on the system boot

sudo systemctl enable opennms
sudo systemctl start opennms

Finally, the OpenNMS web application at http://localhost:8980/opennms. The default login user is admin, and the password is initialized to admin.

http://localhost:8980/opennms

Username: admin
Password: admin

Log in and start configuring your settings.

Enjoy!

You may also like the post below:

Like this:



2 responses to “How to Install OpenNMS on Ubuntu Linux”

  1. ideras Avatar
    ideras

    Hi man
    just want to say thanks for sharing and your time

    it works perfect and straightforward

    thanks a lot, stay healthy n safe 05/6/20

  2. kashif muneer Avatar
    kashif muneer

    Hi
    Hope this mail find you are well
    i installed successfully opennms thank you very much now i want to change ip address and need to configure ssh and telnet kindly share me command thanks alot

Leave a Reply to ideras Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.