Zookeeper -Kafka:ConnectException - 连接被拒绝

时间:2016-03-03 09:34:01

标签: amazon-web-services amazon-ec2 apache-kafka ubuntu-14.04 kafka-python

我正在尝试在 ubuntu EC2 计算机上设置3个Kafka经纪人。但是我在ConnectException开始时获得zookeeper。 <{1}}我的security group内容中的所有端口都已打开。

下面是堆栈跟踪:

ec2

以下是配置:

zookeeper.properties

[2016-03-03 07:37:12,040] ERROR Exception while listening (org.apache.zookeeper.server.quorum.QuorumCnxManager)
java.net.BindException: Cannot assign requested address
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
    at java.net.ServerSocket.bind(ServerSocket.java:376)
    at java.net.ServerSocket.bind(ServerSocket.java:330)
at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java:507)
...
...
...

[2016-03-03 07:23:46,093] WARN Cannot open channel to 2 at election address /52.36.XXX.181:3888 (org.apache.zookeeper.server.quorum.QuorumCnxManager)
    java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:368)
    at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:402)
    at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:840)
    at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:762)

server.properties

dataDir=/tmp/zookeeper
clientPort=2181
maxClientCnxns=0

server.1=52.37.XX.70:2888:3888
server.2=52.36.XXX.181:2888:3888
server.3=52.37.XX.42:2888:3888
initLimit=5
syncLimit=2

我已在实例的 / etc / hosts 中添加了服务器的公共IP。我修改的/ etc / hosts如下:

broker.id=1
port=9092
host.name=52.37.XX.70

num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/tmp/kafka-logs
num.partitions=3
num.recovery.threads.per.data.dir=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
log.cleaner.enable=false

zookeeper.connect=52.37.XX.70:2181,52.36.XXX.181:2181,52.37.XX.42:2181
zookeeper.connection.timeout.ms=6000

127.0.0.1 localhost localhost.localdomain ip-10-131-X-217 127.0.0.1 localhost localhost.localdomain 52.37.XX.70 127.0.0.1 localhost # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts 中的唯一myid条目也会正确输入。

我已按照How to create a MultiNode - MultiBroker Cluster for Kafka on AWS

中提到的所有步骤进行操作

1 个答案:

答案 0 :(得分:4)

问题是因为我使用的是服务器的<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> .positionedAbsolute { position: absolute; left: 0; top: 0; /* Doesn't appear to be required but putting it in for good measure. */ } .positionedRelative { position: relative; top: 300px; left: 320px; } .justifiedBottom { padding: 5px; background-color: rgba(200,200,200,0.5); position: fixed; bottom: 0; left: 0; right: 0; } </style> </head> <body> <div class="positionedAbsolute"> <div class="positionedRelative"> Hello </div> </div> <div class="justifiedBottom">Next Page</div> </body> </html> 。而不是那样,使用Public IP Public DNS个实例修复了问题。