关于ZooKeeper的配置部署问题总结。
问题1:
执行: zkServer.sh start 之后,执行:zkServer.sh status
出现:
JMX enabled by default
Using config: /opt/zk/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
解决问题1:
执行: zkServer.sh start-foreground
进行调试,找具体原因。
问题2:
调试过程中出现如下错误,
Caused by: java.lang.IllegalArgumentException: serverid #server1 is not a number
原因:
myid文件中内容有错,需要修改。
解决问题2:
如果配置文件如下:
1 # The number of milliseconds of each tick
2 tickTime=2000
3 # The number of ticks that the initial
4 # synchronization phase can take
5 initLimit=10
6 # The number of ticks that can pass between
7 # sending a request and getting an acknowledgement
8 syncLimit=5
9 # the directory where the snapshot is stored.
10 # do not use /tmp for storage, /tmp here is just
11 # example sakes.
12 #dataDir=/tmp/zookeeper/
13 dataDir=/opt/zookeeper/zkdata
14 dataLogDir=/opt/zookeeper/zkdatalog
15 # the port at which the clients will connect
16 clientPort=2181
17 #add 3 servers
18 server.1=172.16.18.105:2888:3888
19 server.2=172.16.18.106:2888:3888
20 server.3=172.16.18.107:2888:3888
21
22 # the maximum number of client connections.
23 # increase this if you need to handle more clients
24 #maxClientCnxns=60
25 #
26 # Be sure to read the maintenance section of the
27 # administrator guide before turning on autopurge.
28 #
29 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
30 #
31 # The number of snapshots to retain in dataDir
32 #autopurge.snapRetainCount=3
33 # Purge task interval in hours
34 # Set to "0" to disable auto purge feature
35 #autopurge.purgeInterval=1
那么第一个server 的myid文件只有 纯数字 “1”(注意,没有双引号,没有空格,只有一个1就可以)
其他两个server myid 文件 分别是 “2” 和 “3”
参考:
https://stackoverflow.com/questions/29909191/zookeeper-it-is-probably-not-running/29950279#29950279
https://stackoverflow.com/questions/11498507/zookeeper-three-nodes-and-nothing-but-errors