1、单机连接zookeeper报错(3.5.9版本)
1、进入到zookeeper的解压目录apache-zookeeper-3.5.9-bin,启动zk,执行命令
./bin/zkServer.sh start conf/zoo.cfg
2、启动成功后,远程连接客户端,执行命令报错如下
./bin/zkCli.sh -server IP地址:2181
2021-08-21 00:09:19,780 [myid:47.100.15.91:2181] - INFO [main-SendThread(47.100.15.91:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server www/47.100.15.91:2181. Will not attempt to authenticate using SASL (unknown error)
2021-08-21 00:09:19,782 [myid:47.100.15.91:2181] - INFO [main-SendThread(47.100.15.91:2181):ClientCnxn$SendThread@1244] - Socket error occurred: www/47.100.15.91:2181: Connection refused
2021-08-21 00:09:20,883 [myid:47.100.15.91:2181] - INFO [main-SendThread(47.100.15.91:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server www/47.100.15.91:2181. Will not attempt to authenticate using SASL (unknown error)
2021-08-21 00:09:20,886 [myid:47.100.15.91:2181] - INFO [main-SendThread(47.100.15.91:2181):ClientCnxn$SendThread@1244] - Socket error occurred: www/47.100.15.91:2181: Connection refused
解决办法
1、进入服务器的安装目录
/usr/local/software/zookeeper/apache-zookeeper-3.5.9-bin/logs
发现如下一段报错:
2021-08-21 00:43:59,241 [myid:] - ERROR [main:ZooKeeperServerMain@80] - 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
at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:111)
at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:139)
at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:107)
at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:65)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:128)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:82)
Caused by: java.io.IOException: Failed to bind to /0.0.0.0:8080
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:349)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:310)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:234)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
at org.eclipse.jetty.server.Server.doStart(Server.java:401)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:107)
... 5 more
大概意思是说8080端口号被占用了。
1、修改在zoo.cfg中添加如下端口:
admin.serverPort=8081
2、保存后,执行命令关闭zk。此步骤可省略,但是,为了防止意外情况,执行下比较好。
./bin/zkServer.sh stop conf/zoo.cfg
3、然后再次启动zk
./bin/zkServer.sh start conf/zoo.cfg
4、最后再开始远程连接客户端
./bin/zkCli.sh -server IP地址:2181
注意:如下截图是官网介绍,zk 3.5.0版本后默认的版本号修改成了8080,所以与自己服务的端口号冲突了。
少年,今天也要努力呀!
|