Skip to content

Commit 19a694d

Browse files
committed
Update for ES 8.17.3
* Update templates/jvm.options.j2 from github 8.17.3 version * Add templates/elasticsearch.options.j2 for es_heap_size, es_jvm_custom_parameters * Removed templates/elasticsearch.j2 (pre systemd defaults file)
1 parent cf2a65f commit 19a694d

File tree

6 files changed

+91
-210
lines changed

6 files changed

+91
-210
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# NOTE!
22

33
This is a fork (with some Ubuntu fixes) of a fork (with ES 8.x
4-
support) of the old elastic supplied ansible role.
4+
support) of the old (no longer supported) elastic supplied ansible
5+
role for installing ES 7.x.
56

67
It has been kept in its original form in case upstream fixes become
7-
available, and to avoid any temptation to improve it.
8+
available, for transparency regarding who changed what and when, and
9+
to encourage leaving it alone (avoiding temptation to "improve" it).
810

911
It's used by `mediacloud/newsscribe-ansible`
12+
13+
NOTE!!!! Installs elasticsearch version 8.17.3, accordingly
14+
jvm.options.j2 has been updated to the version from that release.
15+
*BUT* files not used at Media Cloud have NOT been updated!

defaults/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
es_version: "7.17.0"
2+
es_version: "8.17.3"
33
es_use_snapshot_release: false
44
oss_version: false
55
es_package_name: "elasticsearch"
@@ -20,9 +20,9 @@ es_templates: false
2020
es_user: elasticsearch
2121
es_group: elasticsearch
2222
es_config: {}
23-
es_config_default: "elasticsearch.j2"
2423
es_config_log4j2: ""
2524
es_config_jvm: "jvm.options.j2"
25+
es_config_jvm_local: "elasticsearch.options.j2"
2626
#Need to provide default directories
2727
es_conf_dir: "/etc/elasticsearch"
2828
es_pid_dir: "/var/run/elasticsearch"

tasks/elasticsearch-config.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,6 @@
4848
register: system_change
4949
notify: restart elasticsearch
5050

51-
#Copy the default file
52-
- name: Copy Default File
53-
become: yes
54-
template:
55-
src: "{{ es_config_default }}"
56-
dest: "{{ default_file }}"
57-
owner: root
58-
group: "{{ es_group }}"
59-
mode: "660"
60-
force: yes
61-
backup: yes
62-
notify: restart elasticsearch
63-
6451
#Copy the systemd specific file if systemd is installed
6552
- when: use_system_d and (m_lock_enabled or es_max_open_files is defined)
6653
become: yes
@@ -83,6 +70,9 @@
8370
- reload systemd configuration
8471
- restart elasticsearch
8572

73+
# not supposed to modified locally, but
74+
# es install makes substitutions for @thing@
75+
# so this file is version specific!
8676
- name: Copy jvm.options File
8777
become: yes
8878
template:
@@ -95,6 +85,18 @@
9585
backup: yes
9686
notify: restart elasticsearch
9787

88+
- name: Copy elasticsearch.options File
89+
become: yes
90+
template:
91+
src: "{{ es_config_jvm_local }}"
92+
dest: "{{ es_conf_dir }}/jvm.options.d/elasticsearch.options"
93+
owner: root
94+
group: "{{ es_group }}"
95+
mode: "660"
96+
force: yes
97+
backup: yes
98+
notify: restart elasticsearch
99+
98100
- name: Copy log4j2.properties File
99101
become: yes
100102
template:

templates/elasticsearch.j2

Lines changed: 0 additions & 67 deletions
This file was deleted.

templates/elasticsearch.options.j2

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# extracted from old ansible-elasticsearch jvm.options.j2:
2+
3+
# Xms represents the initial size of total heap space
4+
# Xmx represents the maximum size of total heap space
5+
{% if es_heap_size is defined %}
6+
-Xms{{ es_heap_size }}
7+
-Xmx{{ es_heap_size }}
8+
{% else %}
9+
-Xms2g
10+
-Xmx2g
11+
{% endif %}
12+
13+
{% if es_jvm_custom_parameters !='' %}
14+
{% for item in es_jvm_custom_parameters %}
15+
{{ item }}
16+
{% endfor %}
17+
{% endif %}

templates/jvm.options.j2

