Content

Setup OpenNMS in CentOS 6

OpenNMS is a carrier-grade, highly integrated, open source platform designed for building network monitoring solutions. It has the capability to discover and monitor the nodes automatically in a network. Also you can monitor a service by assigning it to OpenNMS.  It can do both automated and directed discovery too.

Prerequisites:

Before starting installation process, we have to make sure to configure few prerequisites.
Make SELINUX in permissive mode.
Edit file /etc/selinux/config,

[root@demohost ~]# vi /etc/selinux/config
[...]
SELINUX=permissive
[...]

Configure FQDN for your host.
Edit /etc/hosts and add fully qualified domain name.

[root@demohost ~]# vi /etc/hosts
127.0.0.1       localhost localhost.localdomain localhost4 localhost4.localdomain4
::1             localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1       demohost.hostingwikipedia.com demohost

1. Install JAVA

Go to the Oracle Java download page and download the required version of JAVA depending upon your distribution architecture. We will download the 64 bit binary  jdk-8u101-linux-x64.tar.gz
Download jdk using wget

[root@demohost ~]# wget -q http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-x64.tar.gz?AuthParam=1472147347_a77a7595ea847d98f1194ce2db1dd53e
[root@demohost ~]# mv jdk-8u101-linux-x64.tar.gz\?AuthParam\=1472147347_a77a7595ea847d98f1194ce2db1dd53e jdk-8u101-linux-x64.tar.gz

Extract the downloaded jdk folder

[root@demohost ~]# tar xf jdk-8u101-linux-x64.tar.gz

Create home directory for JAVA

[root@demohost ~]# mkdir -p /usr/local/java

Move the downloaded java binaries inside JAVA_HOME

[root@demohost ~]# mv jdk1.8.0_101/* /usr/local/java

Add JAVA_HOME environment variable to the profile and update the PATH variable.

[root@demohost java]# echo "export JAVA_HOME=/usr/local/java" >> /etc/profile
[root@demohost java]# echo "export PATH=$PATH:/usr/local/java/bin" >> /etc/profile

Reload new profile

[root@demohost java]# source /etc/profile

Check the version of JAVA

[root@demohost java]# java -version
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

2. Install PostgreSQL

To install PostgreSQL, add its repository in your system and update rpm database.

[root@demohost ~]# rpm -Uvh https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-3.noarch.rpm
[root@demohost ~]# yum update

Now install postgreSQL using yum

[root@demohost ~]# yum install postgresql94-server postgresql94-contrib

Initialize postgresql database

[root@demohost ~]# service postgresql-9.4 initdb

Start postgresql service

[root@demohost ~]# service postgresql-9.4 start

Make postgreSQL to start automatically on every reboot

[root@demohost ~]# chkconfig postgresql-9.4 on

Adjust IPTABLE rule to access postgreSQL from remote system.

[root@demohost ~]# iptables -I INPUT -p tcp -m tcp --dport 5432 -j ACCEPT
[root@demohost ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@demohost ~]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

Execute the following command to access PostgreSQL if you enable SELinux at later stages in your system.

[root@demohost ~]# setsebool -P httpd_can_network_connect_db 1

PostgreSQL only allows to connect if someone is logged in to the local account name that matches the PostgreSQL user. But OpenNMS runs as root and hence it cannot connect as a “postgres” or “opennms” user. To do it, edit postgresql database’s pg_hba.conf file and change the following lines last word to trust.

local   all         all                           peer
host    all         all         127.0.0.1/32      ident
host    all         all         ::1/128           ident
[root@demohost ~]# vi /var/lib/pgsql/9.4/data/pg_hba.conf
local   all         all                                            trust
host    all         all         127.0.0.1/32                       trust
host    all         all         ::1/128                            trust

Now restart postgresql service

[root@demohost ~]# service postgresql-9.4 restart
Stopping postgresql-9.4 service:                             [  OK  ]
Starting postgresql-9.4 service:                             [  OK  ]

Make sure the postgreSQL database format is unicode, if not then use the following procedure to make it unicode.

[root@demohost ~]# su - postgres
-bash-4.1$ psql
psql (9.4.9)
Type "help" for help.
postgres=#
postgres=# UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
UPDATE 1
postgres=# DROP DATABASE template1;
DROP DATABASE
postgres=# CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
CREATE DATABASE
postgres=# UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
UPDATE 1
postgres=# \c template1
You are now connected to database "template1" as user "postgres".
template1=# VACUUM FREEZE;
VACUUM
template1=#

Now, create a database by the name opennms.

[root@demohost ~]# su - postgres -c "createdb -U postgres opennms"

3. Install OpenNMS

First install stable repository.

[root@demohost ~]# rpm -ivh http://yum.opennms.org/repofiles/opennms-repo-stable-rhel6.noarch.rpm
Retrieving http://yum.opennms.org/repofiles/opennms-repo-stable-rhel6.noarch.rpm
warning: /var/tmp/rpm-tmp.7u2bkW: Header V3 DSA/SHA1 Signature, key ID 5b9efd43: NOKEY
Preparing...                      ########################################### [100%]
1:opennms-repo-stable             ########################################### [100%]

