一. zk admin启动默认端口是8080,如果有其他服务在用8080,那启动时就报错了,端口已被绑定
2019-06-1610:40:29,724 [myid:] -ERROR [main:ZooKeeperServerMain ] -UnabletostartAdminServer, exitingabnormallyorg.apache.zookeeper.server.admin.AdminServer$AdminServerException: ProblemstartingAdminServeronaddress0.0.0.0, port8080andcommandURL/commandsatorg.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:107) atorg.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:138) atorg.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:106) atorg.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:64) atorg.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:128) atorg.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:82) Causedby: java.io.IOException: Failedtobindto/0.0.0.0:8080atorg.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:346) atorg.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308) atorg.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80) atorg.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236) atorg.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) atorg.eclipse.jetty.server.Server.doStart(Server.java:396) atorg.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) atorg.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:103) ... 5moreCausedby: java.net.BindException: 地址已在使用atsun.nio.ch.Net.bind0(NativeMethod) atsun.nio.ch.Net.bind(Net.java:433) atsun.nio.ch.Net.bind(Net.java:425) atsun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) atsun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) atorg.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:342) ... 12moreUnabletostartAdminServer, exitingabnormally
二. 这种情况下就去zoo.cfg文件中修改一下端口号,只要没有被其他程序占用的端口都可以
admin.serverPort=9099
'
三.对其他端口做一下补充
1、zookeeper有三个端口(可以修改)
1、2181 2、3888 3、2888
2、3个端口的作用
1、2181:对cline端提供服务 2、3888:选举leader使用 3、2888:集群内机器通讯使用(Leader监听此端口)
3、部署时注意
1、单机单实例,只要端口不被占用即可 2、单机伪集群(单机,部署多个实例),三个端口必须修改为组组不一样 如:myid1 : 2181,3888,2888 myid2 : 2182,3788,2788 myid3 : 2183,3688,2688 3、集群(一台机器部署一个实例)
4、集群为大于等于3个基数,如 3、5、7....,不宜太多,集群机器多了选举和数据同步耗时时长长,不稳定。目前觉得,三台选举+N台observe很不错。