简体   繁体   English

从本地机器将 Python 连接到 AWS EC2 上的 kafka

[英]Connect Python to kafka on AWS EC2 from local machine

I am trying to connect my python application to kafka running on AWS EC2.我正在尝试将我的 python 应用程序连接到在 AWS EC2 上运行的 kafka。 I am able to connect with ec2 via terminal i check with telnet <ec2 ip> 9092 .我可以通过终端连接 ec2 我用telnet <ec2 ip> 9092 I am able to connect via this but not able to connect with python application.我可以通过这个连接,但无法与 python 应用程序连接。 Even if my python application starts with without any error with ec2 ip address, i am not able to receive any data from my kafka topic from ec2 to local machine.即使我的 python 应用程序启动时 ec2 ip 地址没有任何错误,我也无法从我的 kafka 主题从 ec2 到本地机器接收任何数据。

When i add my pulic ip address to:当我将我的公共 IP 地址添加到:

advertised.listeners=PLAINTEXT://<local ip addrss>:9092 

Debezium connector with kafka-connect won't start , but without enabling advertised.listeners it works.带有 kafka-connect 的 Debezium 连接器将无法启动,但如果不启用 Adverted.listeners 则它可以工作。

How do i configure kafka and kafka-connect so that i can consume kafka topic from ec2 instance on my local machine?我如何配置 kafka 和 kafka-connect 以便我可以从本地机器上的 ec2 实例使用 kafka 主题?

You need to set advertised.listeners to be the EC2 Public DNS/IP, restart the broker, then open the VPC / firewall connection on the listening port.你需要设置advertised.listeners是EC2公共DNS / IP,重新启动代理程序,然后打开监听端口上的VPC /防火墙的连接。

Debezium's rest.advertised.listener property is different from Kafka broker's, and you woudn't need it set on your local machine. Debezium 的rest.advertised.listener属性与 Kafka broker 的不同,您不需要在本地机器上设置它。

Python and Kafka Connect should share the same bootstrap.server protocol Python 和 Kafka Connect 应该共享相同的bootstrap.server协议

You can test your listeners better using kafkacat -L -b <bootstrap>:9092您可以使用kafkacat -L -b <bootstrap>:9092更好地测试您的听众

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM