无法使用公共IP访问安装在Azure VM上的kafka(confluent)

时间:2019-03-25 17:31:04

标签: apache-kafka

我已在Azure VM上安装了confluent-oss-5.0.0,并公开了所有必需的端口以使用公共IP地址进行访问。

我尝试更改下面的 etc / kafka / server.properties 来实现但​​没有运气

Approach - 1

listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://<publicIP>:9092

--------------------------------------            
Approach - 2

advertised.listeners=PLAINTEXT://<publicIP>:9092

--------------------------------------            
Approach - 3

listeners=PLAINTEXT://<publicIP>:9092

我遇到了以下错误

pj@pj-HP-EliteBook-840-G1:~/confluent-kafka/confluent-oss-5.0.0/bin$ kafka-console-producer --broker-list <publicIp>:9092 --topic pj_test123>dfsds
[2019-03-25 19:13:38,784] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)


pj@pj-HP-EliteBook-840-G1:~/confluent-kafka/confluent-oss-5.0.0/bin$ kafka-console-producer --broker-list <publicIp>:9092 --topic pj_test123
>message1
>message2
>[2019-03-25 19:20:13,216] ERROR Error when sending message to topic pj_test123 with key: null, value: 3 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Expiring 2 record(s) for pj_test123-0: 1503 ms has passed since batch creation plus linger time
[2019-03-25 19:20:13,218] ERROR Error when sending message to topic pj_test123 with key: null, value: 3 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)




pj@pj-HP-EliteBook-840-G1:~/confluent-kafka/confluent-oss-5.0.0/bin$ kafka-console-consumer --bootstrap-server <publicIp>:9092 --topic pj_test123 --from-beginning
[2019-03-25 19:29:27,742] WARN [Consumer clientId=consumer-1, groupId=console-consumer-42352] Error while fetching metadata with correlation id 2 : {pj_test123=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)

pj@pj-HP-EliteBook-840-G1:~/confluent-kafka/confluent-oss-5.0.0/bin$ kafka-console-consumer --bootstrap-server <publicIp>:9092 --topic pj_test123 --from-beginning
[2019-03-25 19:27:06,589] WARN [Consumer clientId=consumer-1, groupId=console-consumer-33252] Connection to node 0 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

使用

,其他所有服务(如zookeeper,kafka-connect和restAPI)都可以正常工作
kafka-topics --zookeeper 13.71.115.20:2181 --list  --- This is working

参考: Not able to access messages from confluent kafka on EC2

https://kafka.apache.org/documentation/#brokerconfigs

Why I cannot connect to Kafka from outside?

解决方案

谢谢@Robin Moffatt,它对我有用。我在下面进行了更改,并允许Azure网络上的所有与Kafka相关的端口

kafka@kafka:~/confluent-oss-5.0.0$ sudo vi etc/kafka/server.properties 

listeners=INTERNAL://0.0.0.0:9092,EXTERNAL://0.0.0.0:19092
listener.security.protocol.map=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
advertised.listeners=INTERNAL://<privateIp>:9092,EXTERNAL://<publicIp>:19092
inter.broker.listener.name=INTERNAL

1 个答案:

答案 0 :(得分:1)

您需要为代理配置内部和外部侦听器。本文详细介绍了如何:https://rmoff.net/2018/08/02/kafka-listeners-explained/