Running OpenNMS with a Dedicated PostgreSQL Server
From OpenNMS
Contents |
Since 1.6.6
First you probably will need to edit pg_hba.conf on your DB server to allow connections from the OpenNMS app server. There is an opportunity here to introduce a gaping security hole if you don't know what you're doing; please require at least the md5 method for remote TCP connections. Ideally, use SSL as well.
To make OpenNMS installer create data in a remote database you should edit $OPENNMS_HOME/etc/opennms-datasources.xml. The file should reflect your database server IP address or hostname, username, and password as stated in example below:
<jdbc-data-source name="opennms"
database-name="dbname"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://dbhost:5432/dbname"
user-name="username"
password="password" />
Change the dbname, dbhost, port, username and password as needed to match your environment.
Be sure to install the iplike package on the PostgreSQL server.
After this run the OpenNMS installer as you do in a regular installation.
Old Method
The installer doesn't seem to honor the database settings specified in opennms-database.xml. As of today, it seems the installer is hard-coded to connect to PostgreSQL on localhost when run as $OPENNMS_HOME/bin/install -disU.
I can't easily or quickly recompile to change this situation, so I kluged it with an SSH port forward. There are still a few tricks to that method, so here is how to make it work.
First you probably will need to edit pg_hba.conf on your DB server to allow connections from the OpenNMS app server. There is an opportunity here to introduce a gaping security hole if you don't know what you're doing; please require at least the md5 method for remote TCP connections. Ideally, use SSL as well.
In the dialog below, appsrv is the OpenNMS collector / poller application server and dbsrv is the the database server. workstation is my workstation.
[jeffg@workstation]$ ssh root@appsrv root@appsrv's password: [root@appsrv]# ssh -L 5432:localhost:5432 root@dbsrv root@dbsrv's password: [root@dbsrv]#
What I have done here is to create a "tunnel" that makes localhost TCP port 5432 on the app server look exactly like a local instance of PostgreSQL. Leave the dbsrv shell alone for now. Now log in to the app server in a separate window and run $OPENNMS_HOME/bin/install -disU exactly as you would if PostgreSQL were installed right on the app server itself.
If you get an exception from the installer, and if a telnet test on the app server to localhost 5432 connects and then immediately dumps you back to a shell prompt, then you probably need to enable TCP port forwarding in the SSH daemon configuration on the app server. For OpenSSH, just edit /etc/ssh/sshd_config (or /usr/local/etc/ssh/sshd_config, or wherever it is on your particular system) and look for AllowTcpForwarding. If it is set to no or is entirely absent, change or add the line so that it reads AllowTcpForwarding yes. Restart the SSH daemon on the app server. Log out of the app server shell that you got to from the db server, and SSH back in with the -L 5432:localhost:5432 option. The installer should now work happily.
Old Alternative Method
This worked with Opennms 1.3.2 and Tomcat 5.5 on one server and Postgresql 8.1 on a dedicated server. YMMV
The InstallerDB class file retrieves the values for the database host url as well as other values from the installer.properties file in the opennms_install.jar file. To edit this file perform the following steps:
-
Extract the installer.properties file from opennms_install.jar
NOTE: you can also edit this file in Midnight Commander (mc) without extracting it and updating it later./usr/java/jdk1.5.0_10/bin/jar xf opennms_install.jar org/opennms/install/installer.properties
-
The installer.properties file will be extracted in the directory $OPENNMS_HOME/lib/org/opennms/install. Change the install.database.url property to point to your database.
install.database.url=jdbc:postgresql://databasehostname:5432/ -
Update the jar file
/usr/java/jdk1.5.0_10/bin/jar uf opennms_install.jar org/opennms/install/installer.properties
You can run the database installer as per the documentation. You will still need to update the pg_hba.conf file on the postgresql server to allow access from the opennms server.
Gotcha's
To get around the permission denied error for iplike.so I just created a matching $OPENNMS_HOME/lib directory on my database server and put iplike.so there.
You will need to modify the $OPENNMS_HOME/webapps/opennms/WEB-INF/web.xml and add
<context-param> <param-name>opennms.db.url</param-name> <param-value>jdbc:postgresql://yourhostname:5432/opennms</param-value> </context-param>
Old Alternative Method 2
For me, to install OpenNMS and make it use a different PostgreSQL server, I had to do the following:
- Edit the .jar file, used by the "install" tool:
/opt/OpenNMS/lib/opennms_install.jar, and in that file, look fororg/opennms/install/installer.properties. There you can specify the address of the PostgreSQL server used for installation. Note that the "install" tool will try to connect as a privileged user "postgres", with no password - so if you have a password for that user on a remote PostgreSQL server (definitely, you should have it), you may consider removing the password temporarily. Bear in mind the security risks it may be connected with. - Edit
/opt/OpenNMS/etc/opennms-database.xml, and update the server address there. This address is used when OpenNMS is running. - Edit
/opt/OpenNMS/webapps/opennms/WEB-INF/configuration.properties. Database address here is used when you connect using the web interface.









New Pages