diy8187 发表于 2013-1-12 16:20:00

OpenNMS Installation Under Linux

OpenNMS Installation Under Linux

This document is OpenNMS installation guide under Redhat Linux Enterprise Server 5.0. Start OpenNMS installation, you need to prepare following packages:
jdk-1_5_0_15-linux-i586.bin
jakarta-tomcat-4.1.31.tar.gz
postgresql-7.3.21.tar.gz
rrdtool-1.0.50.tar.gz
opennms-1.2.9-0_rhel5.i386.rpm
opennms-webapp-1.2.9-0_rhel5.i386.rpm
(Note: Assume all packages copy to directory /home/jacky)
1. JDK Installation

Unpack jdk with following command. vi ~/.bash_profile
# chmod +x jdk-1_5_0_15-linux-i586.bin
# ./jdk-1_5_0_15-linux-i586.bin
Reading Binary Code License Agreement and input “yes” to agree to license terms. After unpacking, rename directory jdk1.5.0_15 to java directory and move it to /opt.
# mv jdk1.5.0_15 java
# mv java /opt
Setup Environment variable for java home.Insert the following entries in /etc/profile.
# vi /etc/profile

JAVA_HOME=/opt/java
export JAVA_HOME
Save the file then exit and run the command to read /etc/profile.
# source /etc/profile
Input java -version check jdk install.
# java -version
java version "1.5.0_15"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
Java HotSpot(TM) Server VM (build 1.5.0_15-b04, mixed mode)