Lines changed: 49 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,86 @@
1+
# Media Cloud NOTE: this is the jvm.options from
2+
# https://github.com/elastic/elasticsearch v8.17.3 release, with
3+
# @thing@ replaced
4+
################################################################
5+
##
16
## JVM configuration
7+
##
8+
################################################################
9+
##
10+
## WARNING: DO NOT EDIT THIS FILE. If you want to override the
11+
## JVM options in this file, or set any additional options, you
12+
## should create one or more files in the jvm.options.d
13+
## directory containing your adjustments.
14+
##
15+
## See https://www.elastic.co/guide/en/elasticsearch/reference/8.17/advanced-configuration.html#set-jvm-options
16+
## for more information.
17+
##
18+
################################################################
19+
20+
221

322
################################################################
423
## IMPORTANT: JVM heap size
524
################################################################
625
##
7-
## You should always set the min and max JVM heap
8-
## size to the same value. For example, to set
9-
## the heap to 4 GB, set:
26+
## The heap size is automatically configured by Elasticsearch
27+
## based on the available memory in your system and the roles
28+
## each node is configured to fulfill. If specifying heap is
29+
## required, it should be done through a file in jvm.options.d,
30+
## which should be named with .options suffix, and the min and
31+
## max should be set to the same value. For example, to set the
32+
## heap to 4 GB, create a new file in the jvm.options.d
33+
## directory containing these lines:
1034
##
1135
## -Xms4g
1236
## -Xmx4g
1337
##
14-
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
38+
## See https://www.elastic.co/guide/en/elasticsearch/reference/8.17/heap-size.html
1539
## for more information
1640
##
1741
################################################################
1842

19-
# Xms represents the initial size of total heap space
20-
# Xmx represents the maximum size of total heap space
21-
{% if es_heap_size is defined %}
22-
-Xms{{ es_heap_size }}
23-
-Xmx{{ es_heap_size }}
24-
{% else %}
25-
-Xms2g
26-
-Xmx2g
27-
{% endif %}
2843

2944
################################################################
3045
## Expert settings
3146
################################################################
3247
##
33-
## All settings below this section are considered
34-
## expert settings. Don't tamper with them unless
35-
## you understand what you are doing
48+
## All settings below here are considered expert settings. Do
49+
## not adjust them unless you understand what you are doing. Do
50+
## not edit them in this file; instead, create a new file in the
51+
## jvm.options.d directory containing your adjustments.
3652
##
3753
################################################################
3854

39-
## GC configuration
40-
{% if es_version is version('7.6.0', '<') %}
41-
-XX:+UseConcMarkSweepGC
42-
-XX:CMSInitiatingOccupancyFraction=75
43-
-XX:+UseCMSInitiatingOccupancyOnly
44-
{% else %}
45-
8-13:-XX:+UseConcMarkSweepGC
46-
8-13:-XX:CMSInitiatingOccupancyFraction=75
47-
8-13:-XX:+UseCMSInitiatingOccupancyOnly
48-
{% endif %}
49-
50-
## G1GC Configuration
51-
# NOTE: G1 GC is only supported on JDK version 10 or later
52-
{% if es_version is version('7.6.0', '<') %}
53-
# To use G1GC uncomment the lines below.
54-
# 10-:-XX:-UseConcMarkSweepGC
55-
# 10-:-XX:-UseCMSInitiatingOccupancyOnly
56-
# 10-:-XX:+UseG1GC
57-
{% if es_version is version('7.4.0', '<') %}
58-
# 10-:-XX:InitiatingHeapOccupancyPercent=75
59-
{% else %}
60-
# 10-:-XX:G1ReservePercent=25
61-
# 10-:-XX:InitiatingHeapOccupancyPercent=30
62-
{% endif %}
63-
{% else %}
64-
# to use G1GC, uncomment the next two lines and update the version on the
65-
# following three lines to your version of the JDK
66-
# 10-13:-XX:-UseConcMarkSweepGC
67-
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
68-
14-:-XX:+UseG1GC
69-
14-:-XX:G1ReservePercent=25
70-
14-:-XX:InitiatingHeapOccupancyPercent=30
71-
{% endif %}
72-
73-
{% if es_version is version('7.5.0', '<') %}
74-
## DNS cache policy
75-
# cache ttl in seconds for positive DNS lookups noting that this overrides the
76-
# JDK security property networkaddress.cache.ttl; set to -1 to cache forever
77-
-Des.networkaddress.cache.ttl=60
78-
# cache ttl in seconds for negative DNS lookups noting that this overrides the
79-
# JDK security property networkaddress.cache.negative ttl; set to -1 to cache
80-
# forever
81-
-Des.networkaddress.cache.negative.ttl=10
82-
83-
## optimizations
84-
85-
# pre-touch memory pages used by the JVM during initialization
86-
-XX:+AlwaysPreTouch
87-
88-
## basic
89-
90-
# explicitly set the stack size
91-
-Xss1m
92-
93-
# set to headless, just in case
94-
-Djava.awt.headless=true
95-
96-
# ensure UTF-8 encoding by default (e.g. filenames)
97-
-Dfile.encoding=UTF-8
98-
99-
# use our provided JNA always versus the system one
100-
-Djna.nosys=true
101-
102-
# turn off a JDK optimization that throws away stack traces for common
103-
# exceptions because stack traces are important for debugging
104-
-XX:-OmitStackTraceInFastThrow
105-
106-
# flags to configure Netty
107-
-Dio.netty.noUnsafe=true
108-
-Dio.netty.noKeySetOptimization=true
109-
-Dio.netty.recycler.maxCapacityPerThread=0
110-
{% if es_version is version('7.4.0', '>=') %}
111-
-Dio.netty.allocator.numDirectArenas=0
112-
{% endif %}
113-
114-
# log4j 2
115-
-Dlog4j.shutdownHookEnabled=false
116-
-Dlog4j2.disable.jmx=true
117-
{% endif %}
55+
-XX:+UseG1GC
11856

