diff --git a/CHANGELOG.md b/CHANGELOG.md index 29868078..8f9491d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The **patch** part changes is incremented if multiple releases happen the same m * Proper jinja spacing * evolinux-base: ensure dbus is started and enabled (not by default in the case of an offline netinst) +* elasticsearch : use logrotate for garbage collector logs instead of breaking compression cron ### Removed diff --git a/elasticsearch/tasks/configuration.yml b/elasticsearch/tasks/configuration.yml index 99c311c2..c4a5916a 100644 --- a/elasticsearch/tasks/configuration.yml +++ b/elasticsearch/tasks/configuration.yml @@ -118,6 +118,18 @@ tags: - config +- name: Garbage collector logs rotation by the JVM is disabled + lineinfile: + dest: /etc/elasticsearch/jvm.options.d/evolinux.options + regexp: "^-Xlog:gc" + line: "-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=0" + create: yes + owner: root + group: elasticsearch + mode: "0640" + tags: + - config + - name: Configure cluster members lineinfile: dest: /etc/elasticsearch/elasticsearch.yml diff --git a/elasticsearch/tasks/logs.yml b/elasticsearch/tasks/logs.yml index 01829dc9..018a0201 100644 --- a/elasticsearch/tasks/logs.yml +++ b/elasticsearch/tasks/logs.yml @@ -17,3 +17,12 @@ group: root mode: "0750" when: is_cron_installed.rc == 0 + +- name: "Setup logrotate for JVM garbage collector" + template: + src: logrotate.j2 + dest: /etc/logrotate/elasticsearch + owner: root + group: root + mode: "0750" + when: is_cron_installed.rc == 0 diff --git a/elasticsearch/templates/logrotate.j2 b/elasticsearch/templates/logrotate.j2 new file mode 100644 index 00000000..1e78ddec --- /dev/null +++ b/elasticsearch/templates/logrotate.j2 @@ -0,0 +1,12 @@ +/var/log/elasticsearch/gc.log { + su elasticsearch elasticsearch + daily + rotate {{ elasticsearch_log_rotate_days }} + compress + nodelaycompress + missingok + copytruncate + dateext + dateformat .%Y-%m-%d +} + diff --git a/elasticsearch/templates/rotate_elasticsearch_logs.j2 b/elasticsearch/templates/rotate_elasticsearch_logs.j2 index 849a9ca1..981ca433 100644 --- a/elasticsearch/templates/rotate_elasticsearch_logs.j2 +++ b/elasticsearch/templates/rotate_elasticsearch_logs.j2 @@ -8,7 +8,6 @@ MAX_AGE={{ elasticsearch_log_rotate_days | mandatory }} # Compress logs find ${LOG_DIR} -type f -user ${USER} -name "*.log.????-??-??" -exec gzip --best {} \; find ${LOG_DIR} -type f -user ${USER} -name "*-????-??-??.log" -exec gzip --best {} \; -find ${LOG_DIR} -type f -user ${USER} -name "*.log.??" -not -name "*.gz" -exec gzip --best {} \; # Delete old logs -find ${LOG_DIR} -type f -user ${USER} -name "*gz" -ctime +${MAX_AGE} -delete \ No newline at end of file +find ${LOG_DIR} -type f -user ${USER} -name "*gz" -ctime +${MAX_AGE} -delete