How to configure ES_JAVA_OPTS for ES 5.0 using ansible playbook


(ganeshbabu) #1

Hi All,

I am trying to start Elasticsearch 5.0.0 using ansible playbook and I am getting the below error I tried to by giving ES_JAVA_OPTS="-Xms1g -Xmx1g" in elasticsearch.j2 (template) but still unable to resolve the below error

fatal: [10.247.0.31]: FAILED! => {"changed": true, "cmd": ["sudo", "service", "master_node_elasticsearch", "start"], "delta": "0:00:00.086526", "end": "2016-11-09 07:46:34.015391", "failed": true, "rc": 1, "start": "2016-11-09 07:46:33.928865", "stderr": "", "stdout": "Starting elasticsearch: Error: encountered environment variables that are no longer supported\nUse jvm.options or ES_JAVA_OPTS to configure the JVM\nES_HEAP_SIZE=1g: set -Xms1g and -Xmx1g in jvm.options or add "-Xms1g -Xmx1g" to ES_JAVA_OPTS\n[FAILED]", "stdout_lines": ["Starting elasticsearch: Error: encountered environment variables that are no longer supported", "Use jvm.options or ES_JAVA_OPTS to configure the JVM", "ES_HEAP_SIZE=1g: set -Xms1g and -Xmx1g in jvm.options or add "-Xms1g -Xmx1g" to ES_JAVA_OPTS", "[FAILED]"], "warnings": ["Consider using 'become', 'become_method', and 'become_user' rather than running sudo"]}

Please help us to setup the JVM for ES 5.0.0

Thanks,
Ganeshbabu R


(Yannick Welsch) #2

Which playbook are you using? The one provided here is not 5.x compatible yet but there is active work on it.


(ganeshbabu) #3

Thanks @ywelsch for showing the active work.:+1:

I will try to setup ES 5.0


(ganeshbabu) #4

Hi @ywelsch

I had a little doubt in setting up ES 5.0 and I am following ES 5.x support active work but getting below error,

fatal: [10.247.0.5]: FAILED! => {"changed": true, "cmd": ["sudo", "service", "master_node_elasticsearch", "start"], "delta": "0:00:00.054053", "end": "2016-11-14 05:09:33.621534", "failed": true, "rc": 7, "start": "2016-11-14 05:09:33.567481", "stderr": "", "stdout": "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set", "stdout_lines": ["MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set"], "warnings": ["Consider using 'become', 'become_method', and 'become_user' rather than running sudo"]}

Though I have given the es_heap_size value in my playbook but still getting the error.

I have attached the my playbook for your reference and somewhere I am doing mistake & pls correct me


  • name: Elasticsearch with custom configuration
    strategy: debug
    #hosts: localhost
    hosts: 10.247.0.5
    remote_user: esadmin
    sudo: yes
    roles:
  • { role: elasticsearch, es_instance_name: "master_node",
    es_config: {
    node.name: "master_node",
    cluster.name: "ES_LOCAL_CLUSTER",
    discovery.zen.ping.unicast.hosts: "10.247.0.5:9301",
    http.port: 9201,
    transport.tcp.port: 9301,
    node.data: true,
    node.master: true,
    bootstrap.memory_lock: true,
    #bootstrap.mlockall: true,
    discovery.zen.ping.multicast.enabled: false,
    network.host: "10.247.0.5"
    }
    }
    vars:
    es_remote_user: esadmin
    es_scripts: true
    es_templates: false
    es_version_lock: false
    es_heap_size: 1g
    es_java_opts: "-Xms1g -Xmx1g"

Regards,
Ganeshbabu R


(Steve Malenfant) #5

You don't need to use es_java_opts. But you should probably make sure that jvm.options goes in /etc/elasticsearch/jvm.options. Doesn't seem like this file is working in default.path.conf. I believe there is an open issue about this. Playbook needs modified to support that (It does delete the default jvm.options).

Also make sure there is nothing in /usr/share/elasticsearch/plugins/

Remove this

# TODO: Re-enable when fixed in ES 5.0.1
#- name: Delete Default JVM Options File (5.x)
#  file: dest=/etc/elasticsearch/jvm.options state=absent

And change to this

# TODO: Disable when fixed in ES 5.0.1
- name: Copy jvm.options File for Instance
  template: src=jvm.options.j2 dest=/etc/elasticsearch/jvm.options owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
  notify: restart elasticsearch
  when: es_version | version_compare('5.0', '>=')

Hopefully that helps your situation. That's how I could run 3 process on the same server.


(ganeshbabu) #6

Hey @carrot

I have tried the same setting as you suggested and I could see its trying to start ES from the path
/usr/share/elasticsearch/bin/elasticsearch

but It fails to start ES and I got the following error,

fatal: [10.247.0.5]: FAILED! => {"changed": true, "cmd": ["service", "master_node_elasticsearch", "start"], "delta": "0:00:00.050567", "end": "2016-11-17 01:26:21.900953", "failed": true, "rc": 7, "start": "2016-11-17 01:26:21.850386", "stderr": "", "stdout": "/usr/share/elasticsearch/bin/elasticsearch\nMAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set", "stdout_lines": ["/usr/share/elasticsearch/bin/elasticsearch", "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set"], "warnings": ["Consider using service module rather than running service"]}

when I check jvm_options file path it placed in /etc/elasticsearch and heap size value also append to the min & max

Please let me know your thoughts..


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.