阿里云部署kafka

kafka下载地址 http://mirrors.hust.edu.cn/apache/kafka/1.1.1/kafka_2.11-1.1.1.tgz

1.解压

tar -xzvf kafka_2.11-1.1.1.tgz 

2.配置config/server.properties

host.name=阿里云内网地址
advertised.host.name=阿里云外网地址
advertised.port=9092
zookeeper.connect=localhost:2181

3.配置完毕,启动kafka

 bin/kafka-server-start.sh -daemon config/server.properties &

4.本地启动producer,consumer验证

打开producer

bin/kafka-console-producer.sh --broker-list 阿里云内网地址:9092 --topic test 

打开consumer

bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test

producer输入什么,consumer应该能输出什么。本地kafka配置完毕。然后,

问题来了

本地远程连接阿里云kafka,producer一直报连接超时,Failed to update metadata after 60000 ms.

查看日志出现异常:

[2018-08-06 11:16:15,971] WARN [RequestSendThread controllerId=0] Controller 0's connection to broker 47.98.141.146:9092 (id: 0 rack: null) was unsuccessful (kafka.controller.RequestSendThread)
java.net.SocketTimeoutException: Failed to connect within 30000 ms
        at kafka.controller.RequestSendThread.brokerReady(ControllerChannelManager.scala:272)
        at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:225)
        at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:82)
[2018-08-06 11:16:46,084] WARN [RequestSendThread controllerId=0] Controller 0's connection to broker 47.98.141.146:9092 (id: 0 rack: null) was unsuccessful (kafka.controller.RequestSendThread)
java.net.SocketTimeoutException: Failed to connect within 30000 ms
        at kafka.controller.RequestSendThread.brokerReady(ControllerChannelManager.scala:272)
        at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:225)
        at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:82)
[2018-08-06 11:17:16,198] WARN [RequestSendThread controllerId=0] Controller 0's connection to broker 47.98.141.146:9092 (id: 0 rack: null) was unsuccessful (kafka.controller.RequestSendThread)
java.net.SocketTimeoutException: Failed to connect within 30000 ms
        at kafka.controller.RequestSendThread.brokerReady(ControllerChannelManager.scala:272)
        at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:225)
        at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:82)
[2018-08-06 11:17:46,315] WARN [RequestSendThread controllerId=0] Controller 0's connection to broker 47.98.141.146:9092 (id: 0 rack: null) was unsuccessful (kafka.controller.RequestSendThread)
java.net.SocketTimeoutException: Failed to connect within 30000 ms
        at kafka.controller.RequestSendThread.brokerReady(ControllerChannelManager.scala:272)
        at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:225)
        at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:82)

telnet 阿里云内网IP 9092  成功!

telent 阿里云外网IP 9092 失败!

telnet 阿里云外网IP 2181 失败!

telnet 阿里云外网IP 22  成功!

卧槽。

阿里云机器无法telnet自己的外网IP,除了端口22,太坑了。感觉像是有什么ip限制,果断查看控制台,规则组配置。

果然,默认本地开放22端口,如需访问自己外网ip,需额外添加相关规则。

直接本地放行全部端口:

问题解决!!!

 

你可能感兴趣的:(阿里云实践,消息队列)