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了
更多推荐
已为社区贡献2条内容
所有评论(0)