Zookeeper no such file or directory - apache-zookeeper

I am trying to install the zookeeper in my laptop. Using the file, which is bin.tar.gz 3.6.1 version.https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.6.1/apache-zookeeper-3.6.1-bin.tar.gz
Following the instructions which are:
make a folder logs in the main folder.
change the file name in conf folder, from Zoo_sample.cfg to zoo.cfg
change the dataDir path inside the zoo.cfg to where the logs situated.
put the bin path to the environment variables following the post here:https://medium.com/#shaaslam/installing-apache-zookeeper-on-windows-45eda303e835
Using Windows 10 with Bash, the feedback:
alex0#DESKTOP-AGJ32D1 MINGW64 /c/Tools/apache-zookeeper-3.6.1-bin/bin
$ ./zkServer.sh
ZooKeeper JMX enabled by default
Using config: C:\Tools\apache-zookeeper-3.6.1-bin\conf\zoo.cfg
grep: C:\Tools\apache-zookeeper-3.6.1-bin\conf\zoo.cfg: No such file or directory
grep: C:\Tools\apache-zookeeper-3.6.1-bin\conf\zoo.cfg: No such file or directory
mkdir: cannot create directory ‘’: No such file or directory
Usage: ./zkServer.sh [--config <conf-dir>] {start|start-foreground|stop|version|restart|status|print-cmd}
I am sure that the name of cfg file is properly changed, and the dataDir path is set as well. What could the problem I've made? Any help is highly appreciated.

I've figured it out. It is simply the file name issue.
When I changed it into zoo.cfg, the name of the file is zoo.cfg. Therefore, just change it to zoo should solve the problem.

when you setup zookeeper for the first time at your linux system, the default configuration file that have been created is zoo_sample.cfg then when your run the server or the zkServer.sh file, the file came by default to check on the config file named as zoo.cfg, so there the source of the issue.
zookeeper config dir
in my case what I did is that I renamed the file in the zookeeper dir from zoo_simple.cfg to zoo.cfg by using the following command on terminal.
~$ mv zoo_sample.cfg zoo.cfg
in case you still facing an error of zookeeper failed to start as you see in this error example
Try to run Zookeeper with the config file full path, here's the command:
~$ sudo ./zkServer.sh start /[path_to_zookeeper_config_dir]/zoo.cfg
then the server will start

Related

Moving tftpboot folder

Ok, so I am trying to move the /var/lib/tftpboot folder the "proper" way to a dedicated partition. To accomplish this goal I have setup a separate partition called /app and moved the tftpboot folder there.
Issue 1: Symlink
After I moved the folder I created a symlink from the new directory to the old directory using the ln -s /app/tftpboot /var/lib/ command. After doing this I am unable to successfully restart the service using systemctl restart tftp. However, if I just update the path listed in the service file and the config file the service boots fine.

change the path of the log4j.properties for zookeeper

