我正在尝试在ec2上设置zookeeper两个实例。给定here和here。
我试图运行zookeeper失败并出现错误:
命令:bin/zkCli.sh -server localhost:2181
> 2015-03-15 00:22:35,644 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@3ff0efca
Welcome to ZooKeeper!
2015-03-15 00:22:35,671 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2015-03-15 00:22:35,677 [myid:] - WARN [main-SendThread(localhost:2181):ClientCnxn$SendThread@1102] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
[zk: localhost:2181(CONNECTING) 0] 2015-03-15 00:22:36,796 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2015-03-15 00:22:36,797 [myid:] - WARN [main-SendThread(localhost:2181):ClientCnxn$SendThread@1102] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
zoo.cfg as bellow
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/var/lib/zookeeper
clientPort=2181
server.1=localhost:2888:3888
server.2=<My ec2 private IPs>:2889:3889
我也在两个ec2实例上创建了myId文件 - /var/lib/zookeeper/myid
我还尝试编辑/ ect / hosts文件,但仍面临同样的问题。 我如何用1命令启动两个zookeeper实例?
注意:如果我尝试使用bin/zkCli.sh start
命令,服务器就会成功启动。
提前致谢!
答案 0 :(得分:2)
查看zk log zookeeper.out,如果有连接限制错误,请将以下内容配置为zoo.cfg。
# the maximum number of client connections.
# increase this if you need to handle more clients
maxClientCnxns=60
答案 1 :(得分:2)
这是一个暂时的错误,一段时间之后,它消失了: -
这是我的zoo.conf文件:: -
Dir=../data
clientPort=2181
tickTime=2000
initLimit=5
答案 2 :(得分:0)
当我忘记run% ZOOKEEPER_HOME% \ bin \ zkserver.cmd
通过运行,该问题已解决。
答案 3 :(得分:0)
在server.properties上更正此属性
默认为本地主机,将其更改为与zookeeper服务器的starup IP和端口相匹配
zookeeper.connect = 0.0.0.0:2181