设置单个Zookeeper示例,绑定失败

jgzswidk  于 2022-12-09  发布在  Apache
关注(0)|答案(7)|浏览(189)

我正在尝试使用下面的配置设置一个单独的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
envsm3lx

envsm3lx1#

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

server.1=localhost:2888:3888

然后重新启动服务器。

hi3rlvi2

hi3rlvi22#

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

sudo vim /etc/default/zookeeper

导出_JAVA_OPTIONS="-Djava.net.preferIPv4堆栈=真”

然后重新启动过程

sudo service zookeeper-server restart
3vpjnl9f

3vpjnl9f3#

如果您正在为测试/开发运行一个独立的zookeeper,请在zoo.cfg中注解此行:#server.1=localhost:2888:3888
然后,改为:

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

您将看到:
警告[main:QuorumPeerMain@125] -配置中未定义配置或仲裁,正在以独立模式运行
Reference
服务器.1 =缩放1:2888:3888
服务器.2 =缩放2:2888:3888
服务器.3 =缩放3:2888:3888
server.X格式的条目列出了组成ZooKeeper服务的服务器。当服务器启动时,它通过在数据目录中查找文件myid来知道它是哪个服务器。该文件包含ASCII格式的服务器编号。
最后,请注意每个服务器名称后面的两个端口号:“2888”和“3888”。对等体使用前一个端口连接到其他对等体。这样的连接是必要的,以便对等体可以通信,例如,同意更新的顺序。更具体地说,ZooKeeper服务器使用此端口将跟随者连接到领导者。当新领导者出现时,跟随者使用此端口打开到领导者的TCP连接。2因为默认领导者选举也使用TCP,我们当前需要另一个端口用于领导者选举。3这是服务器条目中的第二个端口。

gblwokeq

gblwokeq4#

我的配置文件(zoo.cfg)在单一模式下是在这里,它的工作正常:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=5
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=2
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/usr/local/zookeeper/data
# the port at which the clients will connect
clientPort=2181
admin.serverPort=8081
4lw.commands.whitelist=*
# 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

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
k0pti3hp

k0pti3hp5#

我想指出的是,当您收到以下日志消息时,这意味着服务器实际上已经启动。

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)
yftpprvb

yftpprvb6#

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

plicqrtu

plicqrtu7#

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

相关问题