日期:2014-05-16  浏览次数:20624 次

Linux下Oracle日志工具Log4plsql的安装配置

1、下载Log4plsql

?

# wget http://prdownloads.sourceforge.net/log4plsql/Log4plsql.zip

?2、解压Log4plsql

# unzip Log4plsql.zip

?3、为了便于管理,把Log4plsql移动Oracle安装主目录,在我的机器上是/db/oracle

# mv Log4plsql /db/oracle/

# mv Log4plsql /db/oracle/


?4、配置Log4plsql环境变量




# cd /db/oracle/Log4plsql/cmd/
# vi setVariable.sh

#!/usr/bin/sh

echo initialisation variable

# generique product
export LOG4PLSQL_HOME=/db/oracle/Log4plsql
export ORACLE_HOME=/db/oracle/product/10.2.0
 
# database user
export LOG_SID=orcl
export LOG_USER=ULOG
export LOG_PASSW_USER=ULOG

# system user only use for install. Please, remove this entry after install
export SYS_USER=sys as sysdba
export SYS_PASSW_USER=koonet

# only if you use log4j
export JDK_HOME=/usr/java/jdk1.6

#   other variables is calculate

export ORACLE_USERSYS="$SYS_USER/$SYS_PASSW_USER@$LOG_SID as SYSDBA"
export ORACLE_SID=$LOG_SID
export EXTERNAL_LIB=$LOG4PLSQL_HOME/../WebSiteInvariant/externalProjectLib
export LOG4PLSQL_API=$LOG4PLSQL_HOME/Docs/api
export LOG4PLSQL_SQLDOC=$LOG4PLSQL_HOME/Docs/sql

PATH=$PATH:$JDK_HOME:$EXTERNAL_LIB:$ORACLE_HOME/bin

# Generique Tools
export CLASSPATH=$LOG4PLSQL_HOME/lib/log4j-1.2.jar:$CLASSPATH

# Oraclexmlparser
export CLASSPATH=$ORACLE_HOME/lib/xmlparserv2.jar:$CLASSPATH
export CLASSPATH=$ORACLE_HOME/lib/xmlcomp.jar:$CLASSPATH

# OracleDriver
export CLASSPATH=$ORACLE_HOME/lib/classes12.jar:$CLASSPATH
export CLASSPATH=$ORACLE_HOME/lib/nls_charexport12.jar:$CLASSPATH
export CLASSPATH=$ORACLE_HOME/lib/runtime12.jar:$CLASSPATH

# log4plsql
export CLASSPATH=$LOG4PLSQL_HOME/lib/log4plsql.jar:$CLASSPATH

echo CLASSPATH
echo $CLASSPATH
echo CLASSPATH


?5、运行install.sh安装Log4plsql


# chmod +x *.sh
# ./install.sh

?注意:如果出现以下错误
-bash: ./install.sh: /usr/bin/sh: bad interpreter: 没有那个文件或目录

请编辑install.sh, 把第一行的#!/usr/bin/sh改成#!/bin/sh, 之后执行
# dos2unix install.sh?? ---把dos格式脚本转换成unix
# ./install.sh

6、更改数据库连接配置




# cd /db/oracle/Log4plsql/properties/
# vi log4plsql.xml

<database>
    <source>
        <connection>
           <!-- Database connection where log4plsql ase install.
            |   see : JDBC Developer's Guide and Reference / Verifying a JDBC Client Installation
            |         for all installation Oracle driver install
            +-->
          <username>ulog</username>
          <password>ulog</password>
           <!-- jdbc:oracle:thin:@<host_name>:<port_number>:<sid>  -->
          <dburl>jdbc:oracle:thin:@127.0.0.1:1521:orcl</dburl>
        </connection>
           <!-- the default value of pipename is LOG_PIPE
            +-->
        <pipename>LOG_PIPE</pipename>
    </source>
</database>