0

I need to run side by side two ElasticSearch instances (version 1.7 and version 5.2.2) on the same server (Widows 2012 R2). When I try to run the newer version, I receive an error:

PS C:\Program Files\Elasticsearch\elasticsearch-5.2.2\bin> .\elasticsearch.bat
Error: encountered environment variables that are no longer supported
Use jvm.options or ES_JAVA_OPTS to configure the JVM
ES_HEAP_SIZE=8g: set -Xms8g and -Xmx8g in jvm.options or add "-Xms8g -Xmx8g" to ES_JAVA_OPTS

This is caused by the fact that that there was a breaking change (described here) in the way the heap size is set. In the previous version of ElasticSearch (1.7) it was set by an environment variable:

ES_HEAP_SIZE = 8g

I tried setting up another env variable:

ES_JAVA_OPTS = -Xms8g -Xmx8g

and I also edited jvm.options file by adding

-Xms8g
-Xmx8g

but I'm still getting the same error.

Is there a way to configure heap size in ElasticSearch 5.2.2 without deleting ES_HEAP_SIZE environment variable (which I need to keep version 1.7 up and running)? If not, is it possible to set heap size in the old version in a way that would also allow the new version to run?

Community
  • 1
  • 1
pmbanka
  • 1,902
  • 17
  • 24

2 Answers2

1

Edit: Given that jvm.options is not an option, the only thing I see is modifying your elasticsearch/bin/elasticsearch script, mostly the line:

ES_JAVA_OPTS="$(parse_jvm_options "$ES_JVM_OPTIONS") $ES_JAVA_OPTS" #default

to: ES_JAVA_OPTS="-Xms myXmsValue -Xmx myXmxValue -someOtherOptions someValue"

With the other options and value according to what you want.

Adonis
  • 4,670
  • 3
  • 37
  • 57
  • The file is actually in the `elasticsearch/config`, and I already tried editing it... But ES v5.2.2 still complains about the `ES_HEAP_SIZE` env var. – pmbanka Mar 10 '17 at 14:48
  • Then I would modify the launch script, see my edit (also good catch, it is indeed in the `config` folder) See my edited answer – Adonis Mar 10 '17 at 15:15
1

Here is what I found out:

it turns out that the error I was struggling with was raised not by ElasticSearch itself, but by the batch script running the ElasticSearch (bin\elasticsearch.bat). The problematic lines are:

if not "%ES_HEAP_SIZE%" == "" set bad_env_var=1
(...)
if %bad_env_var% == 1 (
    echo Error: encountered environment variables that are no longer supported
    echo Use jvm.options or ES_JAVA_OPTS to configure the JVM
    (...)
    if not "%ES_HEAP_SIZE%" == "" echo ES_HEAP_SIZE=%ES_HEAP_SIZE%: set -Xms%ES_HEAP_SIZE% and -Xmx%ES_HEAP_SIZE% in jvm.options or add "-Xms%ES_HEAP_SIZE% -Xmx%ES_HEAP_SIZE%" to ES_JAVA_OPTS
    (...)
    exit /b 1
)

As far as I can see, this check is there in order to help people migrating from older version to the newer, pointing them to a new way of setting up the heap size. Apart from that, the environment variable ES_HEAP_SIZE is not mentioned in the script, so its' existence should not affect the ElasticSearch 5.2.2 instance. Based on these observations, the easiest fix seems to be simply commenting out the check:

rem if not "%ES_HEAP_SIZE%" == "" set bad_env_var=1

I tried it and both instances of ElasticSearch now run side by side without issues.

One additional trap to avoid is not to set up the heap size in both the file and ES_JAVA_OPTS, which leads to duplicate min heap size settings found error when deploying. Just stick to the file config.

Huge thanks to @asettouf whose answer led me to the correct solution!

pmbanka
  • 1,902
  • 17
  • 24