rsyslog占用内存过高记录

 

1. 参考其他高版本未出现问题的systemd文件

限制了最大文件打开数

LimitNOFILE=16384

实测,某centos7的系统rsyslog版本:rsyslog-8.24.0-34.el7.x86_64

systemctl status rsyslog|grep -wE "Memory|Active" 

rsyslog运行一个月后,设置了 LimitNOFILE=16384 的系统 rsyslog占用内存为:1GB;通集群其他两个未配置 LimitNOFILE=16384的rsyslog占用内存为:5GB。

 

例1(anolis):

]# cat /usr/lib/systemd/system/rsyslog.service
[Unit]
Description=System Logging Service
;Requires=syslog.socket
Wants=network.target network-online.target
After=network.target network-online.target
#Documentation=man:rsyslogd(8)
#Documentation=https://www.rsyslog.com/doc/

[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/rsyslog
ExecStart=/usr/sbin/rsyslogd -n $SYSLOGD_OPTIONS
UMask=0066
StandardOutput=null
Restart=on-failure

# Increase the default a bit in order to allow many simultaneous
# files to be monitored, we might need a lot of fds.
LimitNOFILE=16384

[Install]
WantedBy=multi-user.target
;Alias=syslog.service

 

例2(kylin):

# cat /usr/lib/systemd/system/rsyslog.service
[Unit]
Description=System Logging Service
;Requires=syslog.socket
Documentation=man:rsyslogd(8)
Documentation=https://www.rsyslog.com/doc/

[Service]
Type=notify
ExecStart=/usr/sbin/rsyslogd -n -iNONE
StandardOutput=null
Restart=on-failure

# Increase the default a bit in order to allow many simultaneous
# files to be monitored, we might need a lot of fds.
LimitNOFILE=16384

[Install]
WantedBy=multi-user.target
;Alias=syslog.service

2. 其他老版本尝试过的方案

systemd直接限制内存,实际测试失败

MemoryMax=80M
MemoryHigh=8M

 

# cat /usr/lib/systemd/system/rsyslog.service
[Unit]
Description=System Logging Service
;Requires=syslog.socket
Wants=network.target network-online.target
After=network.target network-online.target
Documentation=man:rsyslogd(8)
Documentation=http://www.rsyslog.com/doc/

[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/rsyslog
ExecStart=/usr/sbin/rsyslogd -n $SYSLOGD_OPTIONS
Restart=on-failure
UMask=0066
StandardOutput=null
Restart=on-failure
MemoryAccounting=yes


[Install]
WantedBy=multi-user.target
;Alias=syslog.service

 

posted @ 2024-03-15 17:29  咿呀哒喏  阅读(223)  评论(0编辑  收藏  举报