How to install OpenNMS network monitoring tool in CentOS 8
How to install OpenNMS network monitoring tool in CentOS 8
OpenNMS is a free and open source network monitoring and network management platform for managing corporate networks around the world. It is based on Java and aims to manage thousands of devices from a central location. It has the ability to automatically discover and monitor services or nodes in the network.
feature
- Support SNMP, JMX, WMI, NPRE, NSCLient++ and XMP
- Event-driven architecture
- Support device and application monitoring
- Typological discovery and path break
- Configure and execute service monitor
- Supports layer 2 and layer 3 network topologies
In this tutorial, we will show you how to install and configure OpenNMS on CentOS 8 server.
prerequisites
- Server running CentOS 8.
- The root password is configured for the server.
getting Started
OpenNMS is a Java-based application. Therefore, you will need to install Java in your system. You can install it along with other required packages by running the following command:
dnf install java-11-openjdk-devel curl unzip -y
After installing Java, you can verify the Java version with the following command:
java -version
You should get the following output:
openjdk version "11.0.9" 2020-10-20 LTS OpenJDK Runtime Environment 18.9 (build 11.0.9+11-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.9+11-LTS, mixed mode, sharing)
Once completed, you can proceed to the next step.
Install OpenNMS
By default, OpenNMS is not available in the CentOS 8 default repository. Therefore, you need to add the OpenNMS repository to the system.
First, use the following command to add the GPG key:
rpm --import https://yum.opennms.org/OPENNMS-GPG-KEY
After adding the GPG key, run the following command to add the OpenNMS repository.
dnf install https://yum.opennms.org/repofiles/opennms-repo-stable-rhel8.noarch.rpm
Next, you can install OpenNMS by running the following command:
dnf install opennms -y
This will install OpenNMS, PostgreSQL and other packages in your server.
Configure PostgreSQL
OpenNMS uses PostgreSQL as the database backend. You can initialize the PostgreSQL database with the following command:
postgresql-setup --initdb --unit postgresql
You should get the following output:
* Initializing database in '/var/lib/pgsql/data' * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
Next, start the PostgreSQL service and use the following command to enable it to start when the system restarts:
systemctl enable postgresqlsystemctl start postgresql
Next, you will need to create a database and user for PostgreSQL.
First, log in to PostgreSQL using the following command:
su - postgres
After logging in, use the following command to create a user:
[[email protected] ~]$ createuser -P opennms
You will be asked to set a password as shown below:
Enter password for new role: Enter it again:
Next, use the following command to create the database:
[[email protected] ~]$ createdb -O opennms opennms
Next, use the following command to set a password for the PostgreSQL user;
[[email protected] ~]$ psql -c "ALTER USER postgres WITH PASSWORD 'password';"
Next, use the following command to exit from the PostgreSQL Shell:
[[email protected] ~]$ exit;
Next, you will need to modify the PostgreSQL access policy. You can do this by editing the file /var/lib/pgsql/data/pg_hba.conf:
nano /var/lib/pgsql/data/pg_hba.conf
Find the following lines:
# IPv4 local connections: host all all 127.0.0.1/32 ident # IPv6 local connections: host all all ::1/128 ident
And, replace them with the following lines: ads
host all all 127.0.0.1/32 md5 host all all ::1/128 md5
Save and close the file, then restart the PostgreSQL service to apply the changes:
systemctl restart postgresql
Next, you will need to define the database in the /opt/opennms/etc/opennms-datasources.xml file.
nano /opt/opennms/etc/opennms-datasources.xml
Change the following lines that match the database:
<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="password" />
Save and close the file when you are done.
Initialize and start OpenNMS
Next, you will need to initialize OpenNMS. First, use the following command to add Java settings:
/opt/opennms/bin/runjava -s
You should get 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-11.0.9.11-0.el8_2.x86_64/bin/java". runjava: Value of "/usr/lib/jvm/java-11-openjdk-11.0.9.11-0.el8_2.x86_64/bin/java" stored in configuration file.
Next, initialize the database by running the following command:
/opt/opennms/bin/install -dis
Next, use the following command to enable OpenNMS to start when the system reboots:
systemctl enable --now opennms
You should get the following output:
Synchronizing state of opennms.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable opennms Created symlink /etc/systemd/system/multi-user.target.wants/opennms.service → /usr/lib/systemd/system/opennms.service.
Now, you can check the status of the OpenNMS service with the following command:
systemctl status opennms
You should get the following output:
? opennms.service - OpenNMS server Loaded: loaded (/usr/lib/systemd/system/opennms.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2020-11-25 09:21:32 EST; 13s ago Process: 26880 ExecStart=/etc/init.d/opennms -s start (code=exited, status=0/SUCCESS) Main PID: 27928 (java) Tasks: 67 (limit: 12523) Memory: 555.6M CGroup: /system.slice/opennms.service ??27927 bash /etc/init.d/opennms -s start ??27928 /usr/lib/jvm/java-11-openjdk-11.0.9.11-0.el8_2.x86_64/bin/java --add-modules=java.base,java.compiler,java.datatransfer,java> Nov 25 09:21:42 centos8 opennms[26880]: [DEBUG] System property 'opennms.library.jicmp' set to '/usr/lib64/libjicmp.so. Attempting to load ji> Nov 25 09:21:42 centos8 opennms[26880]: [INFO] Successfully loaded jicmp library. Nov 25 09:21:42 centos8 opennms[26880]: [DEBUG] System property 'opennms.library.jicmp' set to '/usr/lib64/libjicmp.so. Attempting to load ji> Nov 25 09:21:42 centos8 opennms[26880]: [INFO] Successfully loaded jicmp library. Nov 25 09:21:42 centos8 opennms[26880]: [DEBUG] System property 'opennms.library.jicmp6' set to '/usr/lib64/libjicmp6.so. Attempting to load > Nov 25 09:21:42 centos8 opennms[26880]: [INFO] Successfully loaded jicmp6 library. Nov 25 09:21:42 centos8 opennms[26880]: [DEBUG] System property 'opennms.library.jicmp' set to '/usr/lib64/libjicmp.so. Attempting to load ji> Nov 25 09:21:42 centos8 opennms[26880]: [INFO] Successfully loaded jicmp library. Nov 25 09:21:42 centos8 opennms[26880]: [DEBUG] System property 'opennms.library.jicmp6' set to '/usr/lib64/libjicmp6.so. Attempting to load > Nov 25 09:21:42 centos8 opennms[26880]: [INFO] Successfully loaded jicmp6 library.
At this point, OpenNMS has started and is listening on port 8980. You can check it with the following command:
ss -antpl | grep :8980
You should get the following output:
LISTEN 0 50 *:8980 *:* users:(("java",pid=27928,fd=988))
Once completed, you can proceed to the next step.
Configure SELinux and firewall
By default, SELinux is enabled in CentOS 8 server. Therefore, you need to disable it first. You can disable it by editing the /etc/selinux/config file:
nano /etc/selinux/config
Find the following line:
SELINUX=enforcing
And, replace it with the following line:
SELINUX=permissive
Save and close the file, then reboot the system to apply the changes.
Next, use the following command to allow port 8980 through firewalld:
firewall-cmd --permanent --add-port=8980/tcp
Next, reload firewalld to apply the changes:
firewall-cmd --reload
Once completed, you can proceed to the next step.
Access OpenNMS web interface
Now, open your web browser and use the URL to access the OpenNMS web interface http://your server-ip: 8980/opennms. You will be redirected to the OpenNMS login page:
Provide the default administrator username as admin and password as admin, then click log in Button. You should see the following page:
Click on Choose to participate Send anonymous usage statistics to OpenNMS. You should see the OpenNMS dashboard in the following page:
Click on Administrator => change password Change the default password. You should see the following page:
Change your default password and click submit Button. You should see the following page:
Click on + Icon to add a new host.You should see the following page: Ads
Provide a name for the new application and click it is good Button. You should see the following page:
Provide your remote host details and click Stipulate Button. After adding the host, you will see the following page:
Now, click Information => node. You should get the details of the remote host in the following page:
in conclusion
Congratulations! You have successfully installed OpenNMS on the CentOS 8 server. Now you can add unlimited network hosts and devices to OpenNMS and start monitoring from a central location.