zookeeper Starting error :'JAVA_HOME error in zookeeper.out'

zookeeper Starting error :'JAVA_HOME error in zookeeper.out'

当我做

bin/zkServer.sh start    #It shows it has started

ZooKeeper JMX enabled by default
Using config: /data/sparkHA/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

几秒钟后,当我检查状态时,我得到了

ZooKeeper JMX enabled by default
Using config: /data/sparkHA/zookeeper-3.4.9/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.

我的zookeeper.out说

nohup: failed to run command â/usr/bin/java/bin/javaâ: Not a directory

但我在 bashrc 中的 JAVA_HOME 是 usr/bin/java,怎么会额外添加一个 /bin/java,导致目录无效。

同样 echo $JAVA_HOME 输出

/usr/bin/java

如何处理这个错误。请帮忙。谢谢。

也尝试按照 Zookeeper not starting, nohup error 在 zkServer.sh 中设置 JAVA_HOME,但得到同样的错误。

您的 JAVA_HOME 指向 /usr/bin/java 文件,但它应该指向您的 JDK 的根目录。例如对我来说是:

➜  ~ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
➜  ~ ll $JAVA_HOME
total 52064
-rw-rw-r--   1 root  wheel   3.2K Oct  1 09:00 COPYRIGHT
-rw-rw-r--   1 root  wheel    40B Oct  1 09:01 LICENSE
-rw-rw-r--   1 root  wheel   159B Oct  1 09:01 README.html
-rwxrwxr-x   1 root  wheel   108K Sep 22 22:49 THIRDPARTYLICENSEREADME-JAVAFX.txt
-rw-rw-r--   1 root  wheel   173K Oct  1 09:01 THIRDPARTYLICENSEREADME.txt
drwxrwxr-x  46 root  wheel   1.5K Oct  1 09:04 bin
drwxrwxr-x   9 root  wheel   306B Oct  1 09:00 db
drwxrwxr-x   9 root  wheel   306B Oct  1 09:00 include
-rwxrwxr-x   1 root  wheel   4.9M Sep 22 22:49 javafx-src.zip
drwxrwxr-x  10 root  wheel   340B Oct  1 09:02 jre
drwxrwxr-x  14 root  wheel   476B Oct  1 09:02 lib
drwxrwxr-x   5 root  wheel   170B Oct  1 09:01 man
-rw-rw-r--   1 root  wheel   529B Oct  1 09:01 release
-rw-rw-r--   1 root  wheel    20M Oct  1 09:01 src.zip

因此,请尝试将有效路径设置为 JDK 根目录。我认为它应该可以解决您的问题。