Running elasticsearch 2.3.5 on OpenJDK 11

October 23, 2019


Elasticsearch 2.3.5 wouldn't start on ubuntu because of an "Unrecognized VM option 'UseParNewGC'". Here's how I "fixed" it.


Installing elasticsearch on ubuntu 18.04 didn't work, looking at the log we see the service was failing to start:



Oct 23 13:22:35 x systemd[1]: Starting Elasticsearch...
Oct 23 13:22:35 x systemd[1]: Started Elasticsearch.
Oct 23 13:22:35 x elasticsearch[9905]: Unrecognized VM option 'UseParNewGC'
Oct 23 13:22:35 x elasticsearch[9905]: Error: Could not create the Java Virtual Machine.
Oct 23 13:22:35 x elasticsearch[9905]: Error: A fatal exception has occurred. Program will exit.
Oct 23 13:22:35 x systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Oct 23 13:22:35 x systemd[1]: elasticsearch.service: Failed with result 'exit-code'.


We can see java is exited due to an unknown VM option... so where is it getting that?


Listing the elasticsearch package contents with dpkg-query -L elasticsearch and looking we see it uses a few bash scripts under /usr/share/elasticsearch/bin to configure itself.


Run sudo nano /usr/share/elasticsearch/bin/elasticsearch.in.sh and comment out that VM arg


  #ES_GC_OPTS="$ES_GC_OPTS -XX:+UseParNewGC"


Then restart the service and it's good to go!