【问题标题】:Can't get ZooKeeper cluster to work, election never happens无法让 ZooKeeper 集群工作,选举永远不会发生
【发布时间】:2012-12-01 13:46:03
【问题描述】:

这是我第一次尝试 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 上运行,但仍然遇到同样的问题。

【问题讨论】:

    标签: java linux configuration hadoop apache-zookeeper


    【解决方案1】:

    问题是我有 偶数 个节点,您需要 奇数 个节点才能进行选举(显然)。应该更新文档以涵盖这一点,因为基本示例显示正好配置了 2 个服务器。

    【讨论】:

    • 你应该可以用偶数个节点进行选举。如果有 2 个节点,则两个节点都必须启动才能完成选举。
    • 如日志所示,两个节点都已启动并运行,选举从未发生。一旦我加入了第三个节点,选举确实发生了,我的集群现在运行良好。
    • 如果你杀死当前的leader,其他节点是否同意新的leader?
    【解决方案2】:

    你的配置无效,特别是

    server.1=redis1:2888:3888
    server.2=redis1:2888:3888
    

    如果您在同一主机上运行两个实例,则需要为每个实例设置不同的端口号,最好是类似

    server.1=localhost:3181:4181
    server.2=localhost:3182:4182
    

    请注意,您应该拥有相同的服务器。# 配置两个服务器的配置文件。

    另一种选择是只使用像 zkconf 这样的东西来为你生成所有这些:http://bit.ly/aQP9Yi

    【讨论】:

    • 只是对真实主机名的一个不好的改变,两个主机名在真实的配置文件中是不同的。
    猜你喜欢
    • 2013-05-08
    • 2018-08-04
    • 1970-01-01
    • 2018-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多