Question

I am using Ubuntu and going to configure zookeeper on ubuntu. I am unable to run command "bin/zkCli.sh -server 127.0.0.1:2181"

ishwar@ubuntu:~/Desktop/storm/zookeeper-3.4.6$ bin/zkServer.sh start
JMX enabled by default
Using config: /home/ishwar/Desktop/storm/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
ishwar@ubuntu:~/Desktop/storm/zookeeper-3.4.6$ bin/zkCli.sh -server 127.0.0.1:2181
bin/zkCli.sh: line 39: java: command not found
ishwar@ubuntu:~/Desktop/storm/zookeeper-3.4.6$ bin/zkCli.sh -server 127.0.0.1:2181

Can any one tell me please why this issue is coming.

Was it helpful?

Solution 2

This could mean 2 things - either java is not installed on your system or if java is installed then JAVA_HOME is not set.
Set JAVA_HOME in .bash_profile using something like export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk/ and then run command source ~/.bash_profile. It will set JAVA_HOME and then you can run zkCli command.

OTHER TIPS

First run bin/zkServer.sh start-foreground instead of bin/zkServer.sh start to see that if zookeeper will run. However, this error is because of not setting JAVA environment variables. to solve that create conf/java.env and write proper java environment variables (such that JAVA_HOME=/path/to/your/java) on it. for example:

touch conf/java.env
echo "JAVA_HOME=/usr/lib/jvm/jdk" > conf/java.env

Now check that everything is OK!

bin/zkServer.sh start

and then

echo ruok | nc localhost 2181

If you didn't install Java please first install it.

Looks like your zookeeper installation is not able to get JAVA_HOME, make sure you have set JAVA_HOME correctly.

mkdir conf/java.env
echo "JAVA_HOME=/usr/lib/jvm/jdk" > conf/java.env

Secondly be very sure about passing configuration file path, and try to start with following command

bin/zkServer.sh start

Than use following command to connect:

bin/zkCli.sh -server 127.0.0.1:2181

From your installation directory, more information Zookeepr installation on ubuntu.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top