Notes: If you system had installed jdk, be likely to return following statement when input java -version, please input following command solve out this problem.
# java -version
-bash: /usr/bin/java: Permission denied
# cd /usr/bin
# chmod +x java
# java -version
Error: could not find libjava.so
Error: could not find Java 2 Runtime Environment.
# ln -s /opt/java/bin/java /usr/bin/java
ln: creating symbolic link `/usr/bin/java' to `/opt/java/bin/java': File exists
# mv /usr/bin/java /usr/bin/java.bak
mv: overwrite `/usr/bin/java.bak'? yes
# ln -s /opt/java/bin/java /usr/bin/java
# java -version
java version "1.5.0_15"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
Java HotSpot(TM) Server VM (build 1.5.0_15-b04, mixed mode)
2. Tomcat Installation

Add tomcat group and tomcat user under group, modfiy password to tomcat.
# groupadd tomcat
# useradd -g tomcat -d /opt/tomcat tomcat
# passwd tomcat
Changing password for user tomcat.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
Decompressing tomcat tar.gz file, rename apache-tomcat-4.1.37 to tomcat and then move it to /opt folder.
# tar -zxvf apache-tomcat-4.1.37.tar.gz

# mv apache-tomcat-4.1.37 tomcat
# mv tomcat/* /opt/tomcat/
# chown -R tomcat.tomcat /opt/tomcat
# chown -R tomcat.tomcat /opt/tomcat/logs
# su - tomcat
Setup Environment variable for tomcat home. Insert the following entries in /etc/profile.
$ vi /etc/profile

CATALINA_HOME=/opt/tomcat
export CATALINA_HOME
Save the file then exit and run the command to read /etc/profile.
$ source /etc/profile
Start tomcat
$ /opt/tomcat/bin/startup.sh
Stop tomcat
$ /opt/tomcat/bin/shutdown.sh
3. RRDTool Installation

Untar tar.gz file, and run the following commands to make and install rrdtool.
# tar -zxvf rrdtool-1.0.50.tar.gz
# cd rrdtool-1.0.50
# ./configure --prefix=/opt/rrdtool;make;make install
When you run configure script, it may ask to install cgilib, if you don't have cgilib on your system, download cgilib from sourceforge.net and install it.
Then run the above commands again to install rrdtool.
Setup Environment variable for rrdtool home. Insert the following entries in /etc/profile.
# vi /etc/profile

RRDTOOL_HOME=/opt/rrdtool
export RRDTOOL_HOME
Save the file then exit and run the command to read /etc/profile.
#source /etc/profile
4. PostgreSQL Installation

Add tomcat group and tomcat user under group, modfiy password to tomcat.
# groupadd postgres
# useradd -g postgres -d /opt/pgsql postgres
# passwd postgres
Changing password for user postgres.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
# chown -R postgres.postgres /opt/pgsql
Untar tar.gz file, and run the following commands to make and install postgresql.
# tar -zxvf postgresql-7.3.21.tar.gz
# cd postgresql-7.3.21
# ./configure --prefix=/opt/pgsql
# make && make install
After this process, add a user to manage postgresql and define home directory /opt/pqsql/ for this user.
# cd /opt/pgsql/
# mkdir /opt/pgsql/data
# chown postgres /opt/pgsql/data
# su - postgres
$ cd /opt/pgsql/
$ bin/initdb -D data/
Modfy postgresql connection parameters
$ vi /opt/pgsql/data/postgresql.conf

tcpip_socket = true
max_connections = 256
shared_buffers = 1024

Copy postgresql src/include *.h file to /opt/pgsql/include, but don’t overwrite exists file.
# cd /home/jacky/postgresql-7.3.21/
# cp -rf src/include /opt/pgsql/
cp: overwrite `/opt/pgsql/include/postgres_ext.h'? no
cp: overwrite `/opt/pgsql/include/libpq/libpq-fs.h'? no
cp: overwrite `/opt/pgsql/include/pg_config.h'? no
cp: overwrite `/opt/pgsql/include/pg_config_os.h'? no

Setup Environment variable for postgres home. Insert the following entries in /etc/profile.
# vi /etc/profile

POSTGRES_HOME="/opt/pgsql"
export POSTGRES_HOME
Save the file then exit and run the command to read /etc/profile.
# source /etc/profile

Start database use postgres user
su - postgres postmaster -i -D ~/data &
or
su - postgres -c "/opt/pgsql/bin/pg_ctl -D /opt/pgsql/data -l logfile start"
5. OpenNMS Installation

Install core and webapp OpenNMS of no dependencies with rpm package. Then OpenNMS default setup to directory /opt/opennms.
# rpm -ivh --nodeps opennms-1.2.9-0_rhel5.i386.rpm
Preparing... ###########################################
1:opennms ###########################################
- moving *.sql.rpmnew files (if any)... done
- checking for old update files... done

*** Installation complete. You must still run the installer and
*** make a few other changes before you start OpenNMS. See the
*** install guide and release notes for details.

# rpm -ivh --nodeps opennms-webapp-1.2.9-0_rhel5.i386.rpm
Preparing... ###########################################
1:opennms-webapp ###########################################

Now you can run following command to install opennms
# sh build.sh install
It will take time to complete installation process.
Setup Environment variable for OpenNMS home. Insert the following entries in /etc/profile.
# vi /etc/profile

OPENNMS_HOME=/opt/opennms
export OPENNMS_HOME
Save the file then exit and run the command to read /etc/profile.
# source /etc/profile

6. OpenNMS Configuration

Before config OpenNMS, MUST start Postgresql.
Run the following commands to configure OpenNMS.
# /opt/opennms/bin/runjava -s
runjava: Looking for an appropriate JRE...
runjava: Checking for an appropriate JRE in JAVA_HOME...
runjava: found: "/opt/java/bin/java" is an appropriate JRE
runjava: value of "/opt/java/bin/java" stored in configuration file
# /opt/opennms/bin/runjava -S /opt/java/jre/bin/java
runjava: checking specified JRE: "/opt/java/jre/bin/java"...
runjava: specified JRE is good.
runjava: value of "/opt/java/jre/bin/java" stored in configuration file
Now run following command to create OpenNMS database and make sure postgres service is running.
# su - postgres -c "/opt/pgsql/bin/pg_ctl -D /opt/pgsql/data -l logfile stop"
# su - postgres -c "/opt/pgsql/bin/postmaster -i -D /opt/pgsql/data &"

# /opt/opennms/bin/install -disU

Set opennms web application environment
# /opt/opennms/bin/install -y -w /opt/tomcat/webapps/ -W /opt/tomcat/server/lib

Configure auto discovery
Go into following directory, open the discovery-configuration.xml with vi and add your ip range in begin and end tags.
# cd /opt/opennms/etc/
# vi discovery-configuration.xml

<discovery-configuration threads="1" packets-per-second="1"
initial-sleep-time="300000" restart-sleep-time="86400000"
retries="3" timeout="800">
<include-range retries="2" timeout="3000">
<begin>192.168.6.1</begin>
<end>192.168.6.254</end>
</include-range>
<include-url>file:/opt/OpenNMS/etc/include</include-url>
</discovery-configuration>
7. OpenNMS Start up

Run the following commands to start services.
# su - postgres -c "/opt/pgsql/bin/pg_ctl -D /opt/pgsql/data -l logfile restart"
# su - tomcat -c "/opt/tomcat/bin/startup.sh"
# /opt/opennms/bin/install -disU
# /opt/opennms/bin/install -y -w /opt/tomcat/webapps/ -W /opt/tomcat/server/lib
# /opt/opennms/bin/opennms.sh start

Now you can login to main page of OpenNMS in your browser.
http://localhost:8080/opennms
Use user name "admin" and password "admin" to logging to main page.
页: [1]
查看完整版本: OpenNMS Installation Under Linux