JVM Heap size configurable for Elasticsearch

This commit is contained in:
Jérémy Lecour 2016-11-18 12:02:55 +01:00 committed by Jérémy Lecour
parent 11083007d6
commit 91361d0c1d
7 changed files with 51 additions and 2 deletions

View File

@ -18,7 +18,9 @@ Tasks are extracted in several files, included in `tasks/main.yml` :
* `elasticsearch_node_name`: node name, defaults to hostname ;
* `elasticsearch_network_host`: which interfaces to bind to ;
* `elasticsearch_network_publish_host`: which interface to publish ;
* `elasticsearch_custom_datadir`: custom datadir
* `elasticsearch_custom_tmpdir`: custom tmpdir
* `elasticsearch_custom_datadir`: custom datadir ;
* `elasticsearch_custom_tmpdir`: custom tmpdir ;
* `elasticsearch_jvm_xms`: mininum heap size reserved for the JVM (defaults to 2g).
* `elasticsearch_jvm_xmx`: maximum heap size reserved for the JVM (defaults to 2g).
By default, Elasticsearch will listen to the public interfaces (`_site_` cf. https://www.elastic.co/guide/en/elasticsearch/reference/5.0/important-settings.html#network.host), so you will have to secure it, with firewall rules for example.

View File

@ -4,3 +4,5 @@ elasticsearch_network_host: "[_site_, _local_]"
elasticsearch_network_publish_host: "_site_"
elasticsearch_custom_datadir: Null
elasticsearch_custom_tmpdir: Null
elasticsearch_jvm_xms: 2g
elasticsearch_jvm_xmx: 2g

View File

@ -26,6 +26,11 @@
tags:
- config
- name: Create a system config directory for systemd overrides
file:
path: /etc/systemd/system/elasticsearch.service.d
state: directory
- name: Override memory config in systemd unit
ini_file:
dest: /etc/systemd/system/elasticsearch.service.d/elasticsearch.conf

View File

@ -47,3 +47,19 @@
insertafter: "^# *RESTART_ON_UPGRADE=true"
tags:
- config
- name: JVM Heap size (min) is set
lineinfile:
dest: /etc/elasticsearch/jvm.options
regexp: "^-Xms"
line: "-Xms{{ elasticsearch_jvm_xms }}"
tags:
- config
- name: JVM Heap size (max) is set
lineinfile:
dest: /etc/elasticsearch/jvm.options
regexp: "^-Xmx"
line: "-Xmx{{ elasticsearch_jvm_xmx }}"
tags:
- config

View File

@ -6,5 +6,10 @@ Install Logstash.
Everything is in the `tasks/main.yml` file.
## Variables
* `logstash_jvm_xms`: minimum heap size reserved for the JVM (defaults to 256m).
* `logstash_jvm_xmx`: maximum heap size reserved for the JVM (defaults to 1g).
The pipeline must be configured before starting Logstash.
https://www.elastic.co/guide/en/logstash/5.0/index.html

View File

@ -0,0 +1,2 @@
logstash_jvm_xms: 256m
logstash_jvm_xmx: 1g

View File

@ -12,3 +12,20 @@
service:
name: logstash
enabled: yes
- name: JVM Heap size (min) is set
lineinfile:
dest: /etc/logstash/jvm.options
regexp: "^-Xms"
line: "-Xms{{ logstash_jvm_xms }}"
tags:
- config
- name: JVM Heap size (max) is set
lineinfile:
dest: /etc/logstash/jvm.options
regexp: "^-Xmx"
line: "-Xmx{{ logstash_jvm_xmx }}"
tags:
- config