0
点赞
收藏
分享

微信扫一扫

could not find java in ES_JAVA_HOME at /root/opt/elastic/elasticsearch-8.1.2/jdk/bin/java

刘员外__ 2022-04-14 阅读 49

报错信息

es@MEPRDAPP01:/root/opt/elastic/elasticsearch-8.1.2> java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
es@MEPRDAPP01:/root/opt/elastic/elasticsearch-8.1.2> sh start.sh 
could not find java in ES_JAVA_HOME at /root/opt/elastic/elasticsearch-8.1.2/jdk/bin/java
es@MEPRDAPP01:/root/opt/elastic/elasticsearch-8.1.2> 

从上文中可以看到,全局的java是存在且版本号大于1.8的,并且当前用户非root用户
查看报错的原因:打开elasticsearch elasticsearch-env查看错误原因
在这里插入图片描述
可以看到该错误是文件不可执行时才报错,那么我们看下他是调用了ES_HOME的jdk,看下该目录下文件是否可执行

查看ES目录下的jdk是否可执行

es@MEPRDAPP01:/root/opt/elastic/elasticsearch-8.1.2> sh start.sh 
could not find java in bundled JDK at /root/opt/elastic/elasticsearch-8.1.2/jdk/bin/java
es@MEPRDAPP01:/root/opt/elastic/elasticsearch-8.1.2> .//root/opt/elastic/elasticsearch-8.1.2/jdk/bin/java -version
bash: .//root/opt/elastic/elasticsearch-8.1.2/jdk/bin/java: 没有那个文件或目录
es@MEPRDAPP01:/root/opt/elastic/elasticsearch-8.1.2> ./root/opt/elastic/elasticsearch-8.1.2/jdk/bin/java -version
bash: ./root/opt/elastic/elasticsearch-8.1.2/jdk/bin/java: 没有那个文件或目录
es@MEPRDAPP01:/root/opt/elastic/elasticsearch-8.1.2> cd /root/opt/elastic/elasticsearch-8.1.2/jdk/bin/java
bash: cd: /root/opt/elastic/elasticsearch-8.1.2/jdk/bin/java: 权限不够

由于root目录是root用户的,不能将root目录的用户和用户组设置为es,因此我们在根目录从新新建一个目录/es,将文件全部移动到/es下

MEPRDAPP01:~/opt # cd  /
MEPRDAPP01:/ # mkdir es
MEPRDAPP01:/ # mv /root/opt/ /es
MEPRDAPP01:/ # chown -R es:es /es
MEPRDAPP01:/ # ll
总用量 80
drwxr-xr-x   2 root root  4096 926 2019 bin
drwxr-xr-x   3 root root  4096 926 2019 boot
drwx------   2 root root   151 926 2019 Desktop
drwxr-xr-x  21 root root  3980 47 22:22 dev
drwxr-xr-x   3 es   es      17 414 13:42 es
drwxr-xr-x 127 root root 12288 414 12:22 etc
drwxr-xr-x   5 root root    49 414 10:40 home

再次执行

es@MEPRDAPP01:/es/opt/elastic/elasticsearch-8.1.2> sh start.sh 

查看报文还有报错 错误1

ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
ERROR: Elasticsearch did not exit normally - check the logs at /es/opt/elastic/logs/elasticsearch.log

修改Elastic的配置文件elasticsearch.yml文件

vim /es/opt/elastic/elasticsearch-8.1.2/config/elasticsearch.yml

添加该配置

node.name: node-1

错误2

  • 编辑配置文件limits.conf
MEPRDAPP01:~ # vim /etc/security/limits.conf

添加如下配置

es hard nofile 65536
es soft nofile 65536
  • 编辑配置文件 sysctl.conf
MEPRDAPP01:~ # vim /etc/sysctl.conf

添加如下配置

vm.max_map_count=655360

查看是否更改

sysctl -p

再次启动

注销调用户es重新登录,再次启动es

MEPRDAPP01:/es/opt/elastic/elasticsearch-8.1.2 # su es
es@MEPRDAPP01:/es/opt/elastic/elasticsearch-8.1.2> sh start.sh 
warning: ignoring JAVA_HOME=/usr/local/java; using bundled JDK
warning: ignoring JAVA_HOME=/usr/local/java; using bundled JDK
warning: ignoring JAVA_HOME=/usr/local/java; using bundled JDK
[2022-04-14T14:23:36,960][INFO ][o.e.n.Node               ] [node-1] version[8.1.2], pid[169299], build[default/tar/31df9689e80bad366ac20176aa7f2371ea5eb4c1/2022-03-29T21:18:59.991429448Z], OS[Linux/4.12.14-94.41-default/amd64], JVM[Eclipse Adoptium/OpenJDK 64-Bit Server VM/17.0.2/17.0.2+8]
[2022-04-14T14:23:36,967][INFO ][o.e.n.Node               ] [node-1] JVM home [/es/opt/elastic/elasticsearch-8.1.2/jdk], using bundled JDK [true]
[2022-04-14T14:23:36,967][INFO ][o.e.n.Node               ] [node-1] JVM arguments [-Xshare:auto, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -Djava.security.manager=allow, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -XX:+ShowCodeDetailsInExceptionMessages, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dio.netty.allocator.numDirectArenas=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j2.formatMsgNoLookups=true, -Djava.locale.providers=SPI,COMPAT, --add-opens=java.base/java.io=ALL-UNNAMED, -XX:+UseG1GC, -Djava.io.tmpdir=/tmp/elasticsearch-3763503562971088099, -XX:+HeapDumpOnOutOfMemoryError, -XX:+ExitOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -Xms31744m, -Xmx31744m, -XX:MaxDirectMemorySize=16642998272, -XX:InitiatingHeapOccupancyPercent=30, -XX:G1ReservePercent=25, -Des.path.home=/es/opt/elastic/elasticsearch-8.1.2, -Des.path.conf=/es/opt/elastic/elasticsearch-8.1.2/config, -Des.distribution.flavor=default, -Des.distribution.type=tar, -Des.bundled_jdk=true]
[2022-04-14T14:23:39,443][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [aggs-matrix-stats]
[2022-04-14T14:23:39,443][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [analysis-common]
[2022-04-14T14:23:39,444][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [constant-keyword]
[2022-04-14T14:23:39,444][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [data-streams]
[2022-04-14T14:23:39,444][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [frozen-indices]
[2022-04-14T14:23:39,444][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-common]
[2022-04-14T14:23:39,444][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-geoip]
[2022-04-14T14:23:39,445][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-user-agent]
....

修改启动脚本内容为后台启动

MEPRDAPP01:/es/opt/elastic/elasticsearch-8.1.2 # vim start.sh
./bin/elasticsearch -d
举报

相关推荐

0 条评论