工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.wdlinux.cn 注册 | 登陆
浏览模式: 标准 | 列表2012年03月6日的文章

squid store.log文件说明

13.3 store.log

store.log记录Squid关于存储或删除cache目标的决定。对每个存在cache里的目标、每个不可cache的目标、以及每个被轮换策略删除的目标,Squid都会创建相应的日志条目。该日志文件内容既包含了内存cache又包含了磁盘cache。

store.log提供了下述不能从access.log获取的内容:

  • 1)某个特定的响应是否被cache。
  • 2)cache目标的文件号。对UFS基础的存储机制,你可转换该文件号到路径名,并且检查cache文件的内容。
  • 3)响应的内容长度:包括Content-Length值和实际的body大小。
  • 4)Date, Last-Modified, 和Expires头部的值。
  • 5)响应的cache关键字(例如MD5哈希值)。

如你所见,这些都是相对低级的信息,在日常管理中可能用不上。除非你要做专业的分析,或打算debug某程序,否则store.log可有可无。可以如下来禁止它:

cache_store_log none

跟其他日志文件一样,Squid将最新的日志条目写到该文件的末尾。某个给定的URI可能出现在日志文件里多次。例如,它先被cache,然后删除,接着又cache住。仅仅最近来的日志条目才反映目标的当前值。

store.log是文本基础的,看起来如下:

1067299212.411 RELEASE -1 FFFFFFFF A5964B32245AC98592D83F9B6EA10B8D 206

    1067299212 1064287906 -1 application/octet-stream 6840/6840

    GET http://download.windowsupdate.com/msdownload/update/v3-19990518/cab...

1067299212.422 SWAPOUT 02 0005FD5F 6F34570785CACABC8DD01ABA5D73B392 200

    1067299210 1057899600 -1 image/gif 1125/1125

    GET http://forum.topsportsnet.com/shf./images/nav_members1.gif

1067299212.641 RELEASE -1 FFFFFFFF B0616CB4B7280F67672A40647DD08474 200

    1067299212 -1 -1 text/html -1/67191

    GET http://www.tlava.com/

1067299212.671 RELEASE -1 FFFFFFFF 5ECD93934257594825659B596D9444BC 200

    1067299023 1034873897 1067299023 image/jpeg 3386/3386

    GET http://ebiz0.ipixmedia.com/abc/ebiz/_EBIZ_3922eabf57d44e2a4c3e7cd234a...

1067299212.786 RELEASE -1 FFFFFFFF B388F7B766B307ADEC044A4099946A21 200

    1067297755 -1 -1 text/html -1/566

    GET http://www.evenflowrocks.com/pages/100303pic15.cfm

1067299212.837 RELEASE -1 FFFFFFFF ABC862C7107F3B7E9FC2D7CA01C8E6A1 304

    1067299212 -1 1067299212 unknown -1/0

    GET http://ebiz0.ipixmedia.com/abc/ebiz/_EBIZ_3922eabf57d44e2a4c3e7cd234a...

1067299212.859 RELEASE -1 FFFFFFFF 5ED2726D4A3AD83CACC8A01CFDD6082B 304

    1066940882 1065063803 -1 application/x-javascript -1/0

    GET http://www.bellsouth.com/scripts/header_footer.js

