Zookeeper3.5及以上启动时8080端口被占用
Posted eternityz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Zookeeper3.5及以上启动时8080端口被占用相关的知识,希望对你有一定的参考价值。
今天闲来无事,学习Zookeeper,下载了Zookeeper的最新版本3.5。启动以后显示:
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.5.4-beta/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
以为启动成功,然后连接时报错,查看后台进程,没有Zookeeper进程。
查看zookeeper的日志文件:
2018-06-29 01:36:01,142 [myid:] - ERROR [main:ZooKeeperServerMain@79] - Unable to start AdminServer, exiting abnormally
org.apache.zookeeper.server.admin.AdminServer$AdminServerException: Problem starting AdminServer on address 0.0.0.0, port 8080 and command URL /commands
发现8080端口被占用,通过查阅Zookeeper3.5的官方文档,发现这是Zookeeper3.5的新特性:
The AdminServer
New in 3.5.0: The AdminServer is an embedded Jetty server that provides an HTTP interface to the four letter word commands. By default, the server is started on port 8080, and commands are issued by going to the URL "/commands/[command name]", e.g., http://localhost:8080/commands/stat. The command response is returned as JSON. Unlike the original protocol, commands are not restricted to four-letter names, and commands can have multiple names; for instance, "stmk" can also be referred to as "set_trace_mask". To view a list of all available commands, point a browser to the URL /commands (e.g., http://localhost:8080/commands). See the AdminServer configuration options for how to change the port and URLs.
这是Zookeeper AdminServer,默认使用8080端口,它的配置属性如下:
New in 3.5.0: The following options are used to configure the AdminServer.
admin.enableServer : (Java system property: zookeeper.admin.enableServer) Set to "false" to disable the AdminServer. By default the AdminServer is enabled.
admin.serverAddress : (Java system property: zookeeper.admin.serverAddress) The address the embedded Jetty server listens on. Defaults to 0.0.0.0.
admin.serverPort : (Java system property: zookeeper.admin.serverPort) The port the embedded Jetty server listens on. Defaults to 8080.
admin.idleTimeout : (Java system property: zookeeper.admin.idleTimeout) Set the maximum idle time in milliseconds that a connection can wait before sending or receiving data. Defaults to 30000 ms.
admin.commandURL : (Java system property: zookeeper.admin.commandURL) The URL for listing and issuing commands relative to the root URL. Defaults to "/commands".
我们可以修改在zoo.cfg中修改AdminServer的端口:
admin.serverPort=8888
保存后,再次启动,Zookeeper启动成功。
站在巨人肩膀上摘苹果
https://www.cnblogs.com/boboooo/p/9242088.html
https://zookeeper.apache.org/doc/r3.6.2/zookeeperAdmin.html
以上是关于Zookeeper3.5及以上启动时8080端口被占用的主要内容,如果未能解决你的问题,请参考以下文章
eclipse启动tomcat出现8080,8009,8005端口被占用的问题