es和jdk是一个强依赖的关系,所以当我们在新版本的ElasticSearch压缩包中包含有自带的jdk,但是当我们的Linux中已经安装了jdk之后,就会发现启动es的时候优先去找的是Linux中已经装好的jdk,此时如果jdk的版本不一致,就会造成jdk不能正常运行,报错如下:
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk1.8.0_291/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
如果Linux服务本来没有配置jdk,则会直接使用es目录下默认的jdk,反而不会报错。文章来源:https://www.toymoban.com/news/detail-742183.html
解决办法
1. 进入bin目录文章来源地址https://www.toymoban.com/news/detail-742183.html
1. 进入bin目录
cd /usr/local/elasticsearch-7.14.0/bin
2.修改elasticsearch-env配置
vim ./elasticsearch-env
# 将jdk修改为es中自带jdk的配置目录,es自带的jdk位置/usr/local/es/elasticsearch-7.14.0/jdk
# now make ES_HOME absolute
ES_HOME=`cd "$ES_HOME"; pwd`
while [ "`basename "$ES_HOME"`" != "bin" ]; do
ES_HOME=`dirname "$ES_HOME"`
done
ES_HOME=`dirname "$ES_HOME"`
# now set the classpath
ES_CLASSPATH="$ES_HOME/lib/*"
# now set the path to java
if [ ! -z "$ES_JAVA_HOME" ]; then
JAVA="$ES_JAVA_HOME/bin/java"
JAVA_TYPE="ES_JAVA_HOME"
elif [ ! -z "$JAVA_HOME" ]; then
# fallback to JAVA_HOME
echo "warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME" >&2
#JAVA="$JAVA_HOME/bin/java"
# 将jdk修改为es中自带jdk的配置目录
JAVA="/usr/local/es/elasticsearch-7.14.0/jdk/bin/java"
JAVA_TYPE="JAVA_HOME"
else
# use the bundled JDK (default)
if [ "$(uname -s)" = "Darwin" ]; then
# macOS has a different structure
#JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java"
# 将jdk修改为es中自带jdk的配置目录
JAVA="/usr/local/es/elasticsearch-7.14.0/jdk/bin/java"
else
#JAVA="$ES_HOME/jdk/bin/java"
# 将jdk修改为es中自带jdk的配置目录
JAVA="/usr/local/es/elasticsearch-7.14.0/jdk/bin/java"
fi
JAVA_TYPE="bundled JDK"
fi
到了这里,关于ElasticSearch--warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!