每个日志条目包含如下13个域:

  • 1. 时间戳

    事件何时发生,表现为Unix纪元以来的秒数,它是毫秒级的。
  • 2. 动作
  • cache目标发生的动作。该域有3个可能值:SWAPOUT,RELEASE,和SO_FAIL。

    • 1)SWAPOUT在Squid成功的存储目标到磁盘时发生。某些目标例如那些消极cache的,仅保存在内存而不是磁盘,Squid不会在store.log里记录它们。
    • 2)SO_FAIL表明Squid不能完整的存储目标到磁盘。多半意味着存储机制拒绝以写方式打开新的磁盘文件。
    • 3)RELEASE在Squid从cache里删除目标,或首先就决定响应不可存储时发生。
  • 3. 目录号
  • 目录号是十进制小数形式,它是个到cache目录的7位索引。对没有存储到磁盘的目标,该域包含-1值。
  • 4. 文件号
  • 文件号是25位的标识符,内在的被squid使用。它被写成8字符的十六进制号。对UFS基础的存储机制,有算法可以转换文件号到路径名(见13.3.1节)。没有存储到磁盘的目标,没有有效的文件号。对这些目标,该域的值是FFFFFFFF。仅仅在RELEASE和SO_FAIL情况下才会出现这个值。
  • 5. cache关键字

    Squid使用MD5哈希值作为主要的索引来定位目标。该关键字基于请求方式、URI、和其他可能的信息计算得来。可以从cache关键字来查找store.log条目。然而请注意,目标的cache关键字可能改变。当Squid在access.log里记录TCP_REFRESH_MISS请求时,这点会发生。情况类似如下:
    1065837334.045 SWAPOUT ... 554BACBD2CB2A0C38FF9BF4B2239A9E5 ... http://blah
    
    1066031047.925 RELEASE ... 92AE17121926106EB12FA8054064CABA ... http://blah
    
    1066031048.074 SWAPOUT ... 554BACBD2CB2A0C38FF9BF4B2239A9E5 ... http://blah
    发生了什么呢?该目标原本cache在某个关键字下(554B...)。一段时间后,Squid接受到对该目标的另一请求,并转发确认请求到原始服务器。当响应以新内容返回时,Squid改变旧目标的cache关键字(92AE...),以便它能授予新目标正确的关键字(554B...)。然后旧目标删除,新目标存储到磁盘。
  • 6. 状态码
  • 该域显示响应的HTTP状态码,跟access.log一样。表13.1是状态码列表。
  • 7. 日期
  • HTTP响应的Date头部值,表现为Unix纪元以来的秒数。值-1表示Date头部不可解析,-2意味着头部完缺。
  • 8. 最后修改时间
  • HTTP响应的Last-Modified头部值,表现为Unix纪元以来的秒数。值-1表示Last-Modified头部不可解析,-2意味着头部完缺。
  • 9. 过期时间
  • HTTP响应的Expires头部值,表现为Unix纪元以来的秒数。值-1表示Expires头部不可解析,-2意味着头部完缺。
  • 10. 内容类型
  • HTTP响应的Content-Type头部值,排除了任何media-type参数。假如Content-Type丢失了,Squid插入值unknown。
  • 11. 内容长度/大小
  • 该域包含2个数字,以斜杠分开。第一个是Content-Length头部值。-1表明Content-Length头部不存在。第二个是HTTP消息body的实际大小。你可使用这2个数字来部分的验证接受到的响应,并验证原始服务器是否不正确的计算了内容长度。大多数情形下,这2个数字相等。
  • 12. 方式
  • 请求目标的HTTP方式,跟access.log里的一样。
  • 13. URI
  • 最后一个域是请求URI,跟access.log里的一样。该域也有前述章节提到的空格问题。然而,这里不必为此担忧,因为你可安全的忽略任何多余的域。
  • 对许多RELEASE的条目,在最后8个域出现的是疑问号(?)。这是因为这些域的大部分值来自squid称为MemObject的结构。该结构仅在目标已被接受时,或目标被完整存储在内存时,才会出现。Squid cache里的大部分目标没有MemObject结构,因为它们仅存在于磁盘。对这些情况,Squid在相应域放置一个疑问号。

squid日志格式处理

