在redhat上创建syslog日志服务器

在redhat上创建syslog日志服务器
 在linux系统中,syslog对应的两个二个进制脚本,分别是/sbin/syslogd和/sbin/klogd,klogd用于记录内核产生的信息放在/var/log/dmesg。syslogd的作用是记录非内核产生的信息,因此记录的信息种类非常多。
构建syslog日志服务器,只需两步。
一,在server端修改/etc/syconfig/syslog,在第六行添加-m,如下图
改完之后,查看syslog的端口514有没有正常打开,netstat -tunp |grep syslog,关闭selinux,执行命令setenforce 0,重启/etc/init.d/syslog restartsever 端设置完毕。
二,在client端,打开/etc/syslog.conf ,在下面添加一行,
*.*                          @192.168.0.160(sever端的ip)
当然client也需关闭selinux,注意client和server要能相互ping通。如果server端有iptables,则需开放udp514端口。
     为了验证刚才的设置有没有效,我重启了client,在sever下/var/log/message,里面记录了client开机的一引起信息,172.16.190.1是我client端的ip.

首先需要注意,6.0版本叫做rsyslog,5.4版本叫syslog
RHEL6.0
客户端配置
[root@server ~]# vi /etc/rsyslog.conf
# Save boot messages also to boot.log
local7.*                                          /var/log/boot.log
*.* @hostname   这里的hostname用服务器的IP地址替换。
然后重新启动服务/etc/init.d/rsyslog restart

服务器端配置:
[root@server ~]# vi /etc/rsyslog.conf
将下面两行的#注释取消掉
# Provides UDP syslog reception
$ModLoad imudp.so
$UDPServerRun 514

然后重新启动服务/etc/init.d/rsyslog restart
使用lsof -i:514  命令来查看rsyslog服务是不是正常侦听端口
注意,防火墙配置的时候要开放UDP的514端口


RHEL5.4
1。客户端
客户端服务器上修改/etc/syslog.conf文件,在最后面加上下面的
*.* @hostname    这里的hostname用服务器的IP地址替换。
重启启动服务/etc/init.d/syslog restart

2 服务器端
在/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"    在这里添加一个-r

重启启动服务/etc/init.d/syslog restart
使用lsof -i:514  命令来查看rsyslog服务是不是正常侦听端口
注意,防火墙配置的时候要开放UDP的514端口

猜你喜欢

转载自blog.csdn.net/qq_20853741/article/details/113487335