原创

Zookeeper启动异常FAILED TO WRITE PID

1.权限问题Permission denied...FAILED TO WRITE PID

如果提示Permission denied...那就是权限问题很好解决直接chmod -R 777 /配置文件中的dataDir目录

2.非权限问题报FAILED TO WRITE PID异常

ZBMAC-C02WD12BH:bin lishihao$ sh ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /Users/lishihao/Desktop/JDTool/apache-zookeeper-3.5.5-bin/bin/../conf/zoo.cfg
mkdir: illegal option -- e
usage: mkdir [-pv] [-m mode] directory ...
-n Starting zookeeper ...
./zkServer.sh: line 169: -e /tmp/zookeeper/zookeeper_server.pid: No such file or directory
FAILED TO WRITE PID

这应该就是启动姿势不对了,到zk的根目录 执行启动命令 ./bin/zkServer.sh start conf/zoo.cfg

ZBMAC-C02WD12BH:apache-zookeeper-3.5.5-bin lishihao$ ./bin/zkServer.sh start conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: conf/zoo.cfg
Starting zookeeper ... STARTED
ZBMAC-C02WD12BH:apache-zookeeper-3.5.5-bin lishihao$ lsof -i:2181
COMMAND   PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
java    21877 lishihao   58u  IPv6 0x35e96b026bea04cb      0t0  TCP *:eforward (LISTEN)

3.没有异常显示启动了,但是实际没启动

  1. 最新的几个版本 zk都会启动一个admin Service 要监听8080端口
  2. 如果你本地已经占用了8080自然起不来,但是不会再命令终端看到异常
  3. 到zk日志里面可以看到

解决方法

在zk的配置文件 zoo.cfg中添加admin.serverPort=未占用的端口号
停用这个服务,在启动脚本中增加"-Dzookeeper.admin.enableServer=false"

4.zk自带的admin service介绍

AdminServer configuration
New in 3.5.0: The following options are used to configure the AdminServer.
admin.enableServer : (Java system property: zookeeper.admin.enableServer) Set to "false" to disable the AdminServer. By default the AdminServer is enabled.
admin.serverAddress : (Java system property: zookeeper.admin.serverAddress) The address the embedded Jetty server listens on. Defaults to 0.0.0.0.
admin.serverPort : (Java system property: zookeeper.admin.serverPort) The port the embedded Jetty server listens on. Defaults to 8080.
admin.idleTimeout : (Java system property: zookeeper.admin.idleTimeout) Set the maximum idle time in milliseconds that a connection can wait before sending or receiving data. Defaults to 30000 ms.
admin.commandURL : (Java system property: zookeeper.admin.commandURL) The URL for listing and issuing commands relative to the root URL. Defaults to "/commands".
  1. 上面是相关配置
  2. 默认地址的uri为/commands
  3. 建议直接admin.enableServer=false
正文到此结束
本文目录