Add elasticsearch jvm.options template and states

This commit is contained in:
Antsiferov Grigory 2018-02-25 09:02:49 +03:00
parent f6e5635c5f
commit 69ee71f540
3 changed files with 79 additions and 4 deletions

View File

@ -10,10 +10,16 @@ fqdn = __salt__['grains.get']('fqdn')
fqdn_ipv6 = __salt__['grains.get']('fqdn_ipv6')
hosts = __salt__['pillar.get']('elastic:hosts', [])
l_nofile = __salt__['pillar.get']('elastic:limits:nofile', 1048576)
l_memlock = __salt__['pillar.get']('elastic:limits:memlock', 'unlimited')
max_map_count = __salt__['pillar.get']('elastic:limits:max_map_count', 262144)
max_threads = __salt__['pillar.get']('elastic:limits:max_threads', 4096)
limits = __salt__['pillar.get']('elastic:limits', {})
l_nofile = limits.get('nofile', 1048576)
l_memlock = limits.get('memlock', 'unlimited')
max_map_count = limits.get('max_map_count', 262144)
max_threads = limits.get('max_threads', 4096)
jvm = __salt__['pillar.get']('elastic:jvm', {})
jvm_heap_size = jvm.get('heap_size', '2g')
jvm_stack_size = jvm.get('stack_size', '1m')
jvm_extra_options = jvm.get('extra_options', {})
# defaults
config = {
@ -45,6 +51,12 @@ state('/etc/elasticsearch/elasticsearch.yml').file.managed(
mode=644, user='root', group='root',
contents="# This file is generated by Salt\n" + yaml.dump(config))
state('/etc/elasticsearch/jvm.options').file.managed(
mode=644, user='root', group='root',
template='jinja', source='salt://elasticsearch/files/jvm.options.tpl',
defaults={'heap_size': jvm_heap_size, 'stack_size': jvm_stack_size,
'extra_options': jvm_extra_options})
state('/etc/conf.d/elasticsearch').file.managed(
mode=644, user='root', group='root',
template='jinja', source="salt://elasticsearch/files/elasticsearch.confd.tpl",

View File

@ -0,0 +1,62 @@
## Managed by Salt
## JVM configuration
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
-Xms{{ heap_size }}
-Xmx{{ heap_size }}
## Expert settings
################################################################
##
## All settings below this section are considered
## expert settings. Don't tamper with them unless
## you understand what you are doing
##
################################################################
## GC configuration
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
## optimizations
# pre-touch memory pages used by the JVM during initialization
-XX:+AlwaysPreTouch
## basic
# force the server VM
-server
# explicitly set the stack size
-Xss{{ stack_size }}
# set to headless, just in case
-Djava.awt.headless=true
# ensure UTF-8 encoding by default (e.g. filenames)
-Dfile.encoding=UTF-8
# use our provided JNA always versus the system one
-Djna.nosys=true
# turn off a JDK optimization that throws away stack traces for common
# exceptions because stack traces are important for debugging
-XX:-OmitStackTraceInFastThrow
# flags to configure Netty
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0
# log4j 2
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true
{% for key, value in extra_options.items() %}
-{{ key }}{{ '='+value if value else '' }}
{% endfor %}

View File

@ -10,5 +10,6 @@ elasticsearch:
- pkg: icedtea3
- pkg: elasticsearch_pkg
- file: /etc/elasticsearch/elasticsearch.yml
- file: /etc/elasticsearch/jvm.options
- file: /etc/security/limits.d/elasticsearch.conf
- file: /etc/conf.d/elasticsearch