首页 > 代码库 > zookeeper在单机上伪集群测试时,出现Unable to start AdminServer, exiting abnormally
zookeeper在单机上伪集群测试时,出现Unable to start AdminServer, exiting abnormally
zookeeper在单机上伪集群测试时,出现Unable to start AdminServer, exiting abnormally
出现该问题的原因大家都知道因为启动完一个zookeeper server后,默认的zkServer.cmd中,没有将对应的不启动AdminServer屏蔽。
AdminServerFactory.java中代码如下
public static AdminServer createAdminServer() { if (!"false".equals(System.getProperty("zookeeper.admin.enableServer"))) { try { Class<?> jettyAdminServerC = Class.forName("org.apache.zookeeper.server.admin.JettyAdminServer"); Object adminServer = jettyAdminServerC.getConstructor().newInstance(); return (AdminServer) adminServer; } catch (ClassNotFoundException e) { LOG.warn("Unable to start JettyAdminServer", e); } catch (InstantiationException e) { LOG.warn("Unable to start JettyAdminServer", e); } catch (IllegalAccessException e) { LOG.warn("Unable to start JettyAdminServer", e); } catch (InvocationTargetException e) { LOG.warn("Unable to start JettyAdminServer", e); } catch (NoSuchMethodException e) { LOG.warn("Unable to start JettyAdminServer", e); } catch (NoClassDefFoundError e) { LOG.warn("Unable to load jetty, not starting JettyAdminServer", e); } } return new DummyAdminServer(); }
因为第一个启动的Zookeeper server已经把8080端口给占用了
根据创建JettyAdminServer中代码如下:
public JettyAdminServer() throws AdminServerException { this(Integer.getInteger("zookeeper.admin.serverPort", DEFAULT_PORT), System.getProperty("zookeeper.admin.commandURL", DEFAULT_COMMAND_URL)); }
所以可以在zkServer.cmd中的最后一个call参数中,增加"-Dzookeeper.admin.enableServer=false"
或者
"-Dzookeeper.admin.serverPort=你的端口号"
更改端口号后再进行启动,这样在单机环境下配置集群测试就OK了
zookeeper在单机上伪集群测试时,出现Unable to start AdminServer, exiting abnormally
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。