FAILED TO WRITE PID installing Zookeeper
Asked Answered
B

12

15

I am new to Zookeeper and it has being a real issue to install it and run. I am not sure what is wrong in here but I will explain what I've being doing to make it more clear:

1.- I've followed the installation guide provided by Apache. This means download the Zookeeper distribution (stable release) extracted the file and moved into the home directory.

2.- As I am using Ubuntu 12.04 I've modified the .bashrc file including this:

export ZOOKEEPER_INSTALL=/home/myusername/zookeeper-3.4.5
export PATH=$PATH:$ZOOKEEPER_INSTALL/bin

3.- Create a config file on conf/zoo.cfg

tickTime=2000
dataDir=/var/zookeeper
clientPort=2181

and also tried with:

dataDir=/var/log/zookeeper

and

dataDir=/var/bin/zookeeper

4.- When running the start command

zkServer.sh start or `bin/zkServer.sh start` nothing happens and always returns this

JMX enabled by default
Using config: /home/sasuke/zookeeper-3.4.5/bin/../conf/zoo.cfg
mkdir: cannot create directory `/var/zookeeper': Permission denied
Starting zookeeper ... /home/sasuke/zookeeper-3.4.5/bin/zkServer.sh: line 113: /var/zookeeper/zookeeper_server.pid: No such file or directory
FAILED TO WRITE PID

I have Java installed and inside the zookeper directory there is a zookeeper.jar file that I think it's not running. Checking here on stackoverflow there was a guy that said he could run zookeeper after typing

ssh localhost

But when I try to do it I get this error

ssh: connect to host localhost port 22: Connection refused

Please help. I've being here trying to solve it for too long.

Getting started guide of zookeeper: http://zookeeper.apache.org/doc/r3.1.2/zookeeperStarted.html Previous case solved with the shh localhost Zookeeper: FAILED TO WRITE PID

UPDATE: The permissions for log are:

drwxr-xr-x 19 root root     4096 Oct 10 07:52 log

and for zookeeper:

drwxr-xr-x  2 zookeeper         zookeeper    4096 Mar 23  2012 zookeeper

Should I change any of these?

Brokerage answered 10/10, 2013 at 12:38 Comment(3)
Post permissions of /var/log/zookeeper ? It seems you do not have the required permissionsMarquetry
Please,see my answer on the same question: #11093136Location
try starting server with "start-foreground" to see full log of problemPogue
M
7

It seems you do not have the required permissions. The /var/log owner is is going to be root. Zookeeper stores the process id and snapshot of data in that directory. The process id of the spawned zookeeper server is stored in a file -zookeeper_server.pid (as of 3.3.6)

If you have root previleges, you could start zookeeper with sudo (root) previleges, it should work but definitely not recommended. Make sure you start zookeeper with the same(or higher) permissions as the owner of the directory.

Create a new directory in your home folder like /home/username/zookeeper-data. Let dataDir point to that directory and it should work.

Marquetry answered 10/10, 2013 at 13:10 Comment(2)
I have changed the dataDir as you said and it worked. But would I have any problems later when developing? I have changed the permissions of the log and zookeeper directory allowing the user and group to write on it but it didn't worked. By the way thanks for the asnwer.Brokerage
You could also give write permissions on dataDir (/var/log/zookeeper/ in your case) to the user running zookeeper... sudo chmod go+w /var/log/zookeeperMacegan
L
14

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

Location answered 30/3, 2015 at 13:5 Comment(1)
This answer should be higher. Especially if getting the error running as root.Greedy
M
7

It seems you do not have the required permissions. The /var/log owner is is going to be root. Zookeeper stores the process id and snapshot of data in that directory. The process id of the spawned zookeeper server is stored in a file -zookeeper_server.pid (as of 3.3.6)

If you have root previleges, you could start zookeeper with sudo (root) previleges, it should work but definitely not recommended. Make sure you start zookeeper with the same(or higher) permissions as the owner of the directory.

Create a new directory in your home folder like /home/username/zookeeper-data. Let dataDir point to that directory and it should work.

Marquetry answered 10/10, 2013 at 13:10 Comment(2)
I have changed the dataDir as you said and it worked. But would I have any problems later when developing? I have changed the permissions of the log and zookeeper directory allowing the user and group to write on it but it didn't worked. By the way thanks for the asnwer.Brokerage
You could also give write permissions on dataDir (/var/log/zookeeper/ in your case) to the user running zookeeper... sudo chmod go+w /var/log/zookeeperMacegan
I
5

The default zookeeper installation (tar extract) comes with the conf file named conf/zoo_sample.cfg while the same extract's bin/zkServer.sh expects the conf file to be called zoo.cfg thereby resulting in a "No such file or dir" and the "failed to write pid" error. So before running zkServer.sh to start or stop zookeeper instance, either:

  • rename the zoo_sample.cfg in the conf dir to zoo.cfg, or
  • give the name (and path) to the conf file (as suggested by Ilya Lapitan), or, of course
  • edit zkServer.sh ;-)
Incomprehensive answered 1/5, 2017 at 4:31 Comment(0)
A
1

When you create the Directory for dataDir make sure to use the -p option. This will allow subsequent directories to be created as required by the application placing files.

mkdir -p /var/log/zookeeperData Then set:

dataDir=/var/log/zookeeperData

Auer answered 17/3, 2016 at 3:19 Comment(0)
C
1

Seems there's all kinds of reasons this can happen. So many helpful answers here!

For me, I had improper line endings in my zoo.cfg file, and possibly invisible characters, so zookeeper was trying to create directories like /var/zookeeper? and /var/zookeeper\r. Reworking my zoo.cfg a bit fixed it for me, along with deleting zoo_sample.conf.

Cryometer answered 12/7, 2019 at 15:8 Comment(0)
B
0

This happens to me due to low disk space. cause zookeeper cant create pid file inside zookeeper data folder.

Bans answered 10/12, 2014 at 6:10 Comment(1)
How much storage required ? I'm facing same issue non of the solution working for me.Congratulation
T
0

I have faced the same issue while starting the zookeeper with this command:

hadoop@ubuntu:~/hadoop/zookeeper/zookeeper-3.4.8$ bin/zkServer.sh start

ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper.

It should have been written by the master. Check the value configured in zookeeper.znode.parent. There could be a mismatch with the one configured in the master.

But running the script as su rectified the issue:

hadoop@ubuntu:~/hadoop/zookeeper/zookeeper-3.4.8$ sudo bin/zkServer.sh start

ZooKeeper JMX enabled by default Using config: /home/hadoop/hadoop/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg Starting zookeeper ... STARTED

Turgot answered 17/6, 2016 at 12:44 Comment(0)
D
0

Go to /usr/local/etc/
You will find zookeeper directory
delete the directory
and restart the server - zkServer start

Dunlap answered 15/6, 2017 at 17:48 Comment(1)
take a look how to make a list sample list.Sectorial
L
0

Change the path give dataDir=/tmp/zookeeper. If it works then its clearly access issues

But its generally not advisable to use tmp directory.

Landry answered 30/8, 2017 at 17:59 Comment(0)
G
0

This seems to be an ownership issue; running the following solved this for me.

$ sudo chown -R $USER /var/lib/zookeeper

N.B. I've outlined my steps below which show the error I was getting (the same as the error in this SO question) and the attempt at trying the solution proposed by a user above, which advised to provide zoo.cfg as an argument.

13:01:29 ✔ ~  :: $ZK/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/Cellar/zookeeper/3.4.14/libexec/bin/../conf/zoo.cfg
Starting zookeeper ... /usr/local/Cellar/zookeeper/3.4.14/libexec/bin/zkServer.sh: line 149: /var/lib/zookeeper/zookeeper_server.pid: Permission denied
FAILED TO WRITE PID

13:01:32 ✘ ~  :: $ZK/bin/zkServer.sh start $ZK/conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: /usr/local/Cellar/zookeeper/3.4.14/libexec/conf/zoo.cfg
Starting zookeeper ... /usr/local/Cellar/zookeeper/3.4.14/libexec/bin/zkServer.sh: line 149: /var/lib/zookeeper/zookeeper_server.pid: Permission denied
FAILED TO WRITE PID
13:04:45 ✔ /var/lib  :: ls -la
total 0
drwxr-xr-x  4 root     wheel 128 Apr 19 18:55 .
drwxr-xr-x 27 root     wheel 864 Apr 19 18:55 ..
drwxr--r--  3 root     wheel  96 Mar 24 15:07 zookeeper
13:04:48 ✔ /var/lib  :: echo $USER
tallamjr
13:06:03 ✔ /var/lib  :: sudo chown -R $USER zookeeper
Password:
13:06:44 ✔ /var/lib  :: ls -la
total 0
drwxr-xr-x  4 root     wheel 128 Apr 19 18:55 .
drwxr-xr-x 27 root     wheel 864 Apr 19 18:55 ..
drwxr--r--  3 tallamjr wheel  96 Mar 24 15:07 zookeeper
13:06:48 ✔ ~  :: $ZK/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/Cellar/zookeeper/3.4.14/libexec/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

REF: - https://askubuntu.com/questions/6723/change-folder-permissions-and-ownership

Gonfalon answered 28/4, 2020 at 12:19 Comment(0)
N
0

For me this solution worked: I granted the read, write and execute permissions for everyone using the command $sudo chmod 777 foldername for the directory zookeeper by going inside the directory /var (/var/zookeeper).

After executing this command try running the zookeeper. It ran in my case

Notorious answered 12/11, 2022 at 18:19 Comment(0)
G
-1

try to use sudo -E bin/zkServer.sh start

Giesecke answered 1/6, 2017 at 9:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.