11957
## JVM temporary directory
12058
-Djava.io.tmpdir=${ES_TMPDIR}
12159

60+
# Leverages accelerated vector hardware instructions; removing this may
61+
# result in less optimal vector performance
62+
20-:--add-modules=jdk.incubator.vector
63+
64+
# Required to workaround performance issue in JDK 23, https://github.com/elastic/elasticsearch/issues/113030
65+
23:-XX:CompileCommand=dontinline,java/lang/invoke/MethodHandle.setAsTypeCache
66+
23:-XX:CompileCommand=dontinline,java/lang/invoke/MethodHandle.asTypeUncached
67+
12268
## heap dumps
12369

124-
# generate a heap dump when an allocation from the Java heap fails
125-
# heap dumps are created in the working directory of the JVM
70+
# generate a heap dump when an allocation from the Java heap fails; heap dumps
71+
# are created in the working directory of the JVM unless an alternative path is
72+
# specified
12673
-XX:+HeapDumpOnOutOfMemoryError
12774

75+
# exit right after heap dump on out of memory error
76+
-XX:+ExitOnOutOfMemoryError
77+
12878
# specify an alternative path for heap dumps; ensure the directory exists and
12979
# has sufficient space
13080
-XX:HeapDumpPath={{ es_heap_dump_path }}
13181

13282
# specify an alternative path for JVM fatal error logs
13383
-XX:ErrorFile={{ es_log_dir }}/hs_err_pid%p.log
13484

135-
## JDK 8 GC logging
136-
137-
8:-XX:+PrintGCDetails
138-
8:-XX:+PrintGCDateStamps
139-
8:-XX:+PrintTenuringDistribution
140-
8:-XX:+PrintGCApplicationStoppedTime
141-
8:-Xloggc:{{ es_log_dir }}/gc.log
142-
8:-XX:+UseGCLogFileRotation
143-
8:-XX:NumberOfGCLogFiles=32
144-
8:-XX:GCLogFileSize=64m
145-
146-
# JDK 9+ GC logging
147-
9-:-Xlog:gc*,gc+age=trace,safepoint:file={{ es_log_dir }}/gc.log:utctime,pid,tags:filecount=32,filesize=64m
148-
{% if es_version is version('7.5.0', '<') %}
149-
# due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise
150-
# time/date parsing will break in an incompatible way for some date patterns and locals
151-
9-:-Djava.locale.providers=COMPAT
152-
153-
{% if es_major_version == "6.x" %}
154-
# temporary workaround for C2 bug with JDK 10 on hardware with AVX-512
155-
10-:-XX:UseAVX=2
156-
{% endif %}
157-
{% endif %}
158-
159-
{% if es_jvm_custom_parameters !='' %}
160-
{% for item in es_jvm_custom_parameters %}
161-
{{ item }}
162-
{% endfor %}
163-
{% endif %}
85+
## GC logging
86+
-Xlog:gc*,gc+age=trace,safepoint:file={{ es_log_dir }}/gc.log:utctime,level,pid,tags:filecount=32,filesize=64m

0 commit comments

Comments
 (0)