先看看squid原始文档怎么解释吧 
#  TAG: logformat
#       Usage:
#
#       logformat <name> <format specification>
#
#       Defines an access log format.
#
#       The <format specification> is a string with embedded % format codes
#
#       % format codes all follow the same basic structure where all but
#       the formatcode is optional. Output strings are automatically escaped
#       as required according to their context and the output format
#       modifiers are usually not needed, but can be specified if an explicit
#       output format is desired.
#
#               % ["|[|'|#] [-] [[0]width] [{argument}] formatcode
#
#               "       output in quoted string format
#               [       output in squid text log format as used by log_mime_hdrs
#               #       output in URL quoted format
#               '       output as-is
#
#               -       left aligned
#               width   field width. If starting with 0 the
#                       output is zero padded
#               {arg}   argument such as header name etc
#
#       Format codes:
#
#               %       a literal % character
#               >a      Client source IP address
#               >A      Client FQDN
#               >p      Client source port
#               <A      Server IP address or peer name
#               la      Local IP address (http_port)
#               lp      Local port number (http_port)
#               <la     Local IP address of the last server or peer connection
#               <lp     Local port number of the last server or peer connection
#               ts      Seconds since epoch
#               tu      subsecond time (milliseconds)
#               tl      Local time. Optional strftime format argument
#                               default %d/%b/%Y:%H:%M:%S %z
#               tg      GMT time. Optional strftime format argument
#                               default %d/%b/%Y:%H:%M:%S %z
#               tr      Response time (milliseconds)
#               dt      Total time spent making DNS lookups (milliseconds)
#
#       HTTP cache related format codes:
#
#               [http::]>h      Original request header. Optional header name argument
#                               on the format header[:[separator]element]
#               [http::]>ha     The HTTP request headers after adaptation and redirection.
#                               Optional header name argument as for >h
#               [http::]<h      Reply header. Optional header name argument
#                               as for >h
#               [http::]un      User name
#               [http::]ul      User name from authentication
#               [http::]ui      User name from ident
#               [http::]us      User name from SSL
#               [http::]ue      User name from external acl helper
#               [http::]>Hs     HTTP status code sent to the client
#               [http::]<Hs     HTTP status code received from the next hop
#               [http::]Ss      Squid request status (TCP_MISS etc)
#               [http::]Sh      Squid hierarchy status (DEFAULT_PARENT etc)
#               [http::]mt      MIME content type
#               [http::]rm      Request method (GET/POST etc)
#               [http::]ru      Request URL
#               [http::]rp      Request URL-Path excluding hostname
#               [http::]rv      Request protocol version
#               [http::]et      Tag returned by external acl
#               [http::]ea      Log string returned by external acl
#               [http::]<st     Sent reply size including HTTP headers
#               [http::]>st     Received request size including HTTP headers. In the
#                               case of chunked requests the chunked encoding metadata
#                               are not included
#               [http::]>sh     Received HTTP request headers size
#               [http::]<sh     Sent HTTP reply headers size
#               [http::]st      Request+Reply size including HTTP headers
#               [http::]<sH     Reply high offset sent
#               [http::]<sS     Upstream object size
#               [http::]<pt     Peer response time in milliseconds. The timer starts
#                               when the last request byte is sent to the next hop
#                               and stops when the last response byte is received.
#               [http::]<tt     Total server-side time in milliseconds. The timer
#                               starts with the first connect request (or write I/O)
#                               sent to the first selected peer. The timer stops
#                               with the last I/O with the last peer.
#logformat squid %ts.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %un %Sh/%<A %mt
#logformat squidmime %ts.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %un %Sh/%<A %mt [%>h] [%<h]
#logformat common %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %>Hs %<st %Ss:%Sh
#logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %>Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
#Default:
# none

{} modifier or argument. Also used to specify header names
>  request (client)  客户请求
<  reply (server)    服务端回应
a  address           访问用户ip地址
A  address name      访问用户电脑名称
h  all headers       浏览器头信息
i  ident               
p  port                 端口
r  request line (no query)
t  time   访问时间
u  user
l  local address/port (where request was accepted)  
     
自己squid配置文件日志格式定义如下:
logformat cccdn  %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %>Hs %<st %tr "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh

海量日志处理系统开源日志系统比较

使用 syslog-ng 搭建安全的日志集中服务器

