OPENSEARCH_JAVA_HOME env is not working

Hi,
I am using Opensearch-1.2.3 which ships Java 15 with it. But I want to use Java 11. So i referred Compatibility - OpenSearch documentation which stated to “set OPENSEARCH_JAVA_HOME environment variable to the Java install location” . I tried it but Opensearch installation used bundled jdk-15 but not jdk-11 which I want to use.

 [opensearch-1.2.3]$ export OPENSEARCH_JAVA_HOME=/etc/alternatives/jre_openjdk
[opensearch-1.2.3]$ ./bin/opensearch
[2022-01-07T11:47:12,157][INFO ][o.o.n.Node               ] [chai-node] version[1.2.3], pid[16189], build[tar/8a529d77c7432bc45b005ac1c4ba3b2741b57d4a/2021-12-21T01:36:21.407473Z], OS[Linux/3.10.0-957.10.1.el7.x86_64/amd64], JVM[AdoptOpenJDK/OpenJDK 64-Bit Server VM/15.0.1/15.0.1+9]
[2022-01-07T11:47:12,162][INFO ][o.o.n.Node               ] [chai-node] JVM home [/home/cloud-user/chaitra-opensearch/opensearch-1.2.3/jdk], using bundled JDK [true]
[2022-01-07T11:47:12,162][INFO ][o.o.n.Node               ] [chai-node] JVM arguments [-Xshare:auto, -Dopensearch.networkaddress.cache.ttl=60, -Dopensearch.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -XX:+ShowCodeDetailsInExceptionMessages, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dio.netty.allocator.numDirectArenas=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.locale.providers=SPI,COMPAT, -Xms1g, -Xmx1g, -XX:+UseG1GC, -XX:G1ReservePercent=25, -XX:InitiatingHeapOccupancyPercent=30, -Djava.io.tmpdir=/tmp/opensearch-12173583538575190589, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -Dclk.tck=100, -Djdk.attach.allowAttachSelf=true, -Djava.security.policy=/home/cloud-user/chaitra-opensearch/opensearch-1.2.3/plugins/opensearch-performance-analyzer/pa_config/opensearch_security.policy, -XX:MaxDirectMemorySize=536870912, -Dopensearch.path.home=/home/cloud-user/chaitra-opensearch/opensearch-1.2.3, -Dopensearch.path.conf=/home/cloud-user/chaitra-opensearch/opensearch-1.2.3/config, -Dopensearch.distribution.type=tar, -Dopensearch.bundled_jdk=true]

But when I set JAVA_HOME to my java installation directory like below, it picked up the java version which I want to use.

[opensearch-1.2.3]$ export JAVA_HOME=/etc/alternatives/jre_openjdk
[opensearch-1.2.3]$ ./bin/opensearch
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a futur
[2022-01-07T11:49:17,898][INFO ][o.o.n.Node               ] [chai-node] version[1.2.3], pid[16544], build[tar/8a529d77c7432bc453b2741b57d4a/2021-12-21T01:36:21.407473Z], OS[Linux/3.10.0-957.10.1.el7.x86_64/amd64], JVM[Red Hat, Inc./OpenJDK 64-Bit Server 11.0.13+8-LTS]
[2022-01-07T11:49:17,902][INFO ][o.o.n.Node               ] [chai-node] JVM home [/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-1.el, using bundled JDK [false]
[2022-01-07T11:49:17,902][INFO ][o.o.n.Node               ] [chai-node] JVM arguments [-Xshare:auto, -Dopensearch.networkaddres=60, -Dopensearch.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=a.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recyclityPerThread=0, -Dio.netty.allocator.numDirectArenas=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.loers=SPI,COMPAT, -Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyO.io.tmpdir=/tmp/opensearch-3512813336349669626, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_eg, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -Dclk.tck=100, -Djdk.attach.allf=true, -Djava.security.policy=/home/cloud-user/chaitra-opensearch/opensearch-1.2.3/plugins/opensearch-performance-analyzer/pansearch_security.policy, -XX:MaxDirectMemorySize=536870912, -Dopensearch.path.home=/home/cloud-user/chaitra-opensearch/opensearDopensearch.path.conf=/home/cloud-user/chaitra-opensearch/opensearch-1.2.3/config, -Dopensearch.distribution.type=tar, -Dopensed_jdk=true]

So I want to know how to use OPENSEARCH_JAVA_HOME ?

Hi @chaitra ,

AFAIK, the Opensearch seems to support OPENSEARCH_JAVA_OPTS only, despite documentation mentioned OPENSEARCH_JAVA_HOME. The approach you have tried with JAVA_HOME seems to be the only option (at the moment) to run Opensearch using different JDK. Could you please open an issue here [1] to get it fixed? Thank you!

[1] GitHub - opensearch-project/OpenSearch: 🔎 Open source distributed and RESTful search engine.

@reta That would be great to update in the docs. What document specific part of docs only mention OPENSEARCH_JAVA_HOME?

@searchymcsearchface the OPENSEARCH_JAVA_HOME is explicitly mentioned in the documentation section right there [1], I suspect it leaked from Elasticsearch [2] documentation however this change came only in 7.12.

[1] Compatibility - OpenSearch documentation
[2] Introduce ES_JAVA_HOME by jasontedor · Pull Request #68954 · elastic/elasticsearch · GitHub