Rsyslog远程传输的几种方式
基本介绍
Rsyslog是一个syslogd的多线程增强版,rsyslog vs. syslog-ng 链接是rsyslog官方和syslog特性和性能上的一些对比,目前大部分Linux发行版本默认也是使用rsyslog记录日志。这里介绍rsyslog远程传输的几种方式,对远程日志传输可以有一个了解。
rsyslog提供三个远程日志传输方式:
- UDP: 数据包传输可信度不高
- TCP: 数据包传输可信度比较高
- RELP: 数据包传输可信度最高,避免数据丢失,比较新的协议,目前应用较少
以下为man手册对RELP协议的一个介绍:
RELP can be used instead of UDP or plain TCP syslog to provide reliable delivery of syslog messages. Please note that plain TCP syslog does NOT provide truly reliable delivery, with it messages may be lost when there is a connection problem or the server shuts down. RELP prevents message loss in hose cases.
关于RELP的更进一步了解可以参考 Using TLS with RELP RELP Input Module RELP Output Module (omrelp)
相关配置
To forward messages to another host via UDP, prepend the hostname with the at sign (“@”). To forward it via plain tcp, prepend two at signs (“@@”). To forward via RELP, prepend the string “:omrelp:” in front of the hostname.
UDP传输
Server端配置
/etc/rsyslog.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
或者把以上配置单独存放在/etc/rsyslog.d/
中的xxx.conf配置文件中,尽量避免修改主配置文件,当然如果要独立文件主配置文件中必须含有以下配置
1 2 3 |
|
Client端配置
/etc/rsyslog.conf
1
|
|
以上配置完成之后/etc/init.d/rsyslog restart
TCP传输
TCP配置和UDP类似,如下
Server端配置
/etc/rsyslog.conf
1 2 3 4 5 6 7 8 9 10 11 |
|
Client端配置
/etc/rsyslog.conf
1
|
|
客户端和服务端重启相关服务即可
关于TCP和UDP的传输方式,rsyslog官方推荐使用TCP传输方式
In general, we suggest to use TCP syslog. It is way more reliable than UDP syslog and still pretty fast. The main reason is, that UDP might suffer of message loss. This happens when the syslog server must receive large bursts of messages. If the system buffer for UDP is full, all other messages will be dropped. With TCP, this will not happen. But sometimes it might be good to have a UDP server configured as well. That is, because some devices (like routers) are not able to send TCP syslog by design. In that case, you would need both syslog server types to have everything covered. If you need both syslog server types configured, please make sure they run on proper ports. By default UDP syslog is received on port 514. TCP syslog needs a different port because often the RPC service is using this port as well.
RELP传输
RELP需要安装rsyslog-relp
相应模块
1
|
|
Server端配置
/etc/rsyslog.conf
1 2 3 4 5 6 7 8 |
|
Client端配置
/etc/rsyslog.conf
1 2 3 4 5 |
|
客户端和服务端重启相关服务即可
参考和拓展资料
- Using TLS with RELP
- RELP Input Module
- RELP Output Module (omrelp)
- Rsyslog remote logging using RELP
- UDP Rsyslog
- TCP Rsyslog
–EOF–
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY