【转】linux服务器上syslog的配置
(2013-10-09 15:41:15)
标签:
it |
分类: Linux |
一、syslog日志服务:
1、守护进程:syslog
2、端口:514
3、配置文件:/etc/syslog.conf
4、常见日志文件:
/var/log/dmesg 内核引导信息日志
/var/log/message 标准系统错误信息日志
/var/log/maillog 邮件系统信息日志
/var/log/cron 计划任务日志
/var/log/secure 安全信息日志
二、
配置文件:
syslog配置文件如下
-----------------------------------------------------------------
配置文件中每行表示一个项目,格式为:facility.level
action
syslog配置文件如下
-----------------------------------------------------------------
|
[root@server ~]# vim
/etc/syslog.conf
# Log all kernel
messages to the console.
# Logging much else
clutters up the screen.
#kern.*
# Log anything
(except mail) of level info or higher.
# Don't log private
authentication messages!
*.info;mail.none;authpriv.none;cron.none
# The authpriv file
has restricted access.
authpriv.*
# Log all the mail
messages in one place.
mail.*
# Log cron
stuff
cron.*
# Everybody gets
emergency messages
*.emerg
# Save news errors
of level crit and higher in a special file.
uucp,news.crit
# Save boot
messages also to boot.log
local7.*
----------------------------------------------------------------- |
由两个部分组成:
第一部分:选择条件(可以有一个或者多个条件),分为两个字段。
第二部分:操作动作;
kern
内核信息;
user 用户进程信息;
mail 电子邮件相关信息;
daemon 后台进程相关信息;
authpriv 包括特权信息如用户名在内的认证活动;
cron 计划任务信息;
syslog 系统日志信息
lpr 打印服务相关信息。
news
新闻组服务器信息
uucp
uucp 生成的信息
local0----local7 本地用户信息
重要级是选择条件的第二个字段,它代表消息的紧急程度。
按严重程度由低到高排序:
debug
不包含函数条件或问题的其他信息
info 提供信息的消息
none 没有重要级,通常用于排错
notice 具有重要性的普通条件
warning 预警信息
err 阻止工具或某些子系统部分功能实现的错误条件
crit 阻止某些工具或子系统功能实现的错误条件
alert 需要立即被修改的条件
emerg 该系统不可用
日志信息可以分别记录到多个文件里,还可以发送到命名管道、其他程序甚至另一台机器。
syslog 主要支持以下活动:
file 指定文件的绝对路径
terminal 或 prin 完全的串行或并行设备标志符
@host(@IP地址) 远程的日志服务器
三、 搭建Linux日志服务器:
1、编辑/etc/sysconfig/syslog文件,让服务器能够接受客户端传来的数据:
在“SYSLOGD_OPTIONS”行上加“-r”选项以允许接受外来日志消息。
-----------------------------------------------------------------
2、重新启动syslog守护进程。
-----------------------------------------------------------------
-----------------------------------------------------------------
|
[root@client
~]#
# 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
#
# -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 ~]#
----------------------------------------------------------------- |
-----------------------------------------------------------------
|
[root@client
~]#
# Log all kernel messages to
the console.
# Logging much else clutters
up the screen.
#kern.*
*.*
# The authpriv file has
restricted access.
authpriv.*
……下面省略
----------------------------------------------------------------- |
[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

加载中…