1.free -m
2.查找buff/cache占用过大的程序
下载hcache(https://github.com/silenceshell/hcache)
chmod 755 hcache
./hcache --top 10
3. 修改rsyslog配置
vim /usr/lib/systemd/system/rsyslog.service
MemoryAccounting=yes
MemoryMax=80M
MemoryHigh=8M
重启
systemctl daemon-reload
systemctl restart rsyslog
4.提高rsyslog日志级别
将*.info改为*.err
vi /etc/rsyslog.conf
重启
systemctl daemon-reload
systemctl restart rsyslog
5.修改Journal配置
vim /etc/systemd/journald.conf
Storage=persistent
SystemMaxUse=1G
SystemMaxFileSize=10M
MaxRetentionSec=1month
ForwardToSyslog=no
ForwardToWall=no
Storage含义:
volatile 代表日志只存在内存中,即/run/log/journal/
persistent 代表日志只存在磁盘中,即/var/log/journal/
auto 代表日志存在磁盘中,或者内存中,取决于你是否创建/var/log/journal/目录,部分系统是需要手动mkdir -p /var/log/journal/,systemctl restart systemd-journald来解放内存。
none 日志不保留,全部drop,当你决定不使用systemd-journald的时候,你可以使用。
重启
systemctl restart systemd-journald



