我正在尝试使用三个节点在完全分布式模式下部署zookeeper集合。启动服务器后,jps下没有任何条目。在给出“zkServer.sh status”时,输出为:
JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Error contacting service. It is probably not running
在给出命令“zkCli.sh -server zks1:2181”时:
Connecting to zks1:2181
2015-05-24 23:02:24,602 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2015-05-24 23:02:24,605 [myid:] - INFO [main:Environment@100] - Client environment:host.name=mtech2-OptiPlex-7010
2015-05-24 23:02:24,606 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.7.0_79
2015-05-24 23:02:24,607 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2015-05-24 23:02:24,607 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre
2015-05-24 23:02:24,608 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/usr/local/zookeeper/bin/../build/classes:/usr/local/zookeeper/bin/../build/lib/*.jar:/usr/local/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/bin/../src/java/lib/*.jar:/usr/local/zookeeper/bin/../conf:
2015-05-24 23:02:24,608 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
2015-05-24 23:02:24,608 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2015-05-24 23:02:24,608 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA>
2015-05-24 23:02:24,608 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2015-05-24 23:02:24,608 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2015-05-24 23:02:24,608 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.75
2015-05-24 23:02:24,608 [myid:] - INFO [main:Environment@100] - Client environment:user.name=hduser
2015-05-24 23:02:24,608 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/home/hduser
2015-05-24 23:02:24,608 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/usr/local/zookeeper
2015-05-24 23:02:24,609 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=zks1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@634fd55e
Welcome to ZooKeeper!
2015-05-24 23:02:24,741 [myid:] - INFO [main-SendThread(zks1:2181):ClientCnxn$SendThread@975] - Opening socket connection to server zks1/192.168.4.60:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2015-05-24 23:02:24,755 [myid:] - WARN [main-SendThread(zks1: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: zks1:2181(CONNECTING) 0]
所有节点的/ etc / hosts文件如下:
192.168.4.60 zks1
192.168.4.61 zks2
192.168.4.66 zks3
zoo.cfg文件如下:
dataDir=/var/zookeeper/
clientPort=2181
initLimit=5
syncLimit=2
server.server1=zks1:2888:3888
server.server2=zks2:2888:3888
server.server3=zks3:2888:3888
我在所有节点上创建了目录/ var / zookeeper,并将所有权更改为hduser:hadoop。
导出的环境变量是:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export ZK_HOME=/usr/local/zookeeper
export PATH=$PATH:$ZK_HOME/bin
数据目录(/ var / zookeeper /)中的myid分别是server1,server2和server3。
请指出问题。
答案 0 :(得分:1)
用server.1替换server.server1并相应地修改每个节点的myid文件就可以了。
答案 1 :(得分:0)
我也遇到了同样的问题。在我的情况下,问题是关于zookeeper位置配置对于每个节点都不相同,因此zookeeper无法提供Quorum,并且提到的节点不能成为集群的一部分。
请确保每个节点的服务器定义相同。
server.server1=zks1:2888:3888
server.server2=zks2:2888:3888
server.server3=zks3:2888:3888
答案 2 :(得分:0)
在第一个/顶部堆栈跟踪中,myid值存在问题。
&#34; 2015-05-24 23:02:24,602 [myid:] - INFO [main:Environment @ 100]&#34; 在myid的上面一行:*这里应该是一个整数/长。所以你可能没有在dataDir文件夹中创建你的myid文件,或者你没有输入任何long / int值。还有一件事myid应该是类型文件。
在第二个问题中,在server.server1 = machine:port1:port2中,因为server1不长,所以org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties()方法将抛出NumberFormatException。 所以server.1应该是一个数字,在整体中是唯一的,同样应该在myid文件中。