Linux7添加syslog,在CentOS 7.2上使用rsyslog配置syslog server

--=========准备========

1.firewall状态检查

firewall-cmd --state

2.停止和禁用

systemctl stop firewalld.service

systemctl disable firewalld.service

3.检查服务

systemctl status firewalld.service

4.检查iptables

systemctl status iptables.service

systemctl stop iptables.service

--==========配置=========

1.打开配置文件

vim /etc/rsyslog.conf

2.启用rsyslog从UDP 514端口接收日志

$ModLoad imudp

$UDPServerRun 514

3.启用rsyslog从TCP 514端口接收日志

$ModLoad imtcp

$InputTCPServerRun 514

4.创建一个日志接收模板

在GLOBAL DIRECTIVES块前,加入

$template RemoteLogs,"/var/log/%HOSTNAME%/%PROGRAMNAME%.log" *

*.*  ?RemoteLogs

备注:

The "& ~" sign represents a redirect rule, and is used to tell rsyslog daemon to stop processing log messages further, and not write them locally. If this redirection is not used, all the remote messages would be also written on local log files besides the log files described above, which means they would practically be written twice. Another consequence of using this rule is that the syslog server's own log messages would only be written to dedicated files named after machine's hostname.

加入规则:

#记录所有日志类型的info级别以及大于info级别的信息,但是mail邮件信息,authpriv验证方面的信息和cron时间任务相关的信息除外

*.info,mail.none,authpriv.none,cron.none    ?RemoteLogs

5.

systemctl restart rsyslog

6.

netstat -tulpn | grep rsyslog

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值