OpenNMS, also known as “Open Network Management System”, is a free, open-source, and powerful network management and network monitoring solution. An enterprise network management system monitors and manages various services and devices from a central location. OpenNMS can be installed on Windows and Linux-based operating systems. OpenNMS uses SNMP and JMX to collect information from remote hosts. It can be installed on various operating systems, including Windows, Mac, Linux/Unix, and Solaris.
This tutorial will teach us how to install and configure OpenNMS on an Ubuntu server.
- A server running Ubuntu. I’ll use Ubuntu 18.04 here.
- At least 2 GB RAM and 2 CPU cores.
- A root password set up on your server.
Before you start, you need to update your system to the latest version. You can do this by running the following command:
apt-get update -y apt-get upgrade -y
Once your server is updated, restart it to apply the changes.
OpenNMS is written in Java. Therefore, you need to install Java for it to work. You can install Java JDK with the following command:
apt-get install default-jdk -y
After installation, check the version of Java with the following command:
You should get the following output:
openjdk 11.0.4 2019-07-16 OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3) OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode, sharing)
When you are done, you can proceed to the next step.
OpenNMS uses the PostgreSQL database to store its data. Therefore, you need to install PostgreSQL on your server. PostgreSQL is available by default in the Ubuntu 18.04 repository. You can install it by simply running the following command:
apt-get install postgresql -y
After installing PostgreSQL, you need to allow the root user to access this database. You can allow the root user by editing the pg_hba.conf file in the /etc/postgresql/10/main/ directory:
Find the following lines:
local all all peer # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5
Replace all lines with the following lines:
local all all trust # IPv4 local connections: host all all 127.0.0.1/32 trust # IPv6 local connections: host all all ::1/128 trust
Save and close the file. Then restart the PostgreSQL service to apply all configuration changes:
systemctl restart postgresql
You can now check the status of the PostgreSQL service by running the following command:
systemctl status postgresql
If everything is ok, you should get the following output:
? postgresql.service - PostgreSQL RDBMS Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled) Active: active (exited) since Wed 2019-08-28 06:19:04 UTC; 14s ago Process: 8653 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 8653 (code=exited, status=0/SUCCESS) Aug 28 06:19:04 ubuntu1804 systemd: Starting PostgreSQL RDBMS... Aug 28 06:19:04 ubuntu1804 systemd: Started PostgreSQL RDBMS.
You can proceed to the next step when you are done with that.
By default, OpenNMS is not available in the default repository of Ubuntu 18.04. Therefore, you need to add the OpenNMS repository to your system.
To add the repository, first download the OpenNMS GPG key and add it using the following command:
wget -O - http://debian.opennms.org/OPENNMS-GPG-KEY | apt-key add -
Next, add the OpenNMS repository to the APT source list file with the following command:
Add the following lines to the end of the file:
deb http://debian.opennms.org stable main deb-src http://debian.opennms.org stable main
Save and close the file. Then update the repository and install OpenNMS with the following command:
apt-get update -y apt-get install default-mta opennms -y
When the installation is successfully completed, you can proceed to the next step.
Create a database for OpenNMS
Before you create the OpenNMS database, you need to set a password for the postgres user. Execute the following command to set the password for postgres:
Type the desired password and press Enter, as shown below:
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
After setting a new password, you will be prompted to confirm the password whenever you want to access the PostgreSQL interactive shell.
Log in as a postgres user with the following command:
su - postgres
Once logged in, create a user and database for OpenNMS with the following command:
createuser -P opennms createdb -O opennms opennms
Next, set a password for the Postgres superuser with the following command:
psql -c "ALTER USER postgres WITH PASSWORD 'opennmspassword';"
Finally, exit the Postgres shell with the following command:
Next, you need to set the database settings for OpenNMS. You can do this by editing the opennms-datasources.xml file. This is where you set the database name, database user name, database user password, and postgres user for administrative access to PostgreSQL.
Make the following changes:
<jdbc-data-source name="opennms" database-name="opennms" class-name="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/opennms" user-name="opennms" password="opennmspassword" /> <jdbc-data-source name="opennms-admin" database-name="template1" class-name="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/template1" user-name="postgres" password="password" /> </datasource-configuration>
Save and close the file when you are done. Then set the Java environment with the following command:
If everything works, you should see the following 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: "/etc/alternatives/java"... runjava: Did not find an appropriate JVM in the PATH: "/etc/alternatives/java" runjava: Searching for a good JVM... runjava: Found a good JVM in "/usr/lib/jvm/java-11-openjdk-amd64/bin/java". runjava: Value of "/usr/lib/jvm/java-11-openjdk-amd64/bin/java" stored in configuration file.
Next you need to initialize the database. You can do this with the following command:
You should see the following 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!
Finally, you need to restart the OpenNMS service so that all configuration changes are applied:
systemctl restart opennms
You can check the status of OpenNMS with the following command:
systemctl status opennms
You should get the following output:
? opennms.service - LSB: OpenNMS - Open Source Network Management System Loaded: loaded (/etc/init.d/opennms; generated) Active: active (running) since Wed 2019-08-28 06:40:19 UTC; 16s ago Docs: man:systemd-sysv-generator(8) Process: 14088 ExecStart=/etc/init.d/opennms start (code=exited, status=0/SUCCESS) Tasks: 172 (limit: 4915) CGroup: /system.slice/opennms.service ??15147 /bin/bash /usr/sbin/opennms start ??15148 /usr/lib/jvm/java-11-openjdk-amd64/bin/java --add-modules=java.base,java.compiler,java.datatransfer,java.desktop,java.instru Aug 28 06:40:14 ubuntu1804 systemd: Starting LSB: OpenNMS - Open Source Network Management System... Aug 28 06:40:19 ubuntu1804 opennms: Starting Open Network Management System: opennmsStarting OpenNMS: (not waiting for startup) ok Aug 28 06:40:19 ubuntu1804 opennms: . Aug 28 06:40:19 ubuntu1804 systemd: Started LSB: OpenNMS - Open Source Network Management System.
When you are done, you can proceed to the next step.
OpenNMS is now installed and listening on port 8980. Now it is time to access the OpenNMS web interface. To do this, open your web browser and enter the URL http://your-server-ip:8980/opennms. You will be redirected to the OpenNMS login page:
Enter the default username and password admin / admin and click the Log In button. On the following page, you should see the default OpenNMS dashboard:
For security reasons, it is recommended that you change the default admin password. To change the admin password, click admin in the right pane and then click the Change Password button. You should see the following page:
Enter your new password and click the Submit button. Once the password is changed, you should see the following page:
That’s it. You have successfully installed OpenNMS on the Ubuntu 18.04 server. You can now add multiple nodes and start monitoring from the OpenNMS dashboard. For more information, see the official OpenNMS documentation at OpenNMS Doc. If you have any questions, feel free to ask me.