CentOS配置远程日志服务器

2019-06-10 19:28:27 5942

(1).发送日志的服务器(被收集)

1

2

3

4

5

   

[root@xuexi ~]# vim /etc/rsyslog.conf

//在#*.* @@remote-host:514行下添加一行

*.* @@192.168.1.222:514  //@@表示使用TCP协议,@表示使用UDP协议

 

[root@xuexi ~]# systemctl restart rsyslog.service

   

(2).接收日志的服务器(收集端)

   

[root@xuexi ~]$ vim /etc/rsyslog.conf

//将以下两行的注释符去除

#$ModLoad imtcp

#$InputTCPServerRun 514

 

[root@xuexi ~]# setenforce 0  //临时关闭SELinux

[root@xuexi ~]# systemctl stop firewalld.service  //临时关闭防火墙

[root@xuexi ~]# systemctl restart rsyslog.service  //重启服务

[root@xuexi ~]# netstat -anlpt | grep 514  //查看是否开启

tcp        0      0 0.0.0.0:514             0.0.0.0:*               LISTEN      9708/rsyslogd

tcp6       0      0 :::514                  :::*                    LISTEN      9708/rsyslogd

   

  注意:收集端需要关闭SELinux和防火墙。

  当被收集端产生日志时,就可以看到接收到的日志了,接收的日志和原来的日志位置一样,不过可以后期定制(local0~local7)


[root@xuexi ~]# tail -f /var/log/messages | grep CentOS6

Feb 15 00:56:12 CentOS6 kernel: Kernel logging (proc) stopped.

Feb 15 00:56:12 CentOS6 rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="2826" x-info="http://www.landui.com"] exiting on signal 15.

Feb 15 00:56:12 CentOS6 kernel: imklog 5.8.10, log source = /proc/kmsg started.

Feb 15 00:56:12 CentOS6 rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="2859" x-info="http://www.landui.com"] start

   

(3).其他需要根据各自使用的日志整理软件配置了,前面应该都是一样的。


提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: