占用 端口_新版Zookeeper v3.5启动后为什么占用8080端口,如何修改端口?

Zookeeper 3.5版本及以上默认的AdminServer占用8080端口,可通过禁用或修改配置文件来改变端口。本文介绍了如何在zoo.cfg中设置admin.enableServer=false或修改admin.serverPort来调整端口,以及如何验证更改并访问新的AdminServer地址。
摘要由CSDN通过智能技术生成

Zookeeper 3.5+新增内容

49d86846d009e715b5051aa28afe577d.png

AdminServer是一个内置的Jetty服务。默认的服务启动在8080端口。例如访问,http://localhost:8080/commands/stat,命令响应以JSON的格式返回。

为了查看所有可用命令的列表,可以访问URL /commands。

启动Zookeeper Server,查看输出信息:

zkServer.sh start-foreground

其中输出信息有如下一段文本,显示AdminServer占用了8080端口。

......

2019-06-07 00:37:48,644 [myid:] - INFO [main:JettyAdminServer@112] - Started AdminServer on address 0.0.0.0, port 8080 and command URL /commands

......

如果不想占用8080端口,如果修改配置文件来实现修改端口呢?

如下是来自Zookeeper官方文档的内容,讲述了AdminServer的配置参数。

http://zookeeper.apache.org/doc/current/zookeeperAdmin.html

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".

通过查看Zookeeper的官方文档,发现有几种解决途径。

1. 禁用AdminServer

在zoo.cfg中增加配置 admin.enableServer=false

或者在启动脚本中增加-Dzookeeper.admin.enableServer=false

2. 修改AdminServer端口号

修改方法的方法有两种:

一种是在启动脚本中增加 -Dzookeeper.admin.serverPort=没有被占用的端口号;

另一种是在zoo.cfg中增加admin.serverPort=没有被占用的端口号,如8090端口号。

vim /opt/apache-zookeeper/conf/zoo.cfg

6cf29895ad6aac2fffd1516f367d2eba.png

下面采用方案2,修改AdminServer端口号为8090。

再次启动Zookeeper Server,查看输出信息:

zkServer.sh start-foreground

5fcfa9746a45165378c353e8ca9fdbcf.png

检查Java进程信息,以及8090 端口。

ee1e9a42c3788d6ed14719e7d64308f1.png

访问Zookeeper AdminServer

http://192.168.56.103:8090/commands

46c5f14cc346b73e8732e8b4c5c17dfa.png

如下是Zookeeper AdminServer的配置参数说明:

cc587a83b5606acbf5d05d263c7d1a53.png

这样,Zookeeper AdminServer占用的8080 端口就释放出来了。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值