管理Linux系统以及应用程序的日志非常重要且具有趣味性。我们想要得到的是重要的、有用的信息,并不是大量的垃圾。你得有能力在日志中找到你需要的信息。古老的 syslogd 工具已经工作了许多个年头。但它现在已经不足以面对更加复杂的需要。为了代替它,我们有了新一代的 Linux 日志管理工具,syslog-ng(syslog-next-generation)。
比较 syslog ,syslog-ng 具有众多高级的功能:更好的网络支持,更加方便的配置,集中式的网络日志存储,并且更具有弹性。比如,使用syslogd时,所有的iptables日志与其他内核日志一起全部存储到了kern.log文件里。Syslog-ng则可以让你有选择性的将iptables部分分出到另外的日志文件中。Syslogd仅能使用UDP协议,Syslog-ng 可以使用UDP和TCP协议。所以你可以在加密的网络隧道中传输日志到集中日志服务器。
安装
所有的Linux发行版本已经默认提供了Syslog-ng包。目前的稳定版本为1.6。如果你使用yum或者apt-get等工具安装Syslog-ng,他们会自动卸载sysklogd包。如果sysklogd没有被自动卸载,亲你手动删除它并且确保syslogd服务已经停止。(sysklogd 是软件包名,syslogd 是服务名)
配置文件结构
由于功能具有弹性,所以配置文件的学习可能稍微曲折。Syslog-ng 的配置文件在 /etc/syslog-ng/syslog-ng.conf ,或者是 /etc/syslog-ng.conf 。你可以通过 man 5 syslog-ng 来学习所有的选项以及字段的含义。一般 syslog-ng 可能含有以下5个章段:
options{}
全局设置。 These can be overridden in any of the next four sections
source{}
信息来源, 来源可以是文件, 本地 sockets, 或者远程主机。
destination{}
信息目标, 可以是文件, 本地 sockets, 或者远程主机。
filter{}
过滤选项非常强大且复杂;你可以过滤日志中的任何方面,比如基础的 syslogd 快捷字段(facility names–man 5 syslog.conf 获取更多信息),log 等级,主机名,以及任何log中出现的字段或者是数字。
log{}
此段将来源 目的 过滤 都给连接起来并且告诉syslog-ng如何处理日志。
一些典型的全局选项:
options {
sync (0);
log_fifo_size (2048);
create_dirs (yes);
group (logs);
dir_group (logs);
perm (0640);
dir_perm (0750);
};
在 /etc/syslog-ng.conf 中使用的全局选项字段必须是被定义过的。 上面例子的具体含义是:
sync
在写入磁盘之前保留多少行的消息输出队列。(这里将日志输出称为“消息”。)0 是首选的数值,这可以让你确保捕获了所有信息,且磁盘也不会在系统以外掉电时丢失信息。
log_fifo_size
输出队列中消息的最大行数。默认为100行。你可以通过计算得出一个合适的数值,以下是引用一份邮件列表,里面提到了相关的内容:
每个消息来源最大接收数据的1024字节。单条日志信息为20至30字节。所以程序的一次执行可以送出1024/20=50条消息。对每个日志发送方,你的 log 接受能力必须满足这个数值。若你有两个日志源,则你必须能一次接受100条信息。
Each message source receives maximum 1024 bytes of data. A single log message is about 20 to 30 bytes. So on a single run each log source may emit 1024/20 = 50 messages. Your log fifo must be able to hold this number of messages for each source. So for two sources, you’ll need at least 100 slots in your fifo.
那两个选项非常容易混淆。 来自远程主机的消息会突然到达,所以你要保证你的 log_fifo_size 参数足以接纳那些突然增加的消息。 不然你就会丢失日志了, 当然这还受限于你的网络速度以及I/O速率。
create_dirs
启用或禁用自动为目标文件创建目录的功能。 在上文中值为“yes”, 所以远程主机会更具需要自动创建目录。
group
dir_group
设定日志文件以及目录的所有人(owner),所以你不必以超级用户(root)的身份去浏览那些日志。
perm
dir_perm
默认新日志文件的权限设置。
Source, Destination, 和 Filter 描述
Source, destination, 和 filter 的名字可以是任意的,看看下面的例子:
source s_local { internal(); unix-stream(”/dev/log”); file(”/proc/kmsg” log_prefix(”kernel: “)); };
destination d_auth { file(”/var/log/auth.log”); };
filter f_auth { facility(auth, authpriv); };
如果你喜欢你可以将 “source s_local” 改为 “source frederick_remington_depew”,当然 “destination d_auth” 也可以为 “destination moon.” 通常我们将 source 的名字中含有 “s” 字段,destination 的名字中含有 “d” 字段, filter 的名字中含有 “f” 字段,但这并不是必须的。source, destination, 和 filter 中其他的选项必须使用已经定义的字段,你可以通过 man 5 syslog-ng.conf 查看这些参数。
上面的例子 “source s_local” 将所有本地生成的日志信息作为一个信息源。而 “destination d_auth” 选项又将这些日志输入了 /var/log/auth.log 文件,当然这是通过 “filter f_auth” 将它们连接起来的。 auth 和 authpriv 是 syslog 标准的设备名称。
最后的日志申明(Log statements)将他们链接到了一起:
log {source(s_local); filter(f_auth); destination(d_auth); };
那么这四行就将本地所有的 auth 和 authpriv 日志筛出并写入了 /var/log/auth.log。
启用远程日志记录
当然,使用老的 syslogd 也可以很好的完成远程日志记录的工作,但那真的不太好,因为他只使用UDP协议传送数据包。首先你需要将所有的客户端上都装好 syslog-ng。并且在日志服务器的 syslog-ng.conf 文件中加入以下配置文件,这样才可以接受远程客户端日志,并将每台机器的日志写入单独的文件。
source s_remote { tcp(); };
destination d_clients { file(”/var/log/HOSTS/$HOST/”); };
log { source(s_remote); destination(d_clients); };
这是一个非常简单但十分有用的例子,他收集所有客户端本地的日志并将日志发送至远程日志服务器:
#sample syslog-ng.conf for a remote client
source s_local { internal(); unix-stream(”/dev/log”); file(”/proc/kmsg” log_prefix(”kernel: “)); };
destination d_loghost {tcp(”192.168.1.10″ port(514));};
log { source(s_local); destination(loghost); };
syslog-ng.conf 配置参考
一份完整的样板配置文件会显得比较长,你可以查看 syslog-ng 安装时附带的配置文件。Debian 用户得到的是一份通过 syslogd 配置而定制的配置文件。我们将给出一份日志服务器的配置文件,以及一个远程日志客户端的配置文件,来看看他们是怎么工作起来的吧:
#sample syslog-ng.conf for a central logging server
options {
sync (0);
log_fifo_size (2048);
create_dirs (yes);
group (logs);
dir_group (logs);
perm (0640);
dir_perm (0750);
};
source s_local { internal(); unix-stream(”/dev/log”); file(”/proc/kmsg” log_prefix(”kernel: “)); };
destination d_auth { file(”/var/log/auth.log”); };
filter f_auth { facility(auth, authpriv); };
source s_remote { tcp(); };
destination d_clients { file(”/var/log/HOSTS/$HOST”); };
log { source(s_remote); destination(d_clients); };
log { source(s_local); filter(f_auth); destination(d_auth); };
修改完 syslog-ng 之后要重启服务:
# /etc/init.d/syslog-ng restart
测试
现在你可以在日志服务器以及客户端上进行一些测试了。由于在本地服务器中最先出现的日志一般是认证日志,所以你可以先尝试着打开一个新的登录窗口,使用su 或者是 sudo 都可以。接着检查 /var/log/auth.log 文件。在客户端上做一些操作,接着检查 /var/log/HOSTS 是否已经为远程客户端创建了新的目录。
另外一个方法是使用更加高级的 logger 命令:
# logger “this is a test”
# logger -p auth.debug “this is a test”
这将在你的日志文件中创建如下内容:
Apr 1 16:08:42 localhost.localdomain logger: this is a test
现在我们已经掌握了 syslog-ng 基本的功能,下周我们讲学习如何将 syslog-ng 客户端以及服务器按照你的意愿配置的更加有规则、易于管理,并且讨论如何建立一个安全的、加密的 syslog-ng 传输。
-----------使用syslog-ng搭建日志服务器---
一、环境
Gentoo-2007.0_amd64

