elasticsearch which: no java in (/sbin:/bin:/usr/sbin:/usr/bin)

机器:centos7.2

javahome:
export JAVA_HOME=/root/jdk1.8.0_60
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

[root@i-j73a8nn6 ~]# java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

[root@i-j73a8nn6 ~]# $PATH
-bash: /root/jdk1.8.0_60/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin: No such file or directory

如果不是sudo启动时报错:
[root@i-j73a8nn6 ~]# elasticsearch-2.2.1/bin/elasticsearch
Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.

at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)

Refer to the log for complete error details.

sudo启动报错:
[root@i-j73a8nn6 ~]# sudo elasticsearch-2.2.1/bin/elasticsearch
which: no java in (/sbin:/bin:/usr/sbin:/usr/bin)
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME

阅读 24.3k
7 个回答
新手上路,请多包涵

首先不能用root用户登陆,sudo默认就是root用户,sudo时需要指定其他用户名。例如:sudo -iu user_a bin/elasticsearch

新增了一个用户,让后在以新增用户启动完成。
不知道各路大神有没有在root下启动的方法?

新手上路,请多包涵

vi /etc/sysconfig/elasticsearch
将 JAVA_HOME=/root/jdk1.8.0_60 写到文件中保存后启动
service elasticsearch start
正在启动 elasticsearch: [确定]

新手上路,请多包涵

vi /etc/sysconfig/elasticsearch
将 JAVA_HOME=/root/jdk1.8.0_60 写到文件中保存后启动
service elasticsearch start
正在启动 elasticsearch: [确定]

这个很棒!!!!

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