├── .ansible-lint ├── .github ├── FUNDING.yml └── workflows │ ├── ci.yml │ ├── release.yml │ └── stale.yml ├── .gitignore ├── .yamllint ├── LICENSE ├── README.md ├── defaults └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── molecule └── default │ ├── converge.yml │ ├── molecule.yml │ └── requirements.yml ├── tasks ├── main.yml ├── setup-Debian.yml └── setup-RedHat.yml └── templates ├── elasticsearch.repo.j2 ├── elasticsearch.yml.j2 ├── heap.options.j2 └── jvm.options.j2 /.ansible-lint: -------------------------------------------------------------------------------- 1 | skip_list: 2 | - 'yaml' 3 | - 'role-name' 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | --- 3 | github: geerlingguy 4 | patreon: geerlingguy 5 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: CI 3 | 'on': 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | schedule: 9 | - cron: "30 4 * * 1" 10 | 11 | defaults: 12 | run: 13 | working-directory: 'geerlingguy.elasticsearch' 14 | 15 | jobs: 16 | 17 | lint: 18 | name: Lint 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Check out the codebase. 22 | uses: actions/checkout@v4 23 | with: 24 | path: 'geerlingguy.elasticsearch' 25 | 26 | - name: Set up Python 3. 27 | uses: actions/setup-python@v5 28 | with: 29 | python-version: '3.x' 30 | 31 | - name: Install test dependencies. 32 | run: pip3 install yamllint 33 | 34 | - name: Lint code. 35 | run: | 36 | yamllint . 37 | 38 | molecule: 39 | name: Molecule 40 | runs-on: ubuntu-latest 41 | strategy: 42 | matrix: 43 | distro: 44 | - rockylinux9 45 | - ubuntu2004 46 | 47 | steps: 48 | - name: Check out the codebase. 49 | uses: actions/checkout@v4 50 | with: 51 | path: 'geerlingguy.elasticsearch' 52 | 53 | - name: Set up Python 3. 54 | uses: actions/setup-python@v5 55 | with: 56 | python-version: '3.x' 57 | 58 | - name: Install test dependencies. 59 | run: pip3 install ansible molecule molecule-plugins[docker] docker 60 | 61 | - name: Run Molecule tests. 62 | run: molecule test 63 | env: 64 | PY_COLORS: '1' 65 | ANSIBLE_FORCE_COLOR: '1' 66 | MOLECULE_DISTRO: ${{ matrix.distro }} 67 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This workflow requires a GALAXY_API_KEY secret present in the GitHub 3 | # repository or organization. 4 | # 5 | # See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy 6 | # See: https://github.com/ansible/galaxy/issues/46 7 | 8 | name: Release 9 | 'on': 10 | push: 11 | tags: 12 | - '*' 13 | 14 | defaults: 15 | run: 16 | working-directory: 'geerlingguy.elasticsearch' 17 | 18 | jobs: 19 | 20 | release: 21 | name: Release 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Check out the codebase. 25 | uses: actions/checkout@v4 26 | with: 27 | path: 'geerlingguy.elasticsearch' 28 | 29 | - name: Set up Python 3. 30 | uses: actions/setup-python@v5 31 | with: 32 | python-version: '3.x' 33 | 34 | - name: Install Ansible. 35 | run: pip3 install ansible-core 36 | 37 | - name: Trigger a new import on Galaxy. 38 | run: >- 39 | ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} 40 | $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2) 41 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Close inactive issues 3 | 'on': 4 | schedule: 5 | - cron: "55 23 * * 0" # semi-random time 6 | 7 | jobs: 8 | close-issues: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | issues: write 12 | pull-requests: write 13 | steps: 14 | - uses: actions/stale@v8 15 | with: 16 | days-before-stale: 120 17 | days-before-close: 60 18 | exempt-issue-labels: bug,pinned,security,planned 19 | exempt-pr-labels: bug,pinned,security,planned 20 | stale-issue-label: "stale" 21 | stale-pr-label: "stale" 22 | stale-issue-message: | 23 | This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! 24 | 25 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. 26 | close-issue-message: | 27 | This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. 28 | stale-pr-message: | 29 | This pr has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! 30 | 31 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. 32 | close-pr-message: | 33 | This pr has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. 34 | repo-token: ${{ secrets.GITHUB_TOKEN }} 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.retry 2 | */__pycache__ 3 | *.pyc 4 | .cache 5 | 6 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | rules: 5 | line-length: 6 | max: 120 7 | level: warning 8 | 9 | ignore: | 10 | .github/workflows/stale.yml 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Jeff Geerling 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible Role: Elasticsearch 2 | 3 | [![CI](https://github.com/geerlingguy/ansible-role-elasticsearch/actions/workflows/ci.yml/badge.svg)](https://github.com/geerlingguy/ansible-role-elasticsearch/actions/workflows/ci.yml) 4 | 5 | An Ansible Role that installs Elasticsearch on RedHat/CentOS or Debian/Ubuntu. 6 | 7 | ## Requirements 8 | 9 | Requires at least Java 8. You can use the [`geerlingguy.java`](https://github.com/geerlingguy/ansible-role-java) to easilly install Java. 10 | 11 | ## Role Variables 12 | 13 | Available variables are listed below, along with default values (see `defaults/main.yml` for default role variables). 14 | 15 | elasticsearch_version: '7.x' 16 | 17 | The major version to use when installing Elasticsearch. 18 | 19 | elasticsearch_package: elasticsearch 20 | 21 | If you want to follow the latest release in the `elasticsearch_version` major release cycle, keep the default here. Otherwise you can add `-7.13.2` (for RHEL-based systems) or `=7.13.2` (for Debian-based systems) to lock in a specific version, e.g. `7.13.2`. 22 | 23 | elasticsearch_package_state: present 24 | 25 | The `elasticsearch` package state; set to `latest` to upgrade or change versions. 26 | 27 | elasticsearch_service_state: started 28 | elasticsearch_service_enabled: true 29 | 30 | Controls the Elasticsearch service options. 31 | 32 | elasticsearch_network_host: localhost 33 | 34 | Network host to listen for incoming connections on. By default we only listen on the localhost interface. Change this to the IP address to listen on a specific interface, or `"0.0.0.0"` to listen on all interfaces. 35 | 36 | When listening on multiple interfaces, if you're setting up a single Elasticsearch server (not a cluster), you should also add `discovery.type: single-node` to `elasticsearch_extra_options`. 37 | 38 | elasticsearch_http_port: 9200 39 | 40 | The port to listen for HTTP connections on. 41 | 42 | elasticsearch_heap_size_min: 1g 43 | 44 | The minimum jvm heap size. 45 | 46 | elasticsearch_heap_size_max: 2g 47 | 48 | The maximum jvm heap size. 49 | 50 | elasticsearch_extra_options: '' 51 | 52 | A placeholder for arbitrary configuration options not exposed by the role. This will be appended as-is to the end of the `elasticsearch.yml` file, as long as your variable preserves formatting with a `|`. For example: 53 | 54 | ```yaml 55 | elasticsearch_extra_options: | # Dont forget the pipe! 56 | some.option: true 57 | another.option: false 58 | ``` 59 | 60 | ## Dependencies 61 | 62 | None. 63 | 64 | ## Example Playbook 65 | 66 | - hosts: search 67 | roles: 68 | - geerlingguy.java 69 | - geerlingguy.elasticsearch 70 | 71 | ## License 72 | 73 | MIT / BSD 74 | 75 | ## Author Information 76 | 77 | This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). 78 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | elasticsearch_version: '7.x' 3 | elasticsearch_package: elasticsearch 4 | elasticsearch_package_state: present 5 | 6 | elasticsearch_service_state: started 7 | elasticsearch_service_enabled: true 8 | 9 | elasticsearch_network_host: localhost 10 | elasticsearch_http_port: 9200 11 | 12 | elasticsearch_heap_size_min: 1g 13 | elasticsearch_heap_size_max: 2g 14 | 15 | elasticsearch_extra_options: '' 16 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: restart elasticsearch 3 | service: name=elasticsearch state=restarted 4 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: [] 3 | 4 | galaxy_info: 5 | role_name: elasticsearch 6 | author: geerlingguy 7 | description: Elasticsearch for Linux. 8 | company: "Midwestern Mac, LLC" 9 | license: "license (BSD, MIT)" 10 | min_ansible_version: 2.10 11 | platforms: 12 | - name: Debian 13 | versions: 14 | - all 15 | - name: Ubuntu 16 | versions: 17 | - all 18 | galaxy_tags: 19 | - web 20 | - system 21 | - monitoring 22 | - logging 23 | - lucene 24 | - elk 25 | - efk 26 | - elasticsearch 27 | -------------------------------------------------------------------------------- /molecule/default/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | #become: true 5 | 6 | pre_tasks: 7 | - name: Update apt cache. 8 | apt: update_cache=true cache_valid_time=600 9 | when: ansible_os_family == 'Debian' 10 | changed_when: false 11 | 12 | roles: 13 | - role: geerlingguy.java 14 | - role: geerlingguy.elasticsearch 15 | -------------------------------------------------------------------------------- /molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | role_name_check: 1 3 | dependency: 4 | name: galaxy 5 | options: 6 | ignore-errors: true 7 | driver: 8 | name: docker 9 | platforms: 10 | - name: instance 11 | image: "geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux9}-ansible:latest" 12 | command: ${MOLECULE_DOCKER_COMMAND:-""} 13 | volumes: 14 | - /sys/fs/cgroup:/sys/fs/cgroup:rw 15 | cgroupns_mode: host 16 | privileged: true 17 | pre_build_image: true 18 | provisioner: 19 | name: ansible 20 | playbooks: 21 | converge: ${MOLECULE_PLAYBOOK:-converge.yml} 22 | -------------------------------------------------------------------------------- /molecule/default/requirements.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - src: geerlingguy.java 3 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - include_tasks: setup-RedHat.yml 4 | when: ansible_os_family == 'RedHat' 5 | 6 | - include_tasks: setup-Debian.yml 7 | when: ansible_os_family == 'Debian' 8 | 9 | - name: Install Elasticsearch. 10 | package: 11 | name: "{{ elasticsearch_package }}" 12 | state: "{{ elasticsearch_package_state }}" 13 | 14 | - name: Configure Elasticsearch 6 or below. 15 | template: 16 | src: "{{ item | basename }}.j2" 17 | dest: "{{ item }}" 18 | owner: root 19 | group: elasticsearch 20 | mode: 0660 21 | with_items: 22 | - /etc/elasticsearch/elasticsearch.yml 23 | - /etc/elasticsearch/jvm.options 24 | notify: restart elasticsearch 25 | when: elasticsearch_version[0] | int < 7 26 | 27 | - name: Configure Elasticsearch 7+. 28 | template: 29 | src: "{{ item | basename }}.j2" 30 | dest: "{{ item }}" 31 | owner: root 32 | group: elasticsearch 33 | mode: 0660 34 | with_items: 35 | - /etc/elasticsearch/elasticsearch.yml 36 | - /etc/elasticsearch/jvm.options.d/heap.options 37 | notify: restart elasticsearch 38 | when: elasticsearch_version[0] | int >= 7 39 | 40 | - name: Force a restart if configuration has changed. 41 | meta: flush_handlers 42 | 43 | - name: Start Elasticsearch. 44 | service: 45 | name: elasticsearch 46 | state: "{{ elasticsearch_service_state }}" 47 | enabled: "{{ elasticsearch_service_enabled }}" 48 | 49 | - name: Make sure Elasticsearch is running before proceeding. 50 | wait_for: 51 | host: "{{ elasticsearch_network_host }}" 52 | port: "{{ elasticsearch_http_port }}" 53 | delay: 3 54 | timeout: 300 55 | -------------------------------------------------------------------------------- /tasks/setup-Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Add required dependencies. 3 | apt: 4 | name: 5 | - apt-transport-https 6 | - gnupg2 7 | state: present 8 | 9 | - name: Add Elasticsearch apt key. 10 | apt_key: 11 | url: https://artifacts.elastic.co/GPG-KEY-elasticsearch 12 | state: present 13 | 14 | - name: Add Elasticsearch repository. 15 | apt_repository: 16 | repo: 'deb https://artifacts.elastic.co/packages/{{ elasticsearch_version }}/apt stable main' 17 | state: present 18 | update_cache: true 19 | -------------------------------------------------------------------------------- /tasks/setup-RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Add Elasticsearch GPG key. 3 | rpm_key: 4 | key: https://artifacts.elastic.co/GPG-KEY-elasticsearch 5 | state: present 6 | 7 | - name: Add Elasticsearch repository. 8 | template: 9 | src: elasticsearch.repo.j2 10 | dest: /etc/yum.repos.d/elasticsearch.repo 11 | mode: 0644 12 | -------------------------------------------------------------------------------- /templates/elasticsearch.repo.j2: -------------------------------------------------------------------------------- 1 | [elasticsearch-{{ elasticsearch_version }}] 2 | name=Elasticsearch repository for {{ elasticsearch_version }} packages 3 | baseurl=https://artifacts.elastic.co/packages/{{ elasticsearch_version }}/yum 4 | gpgcheck=1 5 | gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch 6 | enabled=1 7 | autorefresh=1 8 | type=rpm-md 9 | -------------------------------------------------------------------------------- /templates/elasticsearch.yml.j2: -------------------------------------------------------------------------------- 1 | # {{ ansible_managed }} 2 | # ======================== Elasticsearch Configuration ========================= 3 | # 4 | # NOTE: Elasticsearch comes with reasonable defaults for most settings. 5 | # Before you set out to tweak and tune the configuration, make sure you 6 | # understand what are you trying to accomplish and the consequences. 7 | # 8 | # The primary way of configuring a node is via this file. This template lists 9 | # the most important settings you may want to configure for a production cluster. 10 | # 11 | # Please consult the documentation for further information on configuration options: 12 | # https://www.elastic.co/guide/en/elasticsearch/reference/index.html 13 | # 14 | # ---------------------------------- Cluster ----------------------------------- 15 | # 16 | # Use a descriptive name for your cluster: 17 | # 18 | #cluster.name: my-application 19 | # 20 | # ------------------------------------ Node ------------------------------------ 21 | # 22 | # Use a descriptive name for the node: 23 | # 24 | #node.name: node-1 25 | # 26 | # Add custom attributes to the node: 27 | # 28 | #node.attr.rack: r1 29 | # 30 | # ----------------------------------- Paths ------------------------------------ 31 | # 32 | # Path to directory where to store the data (separate multiple locations by comma): 33 | # 34 | path.data: /var/lib/elasticsearch 35 | # 36 | # Path to log files: 37 | # 38 | path.logs: /var/log/elasticsearch 39 | # 40 | # ----------------------------------- Memory ----------------------------------- 41 | # 42 | # Lock the memory on startup: 43 | # 44 | #bootstrap.memory_lock: true 45 | # 46 | # Make sure that the heap size is set to about half the memory available 47 | # on the system and that the owner of the process is allowed to use this 48 | # limit. 49 | # 50 | # Elasticsearch performs poorly when the system is swapping the memory. 51 | # 52 | # ---------------------------------- Network ----------------------------------- 53 | # 54 | # Set the bind address to a specific IP (IPv4 or IPv6): 55 | # 56 | network.host: {{ elasticsearch_network_host }} 57 | # 58 | # Set a custom port for HTTP: 59 | # 60 | http.port: {{ elasticsearch_http_port }} 61 | # 62 | # For more information, consult the network module documentation. 63 | # 64 | # --------------------------------- Discovery ---------------------------------- 65 | # 66 | # Pass an initial list of hosts to perform discovery when new node is started: 67 | # The default list of hosts is ["127.0.0.1", "[::1]"] 68 | # 69 | #discovery.zen.ping.unicast.hosts: ["host1", "host2"] 70 | # 71 | # Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): 72 | # 73 | #discovery.zen.minimum_master_nodes: 74 | # 75 | # For more information, consult the zen discovery module documentation. 76 | # 77 | # ---------------------------------- Gateway ----------------------------------- 78 | # 79 | # Block initial recovery after a full cluster restart until N nodes are started: 80 | # 81 | #gateway.recover_after_nodes: 3 82 | # 83 | # For more information, consult the gateway module documentation. 84 | # 85 | # ---------------------------------- Various ----------------------------------- 86 | # 87 | # Require explicit names when deleting indices: 88 | # 89 | #action.destructive_requires_name: true 90 | 91 | {{ elasticsearch_extra_options }} 92 | -------------------------------------------------------------------------------- /templates/heap.options.j2: -------------------------------------------------------------------------------- 1 | ## JVM configuration 2 | 3 | ################################################################ 4 | ## IMPORTANT: JVM heap size 5 | ################################################################ 6 | ## 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: 10 | ## 11 | ## -Xms4g 12 | ## -Xmx4g 13 | ## 14 | ## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html 15 | ## for more information 16 | ## 17 | ################################################################ 18 | 19 | # Xms represents the initial size of total heap space 20 | # Xmx represents the maximum size of total heap space 21 | 22 | -Xms{{ elasticsearch_heap_size_min }} 23 | -Xmx{{ elasticsearch_heap_size_max }} 24 | -------------------------------------------------------------------------------- /templates/jvm.options.j2: -------------------------------------------------------------------------------- 1 | ## JVM configuration 2 | 3 | ################################################################ 4 | ## IMPORTANT: JVM heap size 5 | ################################################################ 6 | ## 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: 10 | ## 11 | ## -Xms4g 12 | ## -Xmx4g 13 | ## 14 | ## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html 15 | ## for more information 16 | ## 17 | ################################################################ 18 | 19 | # Xms represents the initial size of total heap space 20 | # Xmx represents the maximum size of total heap space 21 | 22 | -Xms{{ elasticsearch_heap_size_min }} 23 | -Xmx{{ elasticsearch_heap_size_max }} 24 | 25 | ################################################################ 26 | ## Expert settings 27 | ################################################################ 28 | ## 29 | ## All settings below this section are considered 30 | ## expert settings. Don't tamper with them unless 31 | ## you understand what you are doing 32 | ## 33 | ################################################################ 34 | 35 | ## GC configuration 36 | 8-13:-XX:+UseConcMarkSweepGC 37 | 8-13:-XX:CMSInitiatingOccupancyFraction=75 38 | 8-13:-XX:+UseCMSInitiatingOccupancyOnly 39 | 40 | ## G1GC Configuration 41 | # NOTE: G1 GC is only supported on JDK version 10 or later 42 | # to use G1GC, uncomment the next two lines and update the version on the 43 | # following three lines to your version of the JDK 44 | # 10-13:-XX:-UseConcMarkSweepGC 45 | # 10-13:-XX:-UseCMSInitiatingOccupancyOnly 46 | 14-:-XX:+UseG1GC 47 | 14-:-XX:G1ReservePercent=25 48 | 14-:-XX:InitiatingHeapOccupancyPercent=30 49 | 50 | ## DNS cache policy 51 | # cache ttl in seconds for positive DNS lookups noting that this overrides the 52 | # JDK security property networkaddress.cache.ttl; set to -1 to cache forever 53 | -Des.networkaddress.cache.ttl=60 54 | # cache ttl in seconds for negative DNS lookups noting that this overrides the 55 | # JDK security property networkaddress.cache.negative ttl; set to -1 to cache 56 | # forever 57 | -Des.networkaddress.cache.negative.ttl=10 58 | 59 | ## optimizations 60 | 61 | # pre-touch memory pages used by the JVM during initialization 62 | -XX:+AlwaysPreTouch 63 | 64 | ## basic 65 | 66 | # explicitly set the stack size 67 | -Xss1m 68 | 69 | # set to headless, just in case 70 | -Djava.awt.headless=true 71 | 72 | # ensure UTF-8 encoding by default (e.g. filenames) 73 | -Dfile.encoding=UTF-8 74 | 75 | # use our provided JNA always versus the system one 76 | -Djna.nosys=true 77 | 78 | # turn off a JDK optimization that throws away stack traces for common 79 | # exceptions because stack traces are important for debugging 80 | -XX:-OmitStackTraceInFastThrow 81 | 82 | # enable helpful NullPointerExceptions (https://openjdk.java.net/jeps/358), if 83 | # they are supported 84 | 14-:-XX:+ShowCodeDetailsInExceptionMessages 85 | 86 | # flags to configure Netty 87 | -Dio.netty.noUnsafe=true 88 | -Dio.netty.noKeySetOptimization=true 89 | -Dio.netty.recycler.maxCapacityPerThread=0 90 | 91 | # log4j 2 92 | -Dlog4j.shutdownHookEnabled=false 93 | -Dlog4j2.disable.jmx=true 94 | 95 | # Fix for log4shell exploit 96 | -Dlog4j2.formatMsgNoLookups=true 97 | 98 | -Djava.io.tmpdir=${ES_TMPDIR} 99 | 100 | ## heap dumps 101 | 102 | # generate a heap dump when an allocation from the Java heap fails 103 | # heap dumps are created in the working directory of the JVM 104 | -XX:+HeapDumpOnOutOfMemoryError 105 | 106 | # specify an alternative path for heap dumps; ensure the directory exists and 107 | # has sufficient space 108 | -XX:HeapDumpPath=data 109 | 110 | # specify an alternative path for JVM fatal error logs 111 | -XX:ErrorFile=logs/hs_err_pid%p.log 112 | 113 | ## JDK 8 GC logging 114 | 115 | 8:-XX:+PrintGCDetails 116 | 8:-XX:+PrintGCDateStamps 117 | 8:-XX:+PrintTenuringDistribution 118 | 8:-XX:+PrintGCApplicationStoppedTime 119 | 8:-Xloggc:logs/gc.log 120 | 8:-XX:+UseGCLogFileRotation 121 | 8:-XX:NumberOfGCLogFiles=32 122 | 8:-XX:GCLogFileSize=64m 123 | 124 | # JDK 9+ GC logging 125 | 9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m 126 | # due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise 127 | # time/date parsing will break in an incompatible way for some date patterns and locals 128 | 9-:-Djava.locale.providers=COMPAT 129 | 130 | # temporary workaround for C2 bug with JDK 10 on hardware with AVX-512 131 | 10-:-XX:UseAVX=2 132 | --------------------------------------------------------------------------------