OpenNMS is a robust and versatile network monitoring and management platform that allows you to monitor remote devices from a centralized location. It is an open-source solution that offers a wide range of functionalities, including provisioning, service monitoring, event management, and chart support. With support for SNMP and JMX, OpenNMS gathers information from various systems and provides a web-based interface for easy monitoring. In this tutorial, we will guide you through the installation process of OpenNMS on Debian 11.
Prerequisites
Before we begin, make sure you have the following prerequisites in place:
- A server running Debian 11.
- A valid domain name pointed to your server’s IP address.
- Root access to the server.
Install Java on Debian 11
OpenNMS is a Java-based application, so the first step is to install Java on your Debian 11 server. If Java is not already installed, you can install it by running the following command:
apt-get installdefault-jdk -y
Once the installation is complete, verify the Java version by running the command:
java --version
Make a note of the Java version displayed in the output, as it will be useful later.
Install OpenNMS on Debian 11
By default, OpenNMS is not included in the Debian 11 main repository. To install OpenNMS, you need to add the official OpenNMS repository to the APT package manager.
Start by installing the required dependencies with the following command:
apt-get install curl gnupg2 wget -y
Once the dependencies are installed, create a new OpenNMS repository file:
nano /etc/apt/sources.list.d/opennms.list
In the file, add the following lines:
deb https://debian.opennms.org stable main deb-src https://debian.opennms.org stable main
Save and close the file. Next, import the GPG key for the OpenNMS repository:
wget -O https://debian.opennms.org/OPENNMS-GPG-KEY | apt-key add-
Update the package repository cache and install OpenNMS:
apt-get update -y apt-get install opennms -y
During the installation, you might encounter an error related to the installation of iplike
. To resolve this error, you need to create a database and user for OpenNMS in PostgreSQL.
Create a Database in PostgreSQL
PostgreSQL is automatically installed during the OpenNMS installation process. To create a database and user for OpenNMS, follow these steps:
Start the PostgreSQL service:
systemctl start postgresql
Connect to the PostgreSQL instance as the postgres
user:
su - postgres
Create a user for OpenNMS and set a password:
createuser opennms psql -c "ALTER USER opennms WITH PASSWORD 'opennms';"
Create a database for OpenNMS and set a password for the postgres
user:
createdb -O opennms opennms psql -c "ALTER USER postgres WITH PASSWORD 'securepassword';"
Exit the PostgreSQL shell:
exit
With the database and user created, you can now proceed to configure OpenNMS.
Configure OpenNMS
To configure OpenNMS, you need to edit the OpenNMS data source file and define the database credentials.
nano /usr/share/opennms /etc/opennms-datasources.xml
In the file, locate the following lines:
<jdbc-data-source name="opennms" database-name="opennms" class-name="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/opennms" user-name="opennms" password="opennms" /> <jdbc-data-source name="opennms-admin" database-name="template1" class-name="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/template1" user-name="postgres" password="securepassword" />
Replace the url
,user-name
, and password
values with the appropriate database credentials you set earlier.
Save and close the file. Next, check the Java environment:
sudo -u opennms /usr/share/opennms/bin/runjava -s
Make sure that the output shows the correct path to the Java executable.
Finally, run the following command to complete the OpenNMS setup:
sudo -u opennms /usr/share/opennms/bin/install-dis
Once the setup is complete, you can start the OpenNMS service.
Start OpenNMS Service
To start the OpenNMS service and enable it to start at system reboot, run the following commands:
systemctl start opennms systemctl enable opennms
You can verify the status of the OpenNMS service by running:
systemctl status opennms
OpenNMS should be up and running, listening on port 8980. You can confirm this by running the following command:
ss -antpl | grep 8980
If everything is working correctly, you should see an output indicating that OpenNMS is listening on port 8980.
Configure Nginx as a Reverse Proxy for OpenNMS
To enhance the security and performance of OpenNMS, it is recommended to set up Nginx as a reverse proxy. This allows Nginx to handle incoming requests and forward them to the OpenNMS server.
Start by installing Nginx:
apt-get install nginx -y
Once Nginx is installed, create a new Nginx virtual host configuration file:
nano /etc/nginx/conf.d/opennms.conf
In the file, add the following configuration:
server { listen 80; server_name opennms.example.com; access_log /var/log/nginx/opennms.access.log; error_log /var/log/nginx/opennms.error.log; location / { proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-OpenNMS-Server-URL https://nms.hacc.edu/; proxy_pass http://server-ip:8980; } }
Replace opennms.example.com
with your actual domain name and server-ip
with the IP address of your server.
Save and close the file. Verify the Nginx configuration for any syntax errors:
nginx -t
If there are no errors, restart the Nginx service to apply the changes:
systemctl restart nginx
You can check the status of the Nginx service with the following command:
systemctl status nginx
Nginx should be running and ready to handle requests.
Access OpenNMS Dashboard
Now that OpenNMS and Nginx are properly configured, you can access the OpenNMS web interface.
Open your web browser and enter the URL http://opennms.example.com
(replace opennms.example.com
with your actual domain name).
You should see the OpenNMS login page. Use the default username admin
and the password you set during the setup process to log in.
Once logged in, you will be greeted with the OpenNMS dashboard, which provides an overview of your network and system status.
To change the default admin password, click on admin
in the top-right corner of the screen and select Change Password
. Follow the prompts to set a new password.
Congratulations! You have successfully installed and configured OpenNMS on Debian 11. You can now start adding remote devices to OpenNMS and monitor them from the web interface.
If you have any questions or need further assistance, feel free to reach out to our support team at Shape.host. We offer reliable and scalable cloud hosting solutions, including Cloud VPS, to help businesses optimize their network monitoring and management.