<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[运维进行时]]></title> 
<link>https://blog.liuts.com/index.php</link> 
<description><![CDATA[互联网运维与架构]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[运维进行时]]></copyright>
<item>
<link>https://blog.liuts.com/post//</link>
<title><![CDATA[搭建syslog-ng服务器]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[Linux]]></category>
<pubDate>Tue, 21 Aug 2007 13:41:54 +0000</pubDate> 
<guid>https://blog.liuts.com/post//</guid> 
<description>
<![CDATA[ 
	一、软件：<br/>wget http://www.balabit.com/downloads/files/syslog-ng/sources/stable/src/syslog-ng-2.0.5.tar.gz<br/>wget http://nchc.dl.sourceforge.net/sourceforge/php-syslog-ng/php-syslog-ng-2.9.1r10.tar.gz<br/>wget http://www.mirrors.wiretapped.net/security/host-security/syslog-ng/libol/0.2/libol-0.2.24.tar.gz<br/>wget http://ftp.uk.debian.org/debian/pool/main/e/eventlog/eventlog_0.2.5.orig.tar.gz<br/><br/>二、安装：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>tar -zxvf eventlog_0.2.5.orig.tar.gz<br/>cd eventlog-0.2.5<br/>./configure<br/>make && make install<br/><br/>tar -zxvf libol-0.2.24.tar.gz<br/>cd libol-0.2.24<br/>./configure<br/>make && make install<br/>tar -zxvf syslog-ng-2.0.5.tar.gz<br/>cd syslog-ng-2.0.5<br/>export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/<br/>./configure<br/>make && make install<br/><br/>tar -zxvf php-syslog-ng-2.9.1r10.tar.gz<br/>cd html/scripts/<br/><br/>vi syslog2mysql.sh<br/>#!/bin/bash<br/><br/>if [ ! -e /var/log/mysql.pipe ]<br/>then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mkfifo /var/log/mysql.pipe<br/>fi<br/>while [ -e /var/log/mysql.pipe ]<br/>do<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/local/mysql/bin/mysql -u dbuser --password=dbpass dbname < /var/log/mysql.pipe >/dev/null<br/>done<br/></div></div><br/>将表结构导入数据库：<br/><textarea name="code" class="sql" rows="15" cols="100">
CREATE TABLE IF NOT EXISTS `logs` (
&nbsp;&nbsp;`host` varchar(32) default NULL,
&nbsp;&nbsp;`facility` varchar(10) default NULL,
&nbsp;&nbsp;`priority` varchar(10) default NULL,
&nbsp;&nbsp;`level` varchar(10) default NULL,
&nbsp;&nbsp;`tag` varchar(10) default NULL,
&nbsp;&nbsp;`datetime` datetime default NULL,
&nbsp;&nbsp;`program` varchar(15) default NULL,
&nbsp;&nbsp;`msg` text,
&nbsp;&nbsp;`seq` bigint(20) unsigned NOT NULL auto_increment,
&nbsp;&nbsp;PRIMARY KEY&nbsp;&nbsp;(`seq`),
&nbsp;&nbsp;KEY `host` (`host`),
&nbsp;&nbsp;KEY `program` (`program`),
&nbsp;&nbsp;KEY `datetime` (`datetime`),
&nbsp;&nbsp;KEY `priority` (`priority`),
&nbsp;&nbsp;KEY `facility` (`facility`)
) TYPE=MyISAM AUTO_INCREMENT=281 ;
</textarea><br/><br/>#nohup ./syslog2mysql.sh &<br/><br/>服务器端：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>vi /usr/local/etc/syslog-ng.conf<br/>内容如下：http://www.joecen.com/blog/files/syslog-ng.conf<br/>略....<br/><br/>vi /etc/init.d/syslog-ng<br/>------------------------------------------------------<br/>################################################################################<br/>#<br/># Program: syslog-ng init script for Red Hat<br/>#<br/>################################################################################<br/># the following information is for use by chkconfig<br/># if you are want to manage this through chkconfig (as you should), you must<br/># first must add syslog-ng to chkconfig's list of startup scripts it<br/># manages by typing:<br/>#<br/># chkconfig --add syslog-ng<br/>#<br/># DO NOT CHANGE THESE LINES (unless you know what you are doing)<br/># chkconfig: 2345 12 88<br/># description: syslog-ng is the next generation of the syslog daemon. &#92;<br/># syslog-ng gives you the flexibility of logging not only by facility and &#92;<br/># severity, but also by host, message content, date, etc. it can also replace &#92;<br/># klogd's function of logging kernel messages<br/>#<br/># This following block of lines is correct, do not change! (for more info, see<br/># http://www.linuxbase.org/spec/refspecs/LSB_1.1.0/gLSB/facilname.html)<br/>### BEGIN INIT INFO<br/># Provides: $syslog<br/>### END INIT INFO<br/>################################################################################<br/>#<br/># This is an init script for syslog-ng on the Linux platform.<br/>#<br/># It totally relies on the Redhat function library and works the same<br/># way as other typical Redhat init scripts.<br/>#<br/>#<br/># Platforms (tested): Linux (Redhat 7.3)<br/>#<br/>#<br/># Author: Gregor Binder <gbinder@sysfive.com><br/># Changed: October 10, 2000<br/>#<br/># Last Changed: September 27, 2002<br/># Updated by: Diane Davidowicz<br/># changes: Brought the start script up to snuff as far as compliance<br/># with managing the startup script through chkconfig;<br/># added PATH variable ability to hook in path to syslog-ng (if<br/># its necessary); converted init script format to the<br/># standard init script format in Red Hat (7.3 to be exact)<br/># including using the /etc/sysconfig/syslog-ng file to<br/># managed the arguments to syslog-ng without changing this<br/># script, and disabled klogd but noted where and under what<br/># conditions it should be enabled. HAPPY LOGGING.<br/>#<br/># Copyright (c) 2000 by sysfive.com GmbH, All rights reserved.<br/>#<br/>#<br/>################################################################################<br/>#<br/># configuration<br/>#<br/><br/>INIT_PROG="/usr/local/sbin/syslog-ng" # Full path to daemon<br/>INIT_OPTS="" # options passed to daemon<br/><br/>#<br/># Source Redhat function library.<br/>#<br/>. /etc/rc.d/init.d/functions<br/><br/># Tack on path to syslog-ng if not already in PATH<br/>SYSLOGNG_PATH=":/usr/local/sbin"<br/><br/>PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin<br/>INIT_NAME=`basename "$INIT_PROG"`<br/><br/># /etc/sysconfig/ is the standard way to pull in options for a daemon to use.<br/># Source config<br/>if [ -f /etc/sysconfig/syslog-ng ] ; then<br/>. /etc/sysconfig/syslog-ng<br/>else<br/>SYSLOGNG_OPTIONS=<br/>fi<br/><br/>RETVAL=0<br/><br/>umask 077<br/>ulimit -c 0<br/><br/># See how we were called.<br/>start() &#123;<br/>echo -n "Starting $INIT_PROG: "<br/>#daemon $INIT_PROG $SYSLOGNG_OPTIONS<br/>daemon --check $INIT_PROG "$INIT_PROG $INIT_OPTS"<br/>RETVAL=$?<br/>echo<br/><br/>[ $RETVAL -eq 0 ] && touch "/var/lock/subsys/$&#123;INIT_NAME&#125;"<br/>return $RETVAL<br/>&#125;<br/><br/>stop() &#123;<br/><br/>echo -n "Stopping $INIT_PROG: "<br/>killproc $INIT_PROG<br/>RETVAL=$?<br/>echo<br/><br/>[ $RETVAL -eq 0 ] && rm -f "/var/lock/subsys/$&#123;INIT_NAME&#125;"<br/>return $RETVAL<br/><br/>&#125;<br/><br/>rhstatus() &#123;<br/>status $INIT_PROG<br/>&#125;<br/><br/>restart() &#123;<br/>stop<br/>start<br/>&#125;<br/><br/>case "$1" in<br/>start)<br/>start<br/>;;<br/>stop)<br/>stop<br/>;;<br/>status)<br/>rhstatus<br/>;;<br/>restart&#124;reload)<br/>restart<br/>;;<br/>condrestart)<br/>[ -f /var/lock/subsys/syslog-ng ] && restart &#124;&#124; :<br/>;;<br/>*)<br/>echo $"Usage: $0 &#123;start&#124;stop&#124;status&#124;restart&#124;reload&#125;"<br/>exit 1<br/>esac<br/><br/>exit $? <br/>------------------------------------------------------<br/>chmod ugo+x /etc/init.d/syslog-ng<br/>chkconfig --add syslog-ng<br/>#service syslog-ng start <br/></div></div><br/><br/>客户端：<br/>vi /etc/syslog.conf<br/>*.notice;cron.none;authpriv.*&nbsp;&nbsp;&nbsp;&nbsp;@19.2.169.41<br/>或者直接：<br/>echo "*.notice;cron.none;authpriv.*&nbsp;&nbsp; @19.2.169.41"&nbsp;&nbsp;>> /etc/syslog.conf<br/>/etc/init.d/syslog restart<br/><br/>注：如果无法获取客户端日志，试试修改服务器如下文件。<br/>vi /etc/sysconfig/syslo<br/>SYSLOGD_OPTIONS="-m 0 -r"<br/><br/>Tags - <a href="https://blog.liuts.com/tags/syslog-ng/" rel="tag">syslog-ng</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post//#blogcomment</link>
<title><![CDATA[[评论] 搭建syslog-ng服务器]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://blog.liuts.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>