• 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

  • 相关阅读:
    php 计算代码执行时间
    高级php面试题
    MongoDB 或者 redis 可以替代 memcached 吗?
    mysql中myisam,innodb和memory三个存储引擎的区别
    C#发送邮件代码
    使用bootstrap table时不能显示筛选列和分页每页显示的行数
    vue2中,字符串里如何拼接绑定对象
    压缩图片方法
    jquery的ajax方法,在返回中,find方法不起作用
    vue2中,在google浏览器中正常,在ie11中不解析
  • 原文地址:https://www.cnblogs.com/eternityz/p/14113740.html
Copyright © 2020-2023  润新知