Update the rpm database

[root@demohost java]# yum update

Edit repository file to do a manual upgrade instead of automatic update. You can skip this step if you want automatic update. Edit the file /etc/yum.repos.d/opennms-repo-stable-rhel6.repo

# vi /etc/yum.repos.d/opennms-stable-rhel7.repo

Find for the line enabled=1, and change it to enabled=0 inside each [openn-*] section. Now install it using yum.

[root@demohost java]# yum install opennms -y --nogpgcheck
Total size: 738 M
Installed size: 972 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : 2000:jdk1.8.0_60-1.8.0_60-fcs.x86_64                                                                                               1/6
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
jfxrt.jar...
Installing : jicmp6-1.2.4-1.x86_64                                                                                                                        2/6
Installing : jicmp-1.4.5-2.x86_64                                                                                                                          3/6
Installing : opennms-core-18.0.1-1.noarch                                                                                                          4/6
...............
...............
...............
- moving *.sql.rpmnew files (if any)... done
- checking for old update files... done
runjava: Looking for an appropriate JRE...
runjava: Checking for an appropriate JRE in JAVA_HOME...
runjava: found: "/usr/local/java/bin/java" is an appropriate JRE
runjava: value of "/usr/local/java/bin/java" stored in configuration file
*** Installation complete.  You must still run the installer at
.................
.................
.................
Installed:
opennms.noarch 0:18.0.1-1

Tell OpenNMS to use which version of Java.

[root@demohost ~]# /opt/opennms/bin/runjava -S /usr/local/java/bin/java
runjava: checking specified JRE: "/usr/local/java/bin/java"...
runjava: specified JRE is good.
runjava: value of "/usr/local/java/bin/java" stored in configuration file.

Run the installer to setup OpenNMS

[root@demohost ~]# /opt/opennms/bin/install -dis
==============================================================================
OpenNMS Installer
==============================================================================
Configures PostgreSQL tables, users, and other miscellaneous settings.
DEBUG: Platform is IPv6 ready: true
- searching for libjicmp.so:
- trying to load /usr/lib64/libjicmp.so: OK
- searching for libjicmp6.so:
- trying to load /usr/lib64/libjicmp6.so: OK
- searching for libjrrd.so:
- trying to load /usr/lib64/libjrrd.so: NO
- trying to load /usr/lib64/libjrrd.so: NO
….......
….......
….......
Finished in 0 seconds
Processing MonitoringLocationsMigratorOffline: Moves monitoring locations from monitoring-locations.xml into the monitoringlocations tables in the database
- Running pre-execution phase
- Running execution phase
- Saving the execution state
- Running post-execution phase
Finished in 0 seconds
Processing DataCollectionConfigMigrator17Offline: Fixes the missing resource types on datacollection-config.xml. See NMS-7816.
- Running pre-execution phase
.....................
.....................
- Saving the execution state
- Running post-execution phase
Removing backup /opt/opennms/etc/datacollection-config.xml.zip
Finished in 1 second
Processing EOLServiceConfigMigratorOffline: Fixes service-configuration.xml if necessary when upgrading to 17.0.0: HZN-545
- Running pre-execution phase
................
................
................
Finished in 0 seconds
Processing DiscoveryConfigurationMigratorOffline: Removes the 'threads' attribute from discovery-configuration.xml. See HZN-599.
- Running pre-execution phase
Backing up discovery-configuration.xml
Zipping /opt/opennms/etc/discovery-configuration.xml
- Running execution phase
- Saving the execution state
- Running post-execution phase
Removing backup /opt/opennms/etc/discovery-configuration.xml.zip
Finished in 0 seconds
Upgrade completed successfully!

4. Configure firewall

Configure firewall to allow OpenNMS management interface port no 8980

 [root@demohost ~]# iptables -I INPUT -p tcp -m tcp --dport 8980 -j ACCEPT
[root@demohost ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@demohost ~]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter        [  OK  ]
iptables: Flushing firewall rules:                       [  OK  ]
iptables: Unloading modules:                             [  OK  ]
iptables: Applying firewall rules:                       [  OK  ]

Start it and make it start during boot.

[root@demohost ~]# service opennms start
[root@demohost ~]# chkconfig opennms on

5. Access Management Interface

Open your favorite browser and navigate to http://domain-name:8980/opennms/  Provide username and password as admin/admin, you will be redirected to the dashboard.

 

OpenNMS Login Page

 

Once logged in, you will be redirected to Dashboard

 

OpenNMS Dashboard

 

Goto to Admin->Quick add node. Provide requisition name, IP address, Node label and hit “Provision” button at the bottom. You will get a confirmation about node is being added.

 

Quick add node

 

Now Goto Info->Nodes and find out the node by its label name. Finally click the label, you will now able to view its status, notification, events etc.

 

Display node info

 

This way you can add more node for monitoring/surveillance.

Was this article helpful to you?

DD2016

Comments are closed.