二、安装:为了简便,我用了系统自带的syslog-ng

三、服务器配置:
#cat /etc/syslog-ng/syslog-ng.conf

#
# configuration file for syslog-ng, customized for remote logging
#
options {
        use_fqdn(yes);
        chain_hostnames(off);
        keep_hostname(off);
        sync(0);
        # The default action of syslog-ng 1.6.0 is to log a STATS line
        # to the file every 10 minutes.  That's pretty ugly after a while.
        # Change it to every 12 hours so you get a nice daily update of
        # how many messages syslog-ng missed (0).
        stats(43200);
        create_dirs(yes);
};
source s_internal { internal(); };
destination d_syslognglog { file("/var/log/syslog-ng.log"); };
log { source(s_internal); destination(d_syslognglog); };
source s_sys { file ("/proc/kmsg" log_prefix("kernel: ")); unix-stream ("/dev/log"); internal(); };
destination d_cons { file("/dev/console"); };
destination d_mesg { file("/var/log/messages"); };
destination d_auth { file("/var/log/secure"); };
destination d_mail { file("/var/log/maillog"); };
destination d_spol { file("/var/log/spooler"); };
destination d_boot { file("/var/log/boot.log"); };
destination d_cron { file("/var/log/cron"); };
destination d_rsync { file("/var/log/rsync"); };
destination d_mlal { usertty("*"); };
filter f_filter1     { facility(kern); };
filter f_filter2     { level(info) and
                     not (facility(mail)
                        or facility(authpriv) or facility(cron)); };
