From ece94ff0b4ff2e2c1ca84decca38d3c12a684a63 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Thu, 28 Mar 2019 12:45:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96journald=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roles/prepare/tasks/common.yml | 13 +++++++++++++ roles/prepare/templates/95-k8s-journald.conf.j2 | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 roles/prepare/templates/95-k8s-journald.conf.j2 diff --git a/roles/prepare/tasks/common.yml b/roles/prepare/tasks/common.yml index 108e4c8..bbc452b 100644 --- a/roles/prepare/tasks/common.yml +++ b/roles/prepare/tasks/common.yml @@ -42,3 +42,16 @@ - name: 把SCTP列入内核模块黑名单 copy: src=sctp.conf dest=/etc/modprobe.d/sctp.conf + +# 优化设置 journal 日志相关 +- name: 准备 journal 日志相关目录 + file: name={{ item }} state=directory + with_items: + - "/etc/systemd/journald.conf.d" + - "/var/log/journal" + +- name: 优化设置 journal 日志 + template: src=95-k8s-journald.conf.j2 dest=/etc/systemd/journald.conf.d/95-k8s-journald.conf + +- name: 重启 journald 服务 + service: name=systemd-journald state=restarted diff --git a/roles/prepare/templates/95-k8s-journald.conf.j2 b/roles/prepare/templates/95-k8s-journald.conf.j2 new file mode 100644 index 0000000..1f4f07e --- /dev/null +++ b/roles/prepare/templates/95-k8s-journald.conf.j2 @@ -0,0 +1,16 @@ +[Journal] +# 持久化保存到磁盘 +Storage=persistent + +# 最大占用空间 2G +SystemMaxUse=2G + +# 单日志文件最大 200M +SystemMaxFileSize=200M + +# 日志保存时间 2 周 +MaxRetentionSec=2week + +# 禁止转发 +ForwardToSyslog=no +ForwardToWall=no