无法从外部计算机连接到kafka

编程入门 行业动态 更新时间:2024-10-08 04:23:21
本文介绍了无法从外部计算机连接到kafka的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我从Apache Kafka开始,当我尝试从外部计算机进行连接时遇到了问题。

I´m starting with Apache Kafka and i´m facing problems when i try to conect from an external machine.

使用此配置时,如果一切正常该应用程序和docker在同一台计算机上运行。

With this configuration bellow, all works fine if the application and the docker are running at the same machine.

但是当我将应用程序放入计算机A并将docker置于计算机B时,应用程序无法连接。

but when i put the application in machine A and docker at machine B, the application cant connect.

我的春季Kafka @Configuration对@Bean ConsumerFactory和producerFactory有这条线(想象我的机器的docker ip = 10.10.10.10)

My spring Kafka @Configuration have this line to @Bean consumerFactory and producerFactory (imagine my machine with docker ip = 10.10.10.10)

props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "10.10.10.10:9092");

我的docker文件是这样的:

And my docker file is this:

version: '2' services: zookeeper: image: wurstmeister/zookeeper:3.4.6 ports: - 2181:2181 kafka: image: wurstmeister/kafka:0.10.1.1 environment: KAFKA_ADVERTISED_HOST_NAME: 0.0.0.0 KAFKA_ADVERTISED_PORT: 9092 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_CREATE_TOPICS: "topic-jhipster:1:1,PROCESS_ORDER:1:1, PROCESS_CHANNEL:1:1" JMX_PORT: 9999 KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.rmi.port=9999" ports: - 9092:9092 - 9999:9999 kafka-manager: image: sheepkiller/kafka-manager ports: - 9000:9000 links: - zookeeper environment: ZK_HOSTS: zookeeper:2181

我得到此错误:

org.springframework.kafka.core.KafkaProducerException: Failed to send; nested exception is org.apache.kafkamon.errors.TimeoutException: Expiring 1 record(s) for

$ b的1条记录已过期 $ b

编辑,添加一些信息。

Edit, add some information..

我认为它与zookeeper有关的任何配置都缺少了,因为我只有动物园管理员从我的机器A ..和机器B ..的kafka开始工作。.我只不知道如何:(

I think its any configuration about the zookeeper i´m missing .. because if i have only the zookeeper started at my machine A .. and the kafka in machine B.. that works.. i only don´t know how :(

推荐答案

@Krishas和@Hans Jespersen的一些组合

Some mix of @Krishas and @Hans Jespersen

这是我的码头工人yml的代码:

Here is the code of my docker yml:

version: '2' services: zookeeper: image: wurstmeister/zookeeper:3.4.6 ports: - 2181:2181 kafka: image: wurstmeister/kafka:0.10.1.1 environment: KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://10.10.10.10:9092 KAFKA_ADVERTISED_HOST_NAME: 10.10.10.10 KAFKA_ADVERTISED_PORT: 9092 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181

这需要 PLAINTEXT://前缀! 并配置主机名 +端口或监听器

That needs the "PLAINTEXT:// prefix ! And config the "host_name" + "port", or "listeners"

下一步是发现如何配置其他节点

更多推荐

无法从外部计算机连接到kafka

本文发布于:2023-10-16 14:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1497784.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   计算机   kafka

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!