没有安装java的童鞋可以先去安装一下,地址:https://www.java.com/zh_CN/
安装之后还是提示如下错误:
1 ➜ elasticsearch-2.4.3 bin/elasticsearch
2 No Java runtime present, requesting install.
3 ➜ elasticsearch-2.4.3 java -version
4 No Java runtime present, requesting install.
执行如下解决方案:
1 # 首先 cd elasticsearch-2.4.3(此处是指进入你下载并解压后的elasticsearch文件)
2 ➜ Downloads cd elasticsearch-2.4.3
3 ➜ elasticsearch-2.4.3
4 ➜ elasticsearch-2.4.3 vim .bash_profile
5 # 在文件中添加如下两句:
6 # export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
7 # export PATH=${JAVA_HOME}/bin:$PATH
8 ➜ elasticsearch-2.4.3 source .bash_profile
9 ➜ elasticsearch-2.4.3 java -version
10 java version "1.8.0_151"
11 Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
12 Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
至此,该问题解决。
继续执行2步,即可验证Elasticsearch是否安装成功:
第1步:运行elasticsearch文件,如下:
1 ➜ elasticsearch-2.4.3 bin/elasticsearch
2 [2017-11-27 14:10:49,539][INFO ][node ] [Googam] version[2.4.3], pid[18853], build[d38a34e/2016-12-07T16:28:56Z]
3 [2017-11-27 14:10:49,539][INFO ][node ] [Googam] initializing ...
4 [2017-11-27 14:10:50,102][INFO ][plugins ] [Googam] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
5 [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]
6 [2017-11-27 14:10:50,132][INFO ][env ] [Googam] heap size [990.7mb], compressed ordinary object pointers [true]
7 [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]
8 [2017-11-27 14:10:51,924][INFO ][node ] [Googam] initialized
9 [2017-11-27 14:10:51,924][INFO ][node ] [Googam] starting ...
10 [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}
11 [2017-11-27 14:10:51,993][INFO ][discovery ] [Googam] elasticsearch/TxOmRFiySBWHhJAAr8N59g
12 [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)
13 [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}
14 [2017-11-27 14:10:55,039][INFO ][node ] [Googam] started
15 [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"
}