N1盒子的存储设备是emmc,为了延长emmc的使用寿命尽可能的将读写文件在内存中完成。
修改systemd journald日志存放目录为内存,也就是/run/log目录,限制最大使用内存空间64MB:
sed -i 's/#Storage=auto/Storage=volatile/' /etc/systemd/journald.conf
sed -i 's/#RuntimeMaxUse=/RuntimeMaxUse=64M/' /etc/systemd/journald.conf
然后重新启动systemd-journald服务:
systemctl restart systemd-journald
修改rsyslog日志存放目录为/run/log:
sed -i 's/\/var\/log/\/run\/log/g' /etc/rsyslog.d/50-default.conf
修改rsyslog运行用户为root,不然/run/log没写入权限:
sed 's/PrivDropToUser syslog/PrivDropToUser root/' /etc/rsyslog.conf
sed 's/PrivDropToUser syslog/PrivDropToGroup root/' /etc/rsyslog.conf
然后重启rsyslog即可:
systemctl restart rsyslog
修改nginx日志目录:
sed -i 's/\/var\/log/\/run\/log/g' /etc/nginx/nginx.conf
mkdir /run/log/nginx
systemctl restart nginx
修改php-fpm日志目录:
sed -i 's/\/var\/log/\/run\/log/g' /etc/php/7.2/fpm/php-fpm.conf
systemctl restart php7.2-fpm
cups修改日志目录:
sed -i 's/\/var\/log/\/run\/log/g' /etc/cups/cups-files.conf
mkdir /run/log/cups
systemctl restart cups
samba修改配置文件日志目录:
log file = /run/log/samba/log.%m
max log size = 50
mkdir /run/log/samba
systemctl restart smbd
添加个开机启动脚本在启动时创建/run/log目录下nginx cups samba目录。
cat /lib/systemd/system/mklogdir.service
[Unit]
Description=mklogdir
Before=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/mklogdir.sh
[Install]
WantedBy=multi-user.target
修改日志轮询logrotate:
sed -i 's/\/var\/log/\/run\/log/g' /etc/logrotate.d/cups-daemon
sed -i 's/\/var\/log/\/run\/log/g' /etc/logrotate.d/nginx
sed -i 's/\/var\/log/\/run\/log/g' /etc/logrotate.d/php7.2-fpm
sed -i 's/\/var\/log/\/run\/log/g' /etc/logrotate.d/rsyslog
sed -i 's/\/var\/log/\/run\/log/g' /etc/logrotate.d/samba
标签:none