filter f_filter3     { facility(authpriv); };
filter f_filter4     { facility(mail); };
filter f_filter5     { level(emerg); };
filter f_filter6     { facility(uucp) or
                     (facility(news) and level(crit)); };
filter f_filter7     { facility(local7); };
filter f_filter8     { facility(cron); };
filter f_filter9     { facility(daemon); };
filter f_filter10     { facility(local6); };
#log { source(s_sys); filter(f_filter1); destination(d_cons); };
log { source(s_sys); filter(f_filter2); destination(d_mesg); };
log { source(s_sys); filter(f_filter3); destination(d_auth); };
log { source(s_sys); filter(f_filter4); destination(d_mail); };
log { source(s_sys); filter(f_filter5); destination(d_mlal); };
log { source(s_sys); filter(f_filter6); destination(d_spol); };
log { source(s_sys); filter(f_filter7); destination(d_boot); };
log { source(s_sys); filter(f_filter8); destination(d_cron); };
# Remote logging
source s_remote {
        udp(ip(0.0.0.0) port(514));
};
destination r_mesg { file("/var/log/syslog-ng/$YEAR/$MONTH/$HOST/messages" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes)); };
destination r_auth { file("/var/log/syslog-ng/$YEAR/$MONTH/$HOST/secure" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes)); };
destination r_mail { file("/var/log/syslog-ng/$YEAR/$MONTH/$HOST/maillog" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes)); };
destination r_spol { file("/var/log/syslog-ng/$YEAR/$MONTH/$HOST/spooler" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes)); };
destination r_boot { file("/var/log/syslog-ng/$YEAR/$MONTH/$HOST/boot.log" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes)); };
destination r_cron { file("/var/log/syslog-ng/$YEAR/$MONTH/$HOST/cron" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes)); };
destination r_daemon { file("/var/log/syslog-ng/$YEAR/$MONTH/$HOST/daemon" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes)); };
destination r_local6 { file("/var/log/syslog-ng/$YEAR/$MONTH/network/messages" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes)); };
#destination d_separatedbyhosts {
#       file("/var/log/syslog-ng/$HOST/messages" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));
#};
#log { source(s_remote); destination(d_separatedbyhosts); };
log { source(s_remote); filter(f_filter2); destination(r_mesg); };
log { source(s_remote); filter(f_filter3); destination(r_auth); };
log { source(s_remote); filter(f_filter4); destination(r_mail); };
log { source(s_remote); filter(f_filter6); destination(r_spol); };
log { source(s_remote); filter(f_filter7); destination(r_boot); };
log { source(s_remote); filter(f_filter8); destination(r_cron); };
log { source(s_remote); filter(f_filter9); destination(r_daemon); };
log { source(s_remote); filter(f_filter10); destination(r_local6); };

