Thanks, I really needed to know more specifically how can I set the JAVA_HOME variable. I eventually looked at the file /usr/share/elasticsearch/bin/elasticsearch
Through quite a bit of searching I found an include file /usr/share/elasticsearch/bin/elasticsearch and it contained the following code block which indicated I was close to finding it:
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA=`which java`
fi
if [ ! -x "$JAVA" ]; then
echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME"
exit 1
fi
if [ -z "$ES_CLASSPATH" ]; then
echo "You must set the ES_CLASSPATH var" >&2
exit 1
fi
At the top of this file under where it says CONTROLLING STARTUP I found several Java variables so I knew I was close to finding the JAVA_HOME environment variable:
# ES_CLASSPATH -- A Java classpath containing everything necessary to run.
# JAVA_OPTS -- Additional arguments to the JVM for heap size, etc
# ES_JAVA_OPTS -- External Java Opts on top of the defaults set
Further down in the file I saw:
# Any serious use-case though will likely require customization of the
# include. For production installations, it is recommended that you copy
# the sample to one of /usr/share/elasticsearch/elasticsearch.in.sh,
# /usr/local/share/elasticsearch/elasticsearch.in.sh, or
# /opt/elasticsearch/elasticsearch.in.sh and make your modifications there.
I ran ls -al on /usr/share/elasticsearch/bin and saw the file elasticsearch.in.sh and found the entry I needed to fix: JAVA_HOME=/usr/lib/jvm/java-oracle. I modified it to JAVA_HOME=/bin/java, saved the file, and restarted both elasticsearch nodes in the cluster.
For some reason the elasticsearch daemon executed /usr/bin/java, but through a series of symolic links, it still executes the Java binary we need at the path we need, /usr/lib/jvm/java-1.8.0-oracle-1.8.0.151-1jpp.5.el7.x86_64/jre/bin/java:
[root@liferayhost1] ps -ef | grep elastic
elastic+ 96919 1 74 15:04 ? 00:00:15 /usr/bin/java -Xms12g -Xmx12g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Des.path.home=/usr/share/elasticsearch -cp /usr/share/elasticsearch/lib/elasticsearch-2.4.6.jar:/usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch start -Des.pidfile=/var/run/elasticsearch/elasticsearch.pid -Des.default.path.home=/usr/share/elasticsearch -Des.default.path.logs=/var/log/elasticsearch -Des.default.path.data=/usr/local/liferay/elasticsearch/var -Des.default.path.conf=/etc/elasticsearch
root 97041 91410 0 15:04 pts/43 00:00:00 grep --color=auto elastic
[root@portaltest2 bin] ls -al /usr/bin/java
lrwxrwxrwx. 1 root root 22 Jun 28 2018 /usr/bin/java -> /etc/alternatives/java
[root@portaltest2 bin] ls -al /etc/alternatives/java
lrwxrwxrwx. 1 root root 71 Jun 28 2018 /etc/alternatives/java -> **/usr/lib/jvm/java-1.8.0-oracle-1.8.0.151-1jpp.5.el7.x86_64/jre/bin/java**
[root@portaltest2 bin] ls -al /bin/java
lrwxrwxrwx. 1 root root 22 Jun 28 2018 /bin/java -> /etc/alternatives/java
I'm satisfied that we've modified the JAVA_HOME environment variable in the include file at /usr/share/elasticsearch/bin/elasticsearch.in.sh used by the file /usr/share/elasticsearch/bin/elasticsearch to start Elasticsearch 2.4.6 with Java. Thank you!