简体   繁体   English

Kafka和Docker:将Kafka消息推送到另一个Dockerized Consumer

[英]Kafka and Docker: Pushing a Kafka Messages to the another's Dockerized Consumer

Scenario: I need to push, from my Dockerized Kafka container, a message to the physical machines of my teammates. 场景:我需要从我的Dockerized Kafka容器中向我的队友的物理机器发送一条消息。

One teammate (we'll call him Alfred), has his kafka directly installed on Windows. 一个队友(我们称他为阿尔弗雷德),他的kafka直接安装在Windows上。

The other (we'll call him Bob), is also using a Dockerized Kafka container. 另一个(我们称之为Bob)也在使用Dockerized Kafka容器。

Results Thus Far: 结果因此远:

We've been able to push a kafka-produced message from my kafka contain into the consumer of a NON-DOCKERIZED consumer instance of Al's computer. 我们已经能够将来自我的kafka包含的kafka制作的消息推送到Al的计算机的非DOCKERIZED消费者实例的消费者中。 ?So we know that no further configuration; ?所以我们知道没有进一步的配置; producer-side; 生产者侧; is required. 是必须的。 ?Accessing the dockerized kafka of Rob Reris is proving trickier. ?访问Rob Reris的dockerized kafka证明更为棘手。 ?Upon utilizing the command docker network inspect bridge we note that dockerized containers are encapsulated from the general IPv4 address of the company's network. ?在使用命令docker docker network inspect bridge我们注意到dockerized容器是从公司网络的一般IPv4地址封装的。

在此输入图像描述

We identified and attempted to test a number of potential issues. 我们确定并尝试测试了许多潜在问题。

?1. ?1。 Port Forwarding Rules of the receiver's VM. 端口转发接收者VM的规则。 Adjustments to the Port Forwarding Rules have been attempted. 已尝试调整端口转发规则。 No solution. 没有解决方案。 2. Reconfiguring the server.properties located under opt/kafka_2.11-0.9.0.0/config/ on the reciever's folder. 2.重新配置位于接收者文件夹下的opt / kafka_2.11-0.9.0.0 / config /下的server.properties No solution 3. Reconfiguring the server.properties located under the kafka container /etc/kafka/ No solution 4. Add an extra Line to the docker-compose.yml file of the kafka operational build we are utilizing, and rebuild kafka Bob's container. 无解决方案3.重新配置位于kafka容器/ etc / kafka / No解决方案下的server.properties 4.将额外的Line添加到我们正在使用的kafka操作构建的docker-compose.yml文件中,并重建kafka Bob的容器。 Line Added: KAFKA_LISTENERS: "PLAINTEXT://0.0.0.0-9092" 已添加的行: KAFKA_LISTENERS: "PLAINTEXT://0.0.0.0-9092"

Thus far we are still not receiving when I send a test message to Bob's internal network IP. 到目前为止,当我向Bob的内部网络IP发送测试消息时,我们仍然没有收到。

My test message: 我的测试信息:

/bin/kafka-console-producer.sh --broker-list {Bob's IPv4}:9092 --topic test

Could it be that I actually need to target his Dockerized IP...somehow? 可能是因为我真的需要针对他的Dockerized IP ...不知何故? Though I'm certain we already have that covered with the Site-to-Site Port Forwarding of VituralBox. 虽然我确信我们已经拥有了VituralBox的站点到站点端口转发。

Assistance appreciated. 援助表示感谢

The problem you may be facing is the well known issue related to Kafka advertising a private IP to Zookeeper that is not reachable by clients. 您可能遇到的问题是与Kafka广告客户端无法访问的Zookeeper私有IP相关的众所周知的问题。

When you dockerize Kafka you have two broad options: 当您对卡夫卡进行码头化时,您有两个广泛的选择:

  • Launch Kafka containers using network mode = host so Kafka use host network stack. 使用network mode = host启动Kafka容器,以便Kafka使用主机网络堆栈。
  • Use container port forwarding and make Kafka advertise the host IP and port being used setting Kafka config "advertised.listeners" to the right value. 使用容器端口转发并使Kafka公布正在使用的主机IP和端口,将Kafka config“advertised.listeners”设置为正确的值。 In order to do this automatically you may need to create a bootstrap script that finds out the host IP (and port) and set Kafka properties file before running the service. 为了自动执行此操作,您可能需要创建一个引导脚本,找出主机IP(和端口)并在运行服务之前设置Kafka属性文件。 Take a look at wurstmeister/kafka-docker . 看看wurstmeister / kafka-docker

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

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