四、客户端配置
linux使用的syslog守护进程主要有两种,syslog和syslog-ng
1、syslog
#vi /etc/syslog.conf
*.*                                                     @loghost

loghost为日志服务器的IP或者主机名,主机明必须能正确解析到日志服务器IP。
然后重新启动syslog服务:
#/etc/init.d/syslog restart

2、syslog-ng
在配置文件syslog-ng.conf中加入两行:
destination d_udp { udp("loghost" port(514)); };
log { source(src); destination(d_udp); };
重新启动syslog-ng服务
#/etc/init.d/syslog-ng restart

winodws服务器的配置
因为windows服务器不支持日志服务器,因此需要安装一个转换软件:
下载地址为:
https://engineering.purdue.edu/ECN/Resources/Documents/UNIX/evtsys/
根据系统的版本下载32位和64位的程序。
解压后是两个文件evtsys.dll和evtsys.exe
把这两个文件拷贝到 c:\windows\system32目录下。
打开Windows命令提示符(开始->运行 输入CMD)
C:\>evtsys –i –h 192.168.10.100   #(日志服务器的IP地址)
-i 表示安装成系统服务
-h 指定log服务器的IP地址
如果要卸载evtsys,则:
net stop evtsys
evtsys -u
启动该服务:
C:\>net start evtsys

php编译安装常见错误

