这是我第一次尝试 ZooKeeper,虽然我可以轻松地将其设置为在单台机器上运行,但让它在两台机器的集群中运行根本行不通。我认为我的配置可能有问题,但看起来我找不到它。
Here are the logs for server 1
Here are the logs for server 2
我的两台服务器的配置如下:
# 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.
dataDir=/var/lib/zookeeper
# the port at which the clients will connect
clientPort=2181
server.1=redis1:2888:3888
server.2=redis2:2888:3888
对可能出现的问题有什么想法吗?
我在运行 OpenJDK 7 的 Ubuntu Linux 机器上运行 ZooKeeper 3.4.5。尝试在 OpenJDK 6 上运行,但仍然遇到同样的问题。
最佳答案
问题是我有偶数个节点,您需要奇数个节点才能进行选举(显然)。应该更新文档以涵盖这一点,因为基本示例仅显示了 2 个正在配置的服务器。
关于java - 无法让 ZooKeeper 集群工作,选举永远不会发生,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13863756/