简体   繁体   中英

How to start Elasticsearch service with multiple JAVA JDKs

On our servers we are using more than one Java JDK. I'm not able to change this, as we have dependencies for older Java versions. Therefore I'm not able to start the current elasticsearch version (1.5.2) as it needs a JDK > 1.7.0_55, although we have other versions, including a 1.7.0_79, installed. The old version executable is stored under /bin while the newer ones are installed to /usr/jdk1.x.x_xx/bin. I haven't found any option in the /etc/elasticsearch/elasticsearch.yml to set the path to the java executable. I also tried to set the environment vars $PATH and $JAVA_HOME to the newer version, but without any luck. Is there a way to force elasticsearch to use a newer version instead of the old one?

Go to the elasticsearch bash script that is used to launch elasticsearch.

If you have installed with an RPM it is located at:

/usr/share/elasticsearch/bin/elasticsearch

Then search for the function launch_service() At the first line of the function add the following line:

JAVA=/usr/java/jdk1.8.0_25/bin/java

Then:

service elasticsearch restart

It will pick up what ever java version you set in the line you added.

Updating the sysconfig is better approach so any of the scripts don't pick another JDK. In my case it worked when I updated the elasticsearch config in /etc/sysconfig/elasticsearch This is pretty much as advised in https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM