syslog配置文件如下
-----------------------------------------------------------------
[root@server ~]# vim /etc/syslog.conf
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
# The authpriv file has restricted access.
authpriv.* /var/log/secure
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
*.emerg *
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.*
----------------------------------------------------------------- |
三、 搭建Linux日志服务器:
-----------------------------------------------------------------
[root@client ~]# vim /etc/sysconfig/syslog
# Options to syslogd
# -m 0 disables 'MARK' messages.
# -r enables logging from remote machines
# -x disables DNS lookups on messages recieved with -r
# See syslogd(8) for more details
SYSLOGD_OPTIONS="-r -m 0"
# Options to klogd
# -2 prints all kernel oops messages twice; once for klogd to decode, and
# once for processing with 'ksymoops'
# -x disables all klogd processing of oops messages entirely
# See klogd(8) for more details
KLOGD_OPTIONS="-x"
#
SYSLOG_UMASK=077
# set this to a umask value to use for all log files as in umask(1).
# By default, all permissions are removed for "group" and "other".
----------------------------------------------------------------- |
-----------------------------------------------------------------
[root@client ~]# service syslog restart
关闭内核日志记录器: [确定]
关闭系统日志记录器: [确定]
启动系统日志记录器: [确定]
启动内核日志记录器: [确定]
[root@client ~]#
----------------------------------------------------------------- |
四、配置各客户端:
1、配置/etc/syslog.conf
修改客户机/etc/syslog.conf文件,在有关配置行的操作动作部分用一个“@”字符指向日志服务器
-----------------------------------------------------------------
[root@client ~]# vim /etc/syslog.conf
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
*.* @10.64.165.210
# The authpriv file has restricted access.
authpriv.* /var/log/secure
……下面省略
----------------------------------------------------------------- |
2、重启客户端syslog使设置生效。
检测成果:
下图是我们在客户端重启iptables服务后在服务端看到的日志情况:
-----------------------------------------------------------------
[root@client ~]# cat /var/log/messages |tail
Nov 30 16:44:29 10.64.165.200 kernel: klogd 1.4.1, log source = /proc/kmsg started.
Nov 30 16:44:33 10.64.165.200 kernel: Removing netfilter NETLINK layer.
Nov 30 16:44:33 10.64.165.200 kernel: ip_tables: (C) 2000-2006 Netfilter Core Team
Nov 30 16:44:33 10.64.165.200 kernel: Netfilter messages via NETLINK v0.30.
Nov 30 16:44:33 10.64.165.200 kernel: ip_conntrack version 2.4 (4096 buckets, 32768 max) - 228 bytes per conntrack
----------------------------------------------------------------- |