【README】在 192.168.163.201 机器上 启动zk ,并查看zk 这台; 即 集群只有2台机器, 201 202
--ZOO.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/opt/module/zookeeper-3.4.10/zkdata
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
# cluster conf
server.1=192.168.163.201:2888:3888
server.2=192.168.163.202:2888:3888
【1】报错现场
在201上启动zk,如下:
[root@localhost zookeeper-3.4.10]# ./bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost zookeeper-3.4.10]#
[root@localhost zookeeper-3.4.10]#
[root@localhost zookeeper-3.4.10]# ./bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
【2】解决方法
第一步: 查看 zookeeper.out 输出日志,如下:
Cannot open channel to 2 at election address /192.168.163.202:3888
第2步: 很明显,意识到 202 这台机器的 zk没有启动,
启动 202, 如下:
经过查看 status, 202 是leader
第3步, 我们查看201 的zk 状态(这里无需再次启动,因为201已经启动了),201是个 follower
bingo
小结:解决该问题的方法是在 查看zk启动的日志文件, zookeeper.out 文件;