Zookeeper not starting, nohup error

ⅰ亾dé卋堺 提交于 2019-12-06 09:01:04

问题


I have Downloaded zookeeper-3.4.5.tar.gz and after extracting it I wrote conf/zoo.cfg as

tickTime=2000

dataDir=/var/zookeeper

clientPort=2181

Now I tried to start zookeeper by bin/zkServer.sh start it gives

mohit@mohit:~/zookeeper-3.4.5/bin$ sudo sh zkServer.sh start
[sudo] password for mohit: 
JMX enabled by default
Using config: /home/mohit/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

But

$ echo ruok | nc localhost 2181

is not giving any output.

I checked zookeeper.out, it gives

mohit@mohit:~/zookeeper-3.4.5/bin$ cat zookeeper.out 
nohup: failed to run command ‘java’: No such file or directory
mohit@mohit:~/zookeeper-3.4.5/bin$ 

But my JAVA variables are set, I am not getting why this error is coming?

mohit@mohit:~/zookeeper-3.4.5/bin$ echo $JAVA_HOME 
/usr/lib/jdk
mohit@mohit:~/zookeeper-3.4.5/bin$ echo $PATH 
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jdk/bin

please help.Thanks in advance:)


回答1:


Solution:

Sudo was changing the environment.

So I set the environment variables for root.

Thanks to Elliott Frisch.




回答2:


simply add following lines to beginning of zkServer.sh

export JAVA_HOME=/usr/lib/jdk
export PATH=$JAVA_HOME/bin:$PATH

btw1: you can make the script executable by:

 sudo chmod a+x zkServer.sh

I suppose that first line is: #!/bin/bash so you can start it by:

sudo zkServer.sh start

BTW2: it is bad practice to run java code as root if it is not rally necessary. good luck.

BTW3: are you sure that you jdk is directly in folder :/usr/jib/jdk and not in some subfolder? You can validate it by running the exports and then try: java -version



来源:https://stackoverflow.com/questions/20791846/zookeeper-not-starting-nohup-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!