I would like to change the path of log4j.properties file for zookeeper because I want to read this config file too from a central configuration folder, but I have not found any info on how to do it.
This is how I start zookeeper:
$1/bin/zkServer.sh start $2/zoo.cfg
where
$1: the home directory of the unpacked zookeeper
$2: holds the zookeeper config files
What I do now is a silly solution:
Before I start zookeeper I copy this file to zookeeper home directory: cp $2/log4j.properties $1/conf
Is there any better way to configure the usage of an external log4j.properties file?
Here I assume you use the Zookeeper (and it's scripts) provided by apache-kafka
You need to export a variable before starting zookeeper
Here is the default
if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/log4j.properties"
fi
So, you need to do
export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/path/to/your.properties"
zookeeper-server-start zoo.cfg &
It's best if you refactor these together into a systemctl service, though

zookeeper + Kafka - Unable to create data directory

I´m using zookeeper 3.4.8 in single node and try to use kafka.
When I run this command:
zookeeper-server-start.sh /usr/local/kafka_2.9.2-0.8.2.2 /config/zookeeper.properties
I get the below error:
[2016-02-22 17:32:41,661] ERROR Unexpected exception, exiting abnormally (org.apache.zookeeper.server.ZooKeeperServerMain)
java.io.IOException: Unable to create data directory /var/zookeeper/version-2
at org.apache.zookeeper.server.persistence.FileTxnSnapLog.<init>(FileTxnSnapLog.java:85)
at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:104)
at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:86)
at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:52)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:116)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
Any advice?
One reason could be the inappropriate path specified to zoo.config file.
A lot of solutions on the web specifies the path as ":\zookeeper-3.4.7\data".
Instead of the above mentioned format, specify the address as full path from your C: drive to the data folder. It worked for me. (Don't forget to put double slash \ instead of one in case you're on windows)
I got this problem for this setting on Windows PC:
dataDir=c:/data/zoo/
and thus this error:
2016-12-02 15:29:25,327 [myid:] - ERROR [main:ZooKeeperServerMain#64] - Unexpected exception, exiting abnormally
java.io.IOException: Unable to create data directory ??:\data\zoo\version-2
Problem was solved by changing (I have ZooKeeper on C disk unpackaged)
dataDir=/data/zoo/
Also run command line tool as Administrator if needed
I faced the same issue, and this works with
sudo bin/zookeeper-server-start.sh config/zookeeper.properties
You probably don't have permission to write to the directory log.dirs (see zookeeper.properties). Change the directory to a different one, change the permission setting of the current log.dirs directory or run Kafka as different user. You can use the command ls -l /var/zookeeper to see the current permissions and then chmod to change the permissions.
The reason is that zookeeper has no permission. Trying to use the administrator role to install it.
For window's machine
Solved : Use double slashes inside the path while defining the dataDir path
dataDir=E:\\tools\\zookeeperdata\\data
And in my windows 10 system, using zookeeper 3.4.10. the dataDir attribute should setting like :\\\\zookeeper\\\\data, not d:\zookeeper\data. it also can setting as linux file system separator(d:/zookeeper/data). then this problem should be ok. And in linux, I think it permission problem. also it can come across when dataDir is under driver C in windows system.
If you're running the zookeeper in the Windows 10 machine we need to specify the dataDir property something like this
"dataDir=C:\zookeeper-3.4.13\data"
In my windows 10 system, using zookeeper 3.4.13, the following example path is working:
"dataDir=C:\\dev\\tools\\zookeeper-3.4.13\\data"
You have to use double backslashes.
on zoo.cfg you need to change directory to above or anything similar:
dataDir=C:/zookeeper-3.4.14/zookeeper-3.4.14/data
For windows, set dataDir to full path where you have no access restrictions - with no quotes("")
dataDir=C:\\your-path\
dataDir=C:\\zk\tmp\
Note: I have observed the command to fail for some of the path(though full access) and running command prompt as administrator has solved it.
For windows the below too works:
dataDir=C:\\zookeeper-3.4.14\\zookeeper-3.4.14\\data

Zookeeper startup on system reboot error

I have installed zookeeper on my Linux server ubuntu 12.04 in some folder like abc/zookeeper/zkserver/bin/zkserver.sh start. this works fine and starts the server as expected but when i put this zkserver.sh file in /etc/init.d folder and copy the file in rc2.d folder for the reason to start-up zookeeper on system reboot. and when i run this command /etc/init.d/zkserver.sh start this is giving errors like:
JMX enabled by default
Using config: /etc/init.d/../etc/zookeeper/zoo.cfg
grep: /etc/init.d/../etc/zookeeper/zoo.cfg: No such file or directory
mkdir: cannot create directory `': No such file or directory
Starting zookeeper ... STARTED
The zkServer.sh is dependent on a certain directory structure and certain files being present. It is not supposed to be moved in isolation like that. It is also not supposed to be used as an init script.
Check if your zk download comes with the init script. Try looking at src/packages/rpm/init.d/zookeeper or similar, and use that one instead.

Zookeeper: FAILED TO WRITE PID

So I'm trying to to get started with Accumulo. I installed Hadoop and it runs w/o problems but when I try to start Zookeeper I get:
JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
-n Starting zookeeper ...
/opt/zookeeper/bin/zkServer.sh: line 103: /tmp/zookeeper/zookeeper_server.pid: No such file or directory
FAILED TO WRITE PID
I've looked around can't seem to find an answer.
I have had the same problem. In my case was useful to start Zookeeper and directly specify a configuration file:
/bin/zkServer.sh start conf/zoo.conf
I have never heard of zookeeper, but it could be a permissions issue trying to write the file zookeeper_server.pid or perhaps the directory /tmp/zookeeper/ doesn't exist and the shell script isn't accounting for that possibility. Check the permissions and existence of those directories.
zookeeper distributed with default conf, uses /tmp/zookeeper as dataDir for just example sake. It is suggested changing this value in /path/to/zookeeper/conf/zoo.cfg to /var/lib/zookeeper.
Creating /var/lib/zookeeper needs root access, so sudo is required. This directory when created will have following permissions.
ls -al /var/lib/zookeeper/
drwxr-xrwx 4 root wheel 128 May 9 14:03 .
When zookeeper is started without root permission, it cannot write to this directory. hence fails with error
... /usr/local/zookeeper/bin/zkServer.sh: line 169: /var/lib/zookeeper/zookeeper_server.pid: Permission denied
FAILED TO WRITE PID
You need to give write permissions to allow user starting zookeeper to write to /var/lib/zookeeper. In my case, as I am using it in local, I used the following command and it worked
sudo chmod o+w /var/lib/zookeeper