CentOS配置远程日志服务器

(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).接收日志的服务器(收集端)

1
2
3
4
5
6
7
8
9
10
11
[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)

1
2
3
4
5
[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.rsyslog.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.rsyslog.com" ] start

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

猜你喜欢

转载自www.cnblogs.com/qzqdy/p/11435338.html