Mac安装Elasticsearch时提示:No Java runtime present, requesting install.

时间:2022-01-07 21:56:21

没有安装java的童鞋可以先去安装一下,地址:https://www.java.com/zh_CN/

安装之后还是提示如下错误:

 ➜  elasticsearch-2.4.3 bin/elasticsearch
No Java runtime present, requesting install.
➜ elasticsearch-2.4.3 java -version
No Java runtime present, requesting install.

执行如下解决方案:

 #  首先 cd elasticsearch-2.4.3(此处是指进入你下载并解压后的elasticsearch文件)
➜ Downloads cd elasticsearch-2.4.3
➜ elasticsearch-2.4.3
➜ elasticsearch-2.4.3 vim .bash_profile
# 在文件中添加如下两句:
# export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
# export PATH=${JAVA_HOME}/bin:$PATH
➜ elasticsearch-2.4.3 source .bash_profile
➜ elasticsearch-2.4.3 java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

至此,该问题解决。

继续执行2步,即可验证Elasticsearch是否安装成功:

  第1步:运行elasticsearch文件,如下:

 ➜  elasticsearch-2.4.3 bin/elasticsearch
[2017-11-27 14:10:49,539][INFO ][node ] [Googam] version[2.4.3], pid[18853], build[d38a34e/2016-12-07T16:28:56Z]
[2017-11-27 14:10:49,539][INFO ][node ] [Googam] initializing ...
[2017-11-27 14:10:50,102][INFO ][plugins ] [Googam] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2017-11-27 14:10:50,132][INFO ][env ] [Googam] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [185.6gb], net total_space [232.5gb], spins? [unknown], types [hfs]
[2017-11-27 14:10:50,132][INFO ][env ] [Googam] heap size [990.7mb], compressed ordinary object pointers [true]
[2017-11-27 14:10:50,133][WARN ][env ] [Googam] max file descriptors [10240] for elasticsearch process likely too low, consider increasing to at least [65536]
[2017-11-27 14:10:51,924][INFO ][node ] [Googam] initialized
[2017-11-27 14:10:51,924][INFO ][node ] [Googam] starting ...
[2017-11-27 14:10:51,989][INFO ][transport ] [Googam] publish_address {127.0.0.1:9300}, bound_addresses {[fe80::1]:9300}, {[::1]:9300}, {127.0.0.1:9300}
[2017-11-27 14:10:51,993][INFO ][discovery ] [Googam] elasticsearch/TxOmRFiySBWHhJAAr8N59g
[2017-11-27 14:10:55,026][INFO ][cluster.service ] [Googam] new_master {Googam}{TxOmRFiySBWHhJAAr8N59g}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2017-11-27 14:10:55,039][INFO ][http ] [Googam] publish_address {127.0.0.1:9200}, bound_addresses {[fe80::1]:9200}, {[::1]:9200}, {127.0.0.1:9200}
[2017-11-27 14:10:55,039][INFO ][node ] [Googam] started
[2017-11-27 14:10:55,060][INFO ][gateway ] [Googam] recovered [0] indices into cluster_state

  第2步:打开浏览器访问:http://localhost:9200/,看到如下json结果集,表明安装成功:

{
"name" : "Googam",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "lqQ7DANKR3C3skh1JKJBdA",
"version" : {
"number" : "2.4.3",
"build_hash" : "d38a34e7b75af4e17ead16f156feffa432b22be3",
"build_timestamp" : "2016-12-07T16:28:56Z",
"build_snapshot" : false,
"lucene_version" : "5.5.2"
},
"tagline" : "You Know, for Search"
}