Amazon ec2 ec2上的zookeeper无法运行

Amazon ec2 ec2上的zookeeper无法运行,amazon-ec2,apache-zookeeper,Amazon Ec2,Apache Zookeeper,各位,, 我最近在ec2上设置了zookeeper 我遵循了ec2的手册,但它仍然显示错误: root@ip-172-31-15-65:/home/yjiang/zookeeper-3.4.5/bin# ./zkServer.sh status JMX enabled by default Using config: /home/yjiang/zookeeper-3.4.5/bin/../conf/zoo.cfg Error contacting service. It is probably

各位,, 我最近在ec2上设置了zookeeper 我遵循了ec2的手册,但它仍然显示错误:

root@ip-172-31-15-65:/home/yjiang/zookeeper-3.4.5/bin# ./zkServer.sh status
JMX enabled by default
Using config: /home/yjiang/zookeeper-3.4.5/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
但该实例正在后台运行。 然后,当我使用./zkCli.sh–server-server-ip:2181命令时,它显示如下

root@ip-172-31-15-68:/home/yjiang/zookeeper-3.4.5/bin# ./zkCli.sh -server ec2-54-213-208-202.us-west-2.compute.amazonaws.com:2181
Connecting to ec2-54-213-208-202.us-west-2.compute.amazonaws.com:2181
2013-08-31 06:53:05,568 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
2013-08-31 06:53:05,579 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=ip-172-31-15-68.us-west-2.compute.internal
2013-08-31 06:53:05,580 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.7.0_25
2013-08-31 06:53:05,580 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2013-08-31 06:53:05,581 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-7-oracle/jre
2013-08-31 06:53:05,582 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/home/yjiang/zookeeper-3.4.5/bin/../build/classes:/home/yjiang/zookeeper-3.4.5/bin/../build/lib/*.jar:/home/yjiang/zookeeper-3.4.5/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/yjiang/zookeeper-3.4.5/bin/../lib/slf4j-api-1.6.1.jar:/home/yjiang/zookeeper-3.4.5/bin/../lib/netty-3.2.2.Final.jar:/home/yjiang/zookeeper-3.4.5/bin/../lib/log4j-1.2.15.jar:/home/yjiang/zookeeper-3.4.5/bin/../lib/jline-0.9.94.jar:/home/yjiang/zookeeper-3.4.5/bin/../zookeeper-3.4.5.jar:/home/yjiang/zookeeper-3.4.5/bin/../src/java/lib/*.jar:/home/yjiang/zookeeper-3.4.5/bin/../conf:/usr/lib/jvm/java-7-oracle/lib
2013-08-31 06:53:05,583 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2013-08-31 06:53:05,584 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2013-08-31 06:53:05,584 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
2013-08-31 06:53:05,585 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2013-08-31 06:53:05,586 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2013-08-31 06:53:05,586 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.2.0-40-virtual
2013-08-31 06:53:05,587 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
2013-08-31 06:53:05,588 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
2013-08-31 06:53:05,588 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/home/yjiang/zookeeper-3.4.5/bin
2013-08-31 06:53:05,592 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=ec2-54-213-208-202.us-west-2.compute.amazonaws.com:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@3b8a9e64
Welcome to ZooKeeper!
2013-08-31 06:53:05,695 [myid:] - INFO  [main-SendThread(ec2-54-213-208-202.us-west-2.compute.amazonaws.com:2181):ClientCnxn$SendThread@966] - Opening socket connection to server ec2-54-213-208-202.us-west-2.compute.amazonaws.com/54.213.208.202:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
[zk: ec2-54-213-208-202.us-west-2.compute.amazonaws.com:2181(CONNECTING) 0] 2013-08-31 06:53:35,756 [myid:] - INFO  [main-SendThread(ec2-54-213-208-202.us-west-2.compute.amazonaws.com:2181):ClientCnxn$SendThread@1083] - Client session timed out, have not heard from server in 30097ms for sessionid 0x0, closing socket connection and attempting reconnect
2013-08-31 06:53:36,860 [myid:] - INFO  [main-SendThread(ec2-54-213-208-202.us-west-2.compute.amazonaws.com:2181):ClientCnxn$SendThread@966] - Opening socket connection to server ec2-54-213-208-202.us-west-2.compute.amazonaws.com/54.213.208.202:2181. Will not attempt to authenticate using SASL (unknown error)
仅供参考,我已将端口2181、2888和3888添加到所有计算机的防火墙中。我甚至在所有机器上都禁用了防火墙,它仍然不工作。但在我的本地应用程序中,使用相同的配置方法从来没有任何问题。 请帮帮我
非常感谢。

问题可能与AWS间隔与外部地址有关。每个EC2实例都有一个从AWS内部使用的地址(专用地址)和一个在AWS外部使用的地址。您的配置文件显示server2使用ec2-54-213-208-202.us-west-2.compute.amazonaws.com,这绝对是一个外部地址。如果您的所有服务器和AWS中的所有服务器都使用专用地址。

AWS公用主机名从同一区域内解析为其专用IP。这始终是首选的方式,因为显式使用公共IP的速度较慢,流量将被计费。您找到解决方法了吗?
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/home/yjiang/zookeeper/data/zk1
# the port at which the clients will connect
clientPort=2181
server.1=localhost:2888:3888
server.2=ec2-54-213-208-202.us-west-2.compute.amazonaws.com:2888:3888
#server.3=ec2-54-213-208-225.us-west-2.compute.amazonaws.com:2888:3888
#server.4=ip-172-31-15-66.us-west-2.compute.internal:3888
#server.5=ip-172-31-26-18.us-west-2.compute.internal:3888
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1