一、安装opennms前的准备
1、安装Linux
安装linux再此不作详细,请参考相关文档
2、安装JAVA虚拟机
1)jdk安装
在网上下载下载j2sdk-1_4_2_02-linux-i586-rpm.bin;
把j2sdk-1_4_2_02-linux-i586-rpm.bin文件拷贝到系统某一目录,在此以/mypath
cp j2sdk-1_4_2_02-linux-i586-rpm.bin /mypath
cd /mypath
j2sdk-1_4_2_02-linux-i586-rpm.bin
运行它之后会显示一个许可信息 (License),同意之后,安装程序会将 JDK 解压在当前路径下的一个名为 j2sdk1.4.1_02 的目录中
然后作链接
ln -s j2sdk1.4.1_02 jdk
ln -s j2sdk1.4.1_02/jre jre
2)jdk设置
在/etc/profile文件的头上增加下面四行.这里假设JAVA安装在/mypath/j2sdk1.4.2_07目录下,mypath根据系统自己定义
JAVA_HOME=/mypath/jdk
export JAVA_HOME
PATH="$PATH:$JAVA_BIN"
export PATH
然后执行 . /etc/profile,使其生效。
3、安装TOMCAT
下载jakarta-tomcat-4.1.30.zip
然后把jakarta-tomcat-4.1.30.zip文件拷贝到LINUX中,然后在jakarta-tomcat-4.1.30.zip
所在的目录下执行
#unzip -x jakarta-tomcat-4.1.30.zip -d /temp
mv jakarta-tomcat-4.1.30 tomcat4.1.30
ln -s tomcat4.1.30 tomcat
4、postgres数据库安装
1)postgres安装
在网上下载postgresql-7.3.2.tar.gz
# useradd postgres
# passwd postgres
#new passwd: postgres
#retype passwd: postgres
# tar -zxvf source/postgresql-7.3.2.tar.gz
# cd /ir/postgresql-7.3.2
# ./configure --prefix=/usr/local/pgsql
# make
# make install
# chown -R postgres.postgres /usr/local/pgsql
# vi ~postgres/.bash_profile
添加:
PGLIB=/usr/local/pgsql/lib
PGDATA=$HOME/data
PATH=$PATH:/usr/local/pgsql/bin
MANPATH=$MANPATH:/usr/local/pgsql/man
export PGLIB PGDATA PATH MANPATH
以 postgres 用户登录,
# su – postgres
建立数据库目录:
$ mkdir data
启动数据库引擎:
$ initdb
启动服务
/usr/local/pgsql/bin/postmaster -D /home/postgres/data
or
/usr/local/pgsql/bin/pg_ctl -D /home/postgres/data -l logfile start
2)postgres配置
配置/home/postgres/data/postgresql.conf
tcpip_socket = true
max_connections = 256
shared_buffers = 1024
配置/home/postgres/data/pg_hba.conf
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
local all all trust
host all all 127.0.0.1 255.255.255.255 trust
host all all 192.168.0.254 255.255.255.0 trust
3)postgres自启动配置
vi /etc/init.d/post
#! /bin/sh
# PGVERSION is:
PGVERSION=7.3
# Source function library.
INITD=/etc/rc.d/init.d
. $INITD/functions
# Get function listing for cross-distribution logic.
TYPESET=`typeset -f|grep "declare"`
# Get config.
. /etc/sysconfig/network
# Find the name of the script
NAME=`basename $0`
# Set defaults for port and database directory
PGPORT=5432
export PGDATA=/var/lib/pgsql
if [ -f $PGDATA/PG_VERSION ] && [ -d $PGDATA/base/template1 ]
then
echo "Using old-style directory structure"
else
export PGDATA=/var/lib/pgsql/data
fi
# Override defaults from /etc/sysconfig/pgsql if file is present
[ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}
export PGDATA
export PGPORT
export PGOPTS
# Check that networking is up.
# Pretty much need it for postmaster.
[ "${NETWORKING}" = "no" ] && exit 0
[ -f /usr/bin/postmaster ] || exit 0
start(){
PSQL_START=$"Starting ${NAME} service: "
# Check for the PGDATA structure
if [ -f $PGDATA/PG_VERSION ] && [ -d $PGDATA/base ]
then
# Check version of existing PGDATA
if [ `cat $PGDATA/PG_VERSION` != '7.3' ]
then
SYSDOCDIR="(Your System's documentation directory)"
if [ -d /usr/doc/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/doc
fi
if [ -d /usr/share/doc/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/share/doc
fi
if [ -d /usr/doc/packages/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/doc/packages
fi
if [ -d /usr/share/doc/packages/postgresql-$PGVERSION ]
then
SYSDOCDIR=/usr/share/doc/packages
fi
echo
echo $"An old version of the database format was found.\nYou need to upgrade the data format before using PostgreSQL.\nSee $SYSDOCDIR/postgresql-$PGVERSION/README.rpm-dist for more information."
exit 1
# This doesn't seem to do anything useful...
# else
# if echo "$TYPESET"|grep "declare -f success ()" >/dev/null
# then
# success "$PSQL_CHECK"
# else
# echo " [ OK ]"
# fi
# echo
fi
# No existing PGDATA! Initdb it.
else
echo -n $"Initializing database: "
if [ ! -d $PGDATA ]
then
mkdir -p $PGDATA
chown postgres.postgres $PGDATA
chmod go-rwx $PGDATA
fi
# Make sure the locale from the initdb is preserved for later startups...
[ -f /etc/sysconfig/i18n ] && cp /etc/sysconfig/i18n $PGDATA/../initdb.i18n
# Just in case no locale was set, use en_US
[ ! -f /etc/sysconfig/i18n ] && echo "LANG=en_US" > $PGDATA/../initdb.i18n
# Is expanded this early to be used in the command su runs
echo "export LANG LC_ALL LC_CTYPE LC_COLLATE LC_NUMERIC LC_CTYPE LC_TIME" >> $PGDATA/../initdb.i18n
# Initialize the database
su -l postgres -s /bin/sh -c "/usr/bin/initdb --pgdata=$PGDATA > /dev/null 2>&1" < /dev/null
[ -f $PGDATA/PG_VERSION ] && echo_success
[ ! -f $PGDATA/PG_VERSION ] && echo_failure
echo
fi
# Check for postmaster already running...
# note that pg_ctl only looks at the data structures in PGDATA
# you really do need the pidof()
pid=`pidof -s /usr/bin/postmaster`
if [ $pid ] && /usr/bin/pg_ctl status -D $PGDATA > /dev/null 2>&1
then
echo $"Postmaster already running."
else
#all systems go -- remove any stale lock files
rm -f /tmp/.s.PGSQL.${PGPORT} > /dev/null
echo -n "$PSQL_START"
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster -o '-p ${PGPORT}' start > /dev/null 2>&1" < /dev/null
sleep 1
pid=`pidof -s /usr/bin/postmaster`
if [ $pid ]
then
success "$PSQL_START"
touch /var/lock/subsys/${NAME}
echo $pid > /var/run/postmaster.${PGPORT}.pid
echo
else
failure "$PSQL_START"
echo
fi
fi
}
stop(){
echo -n $"Stopping ${NAME} service: "
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl stop -D $PGDATA -s -m fast" > /dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]
then
echo_success
else
echo_failure
fi
echo
rm -f /var/run/postmaster.${PGPORT}.pid
rm -f /var/lock/subsys/${NAME}
}
restart(){
stop
start
}
condrestart(){
[ -e /var/lock/subsys/${NAME} ] && restart
}
reload(){
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl reload -D $PGDATA -s" > /dev/null 2>&1
}
# This script is slightly unusual in that the name of the daemon (postmaster)
# is not the same as the name of the subsystem (postgresql)
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status postmaster
;;
restart)
restart
;;
condrestart)
condrestart
;;
reload|force-reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
exit 1
esac
exit 0
保存
chmod 755 post
ln –s /etc/init.d/post /etc/rc5.d/S82postgress
5、rrdtool安装
到网上下载rrdtool-1.0.49.tar.gz
# tar -zxvf source/rrdtool-1.0.49.tar.gz
# cd rrdtool-1.0.49
# ./configure --prefix=/ir/rrdtool
# make
# make install
安装完毕后,修改MRTG 的配置文件 mrtg.cfg 添加一下三行;
# more /etc/mrtg/net-rrd.cfg
# Created by
# ./cfgmaker --output=/etc/mrtg/net.cfg public@localhost
LogFormat: rrdtool 添加此行
PathAdd: /usr/local/rrdtool/bin/ 添加此行
LibAdd: /usr/local/rrdtool/lib/perl/ 添加此行
二、opennms安装
# cd /ir/source
# rpm -Uvh j2sdk-1_4_2_07-linux-i586.rpm
#rpm -Uvh tomcat4-4.1.24-full.2jpp.noarch.rpm
# rpm -Uvh tomcat4-admin-webapps-4.1.24-full.2jpp.noarch.rpm
# rpm -Uvh rrdtool-1.0.41-1.8.0.i386.rpm --nodeps
# rpm -Uvh postgresql-7.3.2-3.i386.rpm --nodeps
# rpm -Uvh postgresql-server-7.3.2-3.i386.rpm –-nodeps
# rpm -Uvh postgresql-libs-7.3.2-3.i386.rpm
# rpm -Uvh perl-DBD-Pg-1.21-2.i386.rpm –-nodeps
#rpm -Uvh opennms-1.2.0-1_rhl9.i386.rpm
#rpm -Uvh opennms-webapp-1.2.0-1_rhl9.i386.rpm
#rpm -Uvh opennms-docs-1.2.0-1_rhl9.i386.rpm
以上所有文件必须先到网上下载,安装完毕后设置jre
# cd /opt/OpenNMS/bin
# runjava –s
# runjava -S path
# $OPENNMS_HOME/bin/install –disU
# $OPENNMS_HOME/bin/install -y -w $CATALINA_HOME/webapps -W $CATALINA_HOME/server/lib
opennms系统配置
配置notificationCommand.xml
此项是配置是消息发送
配置discovery-configuration.xml
输入要管理的设备(包括了IP , 共同体的密码等),此文件可以什么都不配,但是要指定一个文件:targethost.xml ,然后到targethot.xml中来配
配置 targethost.xml
在targethost.xml输入配具体的要管理的机器
最后启动tomcat,opennms运行。