centos 6.2 syslog-ng的配置

一、准备的环境包
  1、eventlog_0.2.12.tar.gz
  2、syslog-ng_3.3.5.tar
  3、glib2-devel
  4、gcc
二、安装步骤
  1、gcc安装
     yum install gcc
  2、eventlog安装
     tar zxvf eventlog_0.2.12.tar.gz 
     cd eventlog-0.2.12/
     ./configure --prefix=/opt/eventlog/
     make && make install
   3、glib2-devel 安装
   yum install glib2-devel
   4、syslog-ng安装
     export PKG_CONFIG_PATH=/opt/eventlog/lib/pkgconfig
     tar xzvf syslog-ng_3.3.5.tar.gz 
     cd syslog-ng-3.3.5/
     ./configure --prefix=/opt/syslog-ng
     make && make install

三、syslog-ng自启动脚本

#!/bin/bash
# syslog-ng        Starts syslog-ng.
# chkconfig: - 91 61
# description: Syslog-ng is the facility by which many daemons use to log
# processname: syslog-ng
# pidfile: /usr/local/syslog-ng/etc/syslogng.pid
# config: /usr/local/syslog-ng/etc/nginx.conf
syslogngd=/opt/syslog-ng/sbin/syslog-ng
syslogng_pid=/opt/syslog-ng/var/syslog-ng.pid
RETVAL=0
prog="syslog-ng"
# Source function library.
.  /etc/rc.d/init.d/functions
[ -x $syslogngd ] || exit 0
# Start syslog-ng daemons functions.
start() {
if [ -e $syslogng_pid ];then
   echo "syslog-ng already running...."
   exit 1
fi
   echo -n $"Starting $prog: "
   daemon $syslogngd
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && touch /var/lock/subsys/syslog-ng
   return $RETVAL
}
# Stop syslogng daemons functions.
stop() {
        echo -n $"Stopping $prog: "
        killproc $syslogngd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/syslog-ng /opt/syslog-ng/var/syslog-ng.pid
}
reload() {
    echo -n $"Reloading $prog: "
    killproc $syslogngd -HUP
    RETVAL=$?
    echo
}
# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        reload
        ;;
restart)
        stop
        start
        ;;
status)
        status $prog
        RETVAL=$? 60.        ;;
*)
        echo $"Usage: $prog {start|stop|restart|reload|status|help}"
        exit 1 64.esac 65.exit $RETVAL 赋予syslog-ng 脚本执行权限;
esac

四、设置权限
  chmod +x /etc/rc.d/init.d/syslog-ng
五、让syslog-ng以服务的形式开机启动
    chkconfig syslog-ng on
六、启动、重启、停止syslog-ng
  service syslog-ng start
   service syslog-ng restart
   service syslog-ng stop
七、结束

posted @ 2012-09-26 18:04  sunney  阅读(1641)  评论(0编辑  收藏  举报