【问题标题】:Setting up a single Zookeeper instance and the binding fails设置单个 Zookeeper 实例并且绑定失败
【发布时间】:2014-09-10 01:41:09
【问题描述】:

我正在尝试使用以下配置设置单个 zookeeper 实例,但是启动日志表明 zookeeper 在尝试绑定端口 2181 时正在停止。请有人在这里告诉我这个问题。谢谢。

启动日志;

    2014-07-18 16:00:48,976 [myid:] - INFO  [main:QuorumPeerConfig@103] - Reading configuration from: /opt/zookeeper/bin/../conf/zoo.cfg
2014-07-18 16:00:48,980 [myid:] - ERROR [main:QuorumPeerConfig@289] - Invalid configuration, only one server specified (ignoring)
2014-07-18 16:00:48,982 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2014-07-18 16:00:48,982 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2014-07-18 16:00:48,983 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2014-07-18 16:00:48,983 [myid:] - WARN  [main:QuorumPeerMain@113] - Either no config or no quorum defined in config, running  in standalone mode
2014-07-18 16:00:48,997 [myid:] - INFO  [main:QuorumPeerConfig@103] - Reading configuration from: /opt/zookeeper/bin/../conf/zoo.cfg
2014-07-18 16:00:48,998 [myid:] - **ERROR** [main:QuorumPeerConfig@289] - Invalid configuration, only one server specified (ignoring)
2014-07-18 16:00:48,998 [myid:] - INFO  [main:ZooKeeperServerMain@95] - Starting server
2014-07-18 16:00:49,007 [myid:] - INFO  [main:Environment@100] - Server environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2014-07-18 16:00:49,007 [myid:] - INFO  [main:Environment@100] - Server environment:host.name=<NA>
2014-07-18 16:00:49,007 [myid:] - INFO  [main:Environment@100] - Server environment:java.version=1.7.0_51
2014-07-18 16:00:49,007 [myid:] - INFO  [main:Environment@100] - Server environment:java.vendor=Oracle Corporation
2014-07-18 16:00:49,007 [myid:] - INFO  [main:Environment@100] - Server environment:java.home=/usr/java/jdk1.7.0_51/jre
2014-07-18 16:00:49,007 [myid:] - INFO  [main:Environment@100] - Server environment:java.class.path=/opt/zookeeper/bin/../build/classes:/opt/zookeeper/bin/../build/lib/*.jar:/opt/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/opt/zookeeper/bin/../lib/log4j-1.2.16.jar:/opt/zookeeper/bin/../lib/jline-0.9.94.jar:/opt/zookeeper/bin/../zookeeper-3.4.6.jar:/opt/zookeeper/bin/../src/java/lib/*.jar:/opt/zookeeper/bin/../conf:
2014-07-18 16:00:49,008 [myid:] - INFO  [main:Environment@100] - Server environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2014-07-18 16:00:49,010 [myid:] - INFO  [main:Environment@100] - Server environment:java.io.tmpdir=/tmp
2014-07-18 16:00:49,010 [myid:] - INFO  [main:Environment@100] - Server environment:java.compiler=<NA>
2014-07-18 16:00:49,010 [myid:] - INFO  [main:Environment@100] - Server environment:os.name=Linux
2014-07-18 16:00:49,010 [myid:] - INFO  [main:Environment@100] - Server environment:os.arch=amd64
2014-07-18 16:00:49,011 [myid:] - INFO  [main:Environment@100] - Server environment:os.version=3.10.0-123.4.2.el7.x86_64
2014-07-18 16:00:49,011 [myid:] - INFO  [main:Environment@100] - Server environment:user.name=root
2014-07-18 16:00:49,011 [myid:] - INFO  [main:Environment@100] - Server environment:user.home=/root
2014-07-18 16:00:49,011 [myid:] - INFO  [main:Environment@100] - Server environment:user.dir=/opt/zookeeper/bin
2014-07-18 16:00:49,018 [myid:] - INFO  [main:ZooKeeperServer@755] - tickTime set to 2000
2014-07-18 16:00:49,018 [myid:] - INFO  [main:ZooKeeperServer@764] - minSessionTimeout set to -1
2014-07-18 16:00:49,018 [myid:] - INFO  [main:ZooKeeperServer@773] - maxSessionTimeout set to -1
2014-07-18 16:00:49,029 [myid:] - INFO  [main:NIOServerCnxnFactory@94] - binding to port 0.0.0.0/0.0.0.0:2181

Zookeeper 配置文件。

    # 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/zookeeper/data
# the port at which the clients will connect
clientPort=2181
#log directory.
dataLogDir=/opt/zookeeper/log

server.1=localhost:2888:3888

# 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

【问题讨论】:

  • 当我尝试在同一台机器上配置 3 节点 ZK 集群时遇到了同样的问题。我为导致此问题的所有三个实例配置了相同的客户端端口。然后我只尝试了一个节点集群,仍然看到同样的问题。显然,有一个在端口 2181 上侦听的过时进程导致了此问题。你能检查一下你是否也是这种情况?
  • 这个问题有什么解决办法吗?

标签: apache-zookeeper solrcloud


【解决方案1】:

如果您正在为测试/开发运行独立的 Zookeeper,请在 zoo.cfg 中评论此行:#server.1=localhost:2888:3888

然后,而不是:

错误 [main:QuorumPeerConfig@289] - 无效配置,仅指定了一台服务器(忽略)

你会看到:

WARN [main:QuorumPeerMain@125] - 没有配置或没有仲裁 在配置中定义,以独立模式运行

Reference:

server.1=zoo1:2888:3888
server.2=zoo2:2888:3888
server.3=zoo3:2888:3888

表单 server.X 的条目列出了组成 动物园管理员服务。当服务器启动时,它知道它是哪个服务器 是通过在数据目录中查找文件myid。该文件有 包含服务器编号,以 ASCII 格式。

最后,请注意每个服务器名称后面的两个端口号:“2888”和 “3888”。对等点使用前一个端口连接到其他对等点。这样一个 连接是必要的,以便对等方可以通信,例如, 同意更新的顺序。更具体地说,一个 ZooKeeper 服务器 使用此端口将追随者连接到领导者。当一个新的领导 出现时,跟随者使用此命令打开到领导者的 TCP 连接 港口。因为默认的leader选举也使用TCP,我们目前 需要另一个端口进行领导者选举。这是第二个端口 服务器条目。

【讨论】:

    【解决方案2】:

    在 CentOS 上,您可以编辑以下文件并添加 _JAVA_OPTIONS 行

    sudo vim /etc/default/zookeeper
    

    export _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true"

    然后重启进程

    sudo service zookeeper-server restart
    

    【讨论】:

      【解决方案3】:

      尝试将此添加到 zoo.cfg quorumListenOnAllIPs=true

      【讨论】:

      • 这如何解决问题?请详细说明。
      【解决方案4】:

      您是否在 Windows 64 位上运行 zookeeper。我遇到了同样的问题,但后来发现不支持 Win64。查看 Zookeeper 链接http://zookeeper.apache.org/doc/r3.4.5/zookeeperAdmin.html#sc_supportedPlatforms

      【讨论】:

        【解决方案5】:

        我建议您从配置文件中删除以下行

        server.1=localhost:2888:3888
        

        然后重启服务器。

        【讨论】:

        • 有什么具体的理由来删除它吗?就我而言,我有server.0=localhost:2888:3888
        【解决方案6】:

        我要提一下,当您收到以下日志消息时,这意味着服务器实际上已启动。

        INFO  [main:NIOServerCnxnFactory@94] - binding to port 0.0.0.0/0.0.0.0:2181
        

        如果您有一个如下的 Zookeeper 实例,您看到的错误消息实际上是警告而不是错误。

        2014-07-18 16:00:48,980 [myid:] - ERROR [main:QuorumPeerConfig@289] - Invalid configuration, only one server specified (ignoring)
        

        【讨论】:

          猜你喜欢
          • 2017-06-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-03-22
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多