精典错误
  /libxmlrpc/encoding.c:101:undefined reference to 'libiconv_close'
  collect2: ld returned 1 exit status
  make:*** [sapi/fpm/php-fpm] Error 1
  解决方法:
  #make ZEND_EXTRA_LIBS='-liconv'
  错误一、编译php出错
  /php-5.3.2/ext/fileinfo/libmagic/apprentice.c:147:internal compiler error:Segmentation fault
  Please submit a full bug report,
  with preprocessed source if appropriate.
  See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.
  The bug is not reproducible,so it is likely a hardware or OS problem.
  make:*** [ext/fileinfo/libmagic/apprentice.lo] Error 1
  解决方法:内存大于1G即可,这是php5.3.2的一个bug
  --------------------------------------------------------------------
  错误二、重新构造configure文件出错
  ./buildconf --force
  Forcing buildconf
  buildconf:checking installation…
  buildconf:autoconf version 2.59 (ok)
  buildconf:Your version of autoconf likely contains buggy cache code.
  Running vcsclean for you.
  To avoid this,install autoconf-2.13.
  Can't figure out your VCS, not cleaning.
  解决方法:编译安装autoconf-2.13
  再将autoconf-2.13的auotconf文件至/usr/local/autoconf
  --------------------------------------------------------------------
  错误三、编译时缺少库
  configure: error: libXpm.(a|so) not found.
  解决方法:yum install libXpm-devel
  --------------------------------------------------------------------
  错误四、编译时缺少gmp.h文件
  configure: error: Unable to locate gmp.h
  解决方法:yum install gmp-devel
  --------------------------------------------------------------------
  错误五
  Configure: error: xml2-config not found. Please check your libxml2 installation.
  解决方法:
  #yum install libxml2 libxml2-devel (For Redhat & Fedora)
  # aptitude install libxml2-dev      (For ubuntu)
  --------------------------------------------------------------------
  错误六
  Checking for pkg-config… /usr/bin/pkg-config
  configure: error: Cannot find OpenSSL’s <evp.h>
  解决方法:
  #yum install openssl openssl-devel
  --------------------------------------------------------------------
  错误七
  Configure: error: Please reinstall the BZip2 distribution
  解决方法:
  # yum install bzip2 bzip2-devel
  --------------------------------------------------------------------
  错误八
  Configure: error: Please reinstall the libcurl distribution -
  easy.h should be in <curl-dir>/include/curl/
  解决方法:
  # yum install curl curl-devel   (For Redhat & Fedora)
  # install libcurl4-gnutls-dev    (For Ubuntu)
  --------------------------------------------------------------------
  错误九:
  Configure: error: libjpeg.(also) not found.
  解决方法:
  # yum install libjpeg libjpeg-devel
  --------------------------------------------------------------------
  错误十
  Configure: error: libpng.(also) not found.
  --------------------------------------------------------------------
  解决方法:
  # yum install libpng libpng-devel
  --------------------------------------------------------------------
  错误十一
  Configure: error: freetype.h not found.
  解决方法:
  #yum install freetype-devel
  --------------------------------------------------------------------
  错误十二
  Configure: error: Unable to locate gmp.h
  解决方法:
  # yum install gmp-devel
  --------------------------------------------------------------------
  错误十三
  Configure: error: Cannot find MySQL header files under /usr.
  Note that the MySQL client library is not bundled anymore!
  解决方法:
  # yum install mysql-devel            (For Redhat & Fedora)
  # apt-get install libmysql++-dev      (For Ubuntu)
  --------------------------------------------------------------------
  错误十四
  Configure: error: Please reinstall the ncurses distribution
  解决方法:
  # yum install ncurses ncurses-devel
  --------------------------------------------------------------------
  错误十五
  Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
  解决方法:
  # yum install unixODBC-devel
  --------------------------------------------------------------------
  错误十六
  Configure: error: Cannot find pspell
  解决方法:
  # yum install pspell-devel
  --------------------------------------------------------------------
  错误十七
  configure: error: mcrypt.h not found. Please reinstall libmcrypt.
  解决方法:
  # yum install libmcrypt libmcrypt-devel    (For Redhat & Fedora)
  # apt-get install libmcrypt-dev
  --------------------------------------------------------------------
  错误十八
  Configure: error: snmp.h not found. Check your SNMP installation.
  解决方法:
  # yum install net-snmp net-snmp-devel
  --------------------------------------------------------------------
  错误十九
  configure:error:Cannot find ldap.h
  解决方法:
  #yum install openldap-devel openldap
  错误二十
  configure:error:xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
  解决方法:
  #yum install libxslt libxslt-devel
  错误二十一
  checking for libevent >=1.4.11 install prefix… configure: error: Could not find libevent >=1.4.11 in /usr/local/php
  解决方法:
  安装libevent-1.4.11以上版本至/usr/local
  tar xzvf libevent-1.4.14-stable.tar.gz
  cd libevent-1.4.14-stable
  ./configure --prefix=/usr/local
  make&&make install
  在编译。/configure时添加--with-libevent-dir=/usr/local即可
  错误二十二
  cc1: out of memory allocating 2036 bytes after a total of 81846272 bytes
  make: *** [ext/date/lib/parse_date.lo] Error 1
  报错:
  /usr/bin/ld: cannot find -lltdl
  collect2: ld returned 1 exit status
  make:*** [sapi/fpm/php-fpm] Error 1
  解决方法:
  安装ltdl
  #cd /libmcrypt-2.5.7/libltdl/
  #./configure --enable-ltdl-install
  #ldconfig
  #cd php-5.3.6
  #make ZEND_EXTRA_LIBS='-liconv'