【问题标题】:Not able to access kafka(confluent) installed on Azure VM using public IP无法使用公共 IP 访问安装在 Azure VM 上的 kafka(confluent)
【发布时间】:2021-11-30 15:58:21
【问题描述】:

我已经在 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

【问题讨论】:

    标签: apache-kafka


    【解决方案1】:

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

    【讨论】:

    • 它适用于我``` 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://:9092,EXTERNAL://:19092 inter.broker .listener.name=内部 ```
    • 首先我将内部端口保留为 19092 并更改了其他几个地方(etc/kafka/connect-distributed.properties、connect-standalone.properties、kafka-rest.properties、ksql-server.properties .. .) 使用端口 19092。但它不起作用,并且出现了新的其他问题(如 kafka-connect、shcema-registry 未启动)。 debezium mysql连接器也不起作用。这有什么线索吗?
    【解决方案2】:

    您还必须公开访问端口 9092(您的代理)。为此,

    1. 在 Azure 门户中转到您的虚拟机
    2. 在左侧菜单的设置下选择网络
    3. 添加入站端口规则
    4. 添加端口 9092 可从任何地方访问

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-27
      • 2015-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多