首页 > 基础资料 博客日记

ElasticSearch--warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME

2024-02-22 21:57:07基础资料围观554

文章ElasticSearch--warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME分享给大家,欢迎收藏Java资料网,专注分享技术知识

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,反而不会报错。

解决办法

1. 进入bin目录

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


文章来源:https://blog.csdn.net/weixin_47006899/article/details/132142588
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!

标签:

相关文章

本站推荐

标签云