首页 > 解决方案 > Elastic Search Immediately Dies on Mac

问题描述

I downloaded elastic search today. When I try to run it, it is immediately killed with the following message:

Johnathans-MacBook-Pro:Downloads jward$ ./elasticsearch-7.6.1/bin/elasticsearch
./elasticsearch-7.6.1/bin/elasticsearch-env: line 71: 12909 Killed: 9               
"$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.java_version_checker.JavaVersionChecker

My java version is:

java version "11.0.6" 2020-01-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.6+8-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.6+8-LTS, mixed mode)

Why won't the elastic search service start?

标签: macoselasticsearchstartup-error

解决方案


Elasticsearch isn't able to recognize your Java version and that's the reason it is failing. Please see in your logs, the error is thrown from the below class and you can have a look at from below source code.

https://github.com/elastic/elasticsearch/blob/master/distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersionChecker.java#L28 and you can have a look at this class, All it does is checks if the runtime Java version is at least 1.8..

In your case its java 11, so java version isn't a problem, the problem lies in Elasticsearch not recognizing that.

You need to set proper JAVA_HOME in your ~/.zshrc if using latest Mac OS Catalina, as they moved to ~/.zshrc and I see you just mention JAVA_HOME=$(/usr/libexec/java_home) but don't see EXPORT before this. So please add below line.

EXPORT JAVA_HOME=$(/usr/libexec/java_home) 

After that source ~/.zshrc and then close the terminal and see the output of java -version , if it shows java 11 version then you are good to go and run the elasticsearch again.

Hope this helps and let me know if you have further questions.


推荐阅读