简体   繁体   English

Kafka Producer中的经纪人列表参数错误

[英]Error in broker list argument in Kafka Producer

I started a docker container from Wurstmeister Kafka with the command: 我使用以下命令从Wurstmeister Kafka启动了一个Docker容器:

docker run -ti --name sender --entrypoint /bin/bash wurstmeister/kafka:latest

Then i use the command: 然后我使用命令:

docker exec -ti <container_id> bash

to go inside the container.Once in bash, i try to set up a Kafka producer to send messages. 进入容器中。一旦进行了bash操作,我尝试设置一个Kafka生产者来发送消息。 The Kafka server resides in a vm in the cloud with public address 192.168.25.21. Kafka服务器位于公共地址为192.168.25.21的云中的虚拟机中。 When i run the command inside the container: 当我在容器内运行命令时:

/opt/kafka/bin/kafka-console-producer.sh --broker-list 192.168.25.21:9092 --topic test

i get the error in the broker-list argument.The broker-list argument wants a string as an argument and it recognises the 192.168.25.21 as number. 我在broker-list参数中得到错误.broker-list参数想要一个字符串作为参数,并且将192.168.25.21识别为数字。 If i use the dns name of another server it works fine.However i want to be able to use the ip as described previously.Any suggestions? 如果我使用其他服务器的dns名称,则可以正常工作,但是我希望能够如前所述使用ip。任何建议?

So, --entrypoint /bin/bash should put you in a terminal already, no reason to exec -ti again. 因此, --entrypoint /bin/bash应该已经将您放置在终端中,没有理由再次exec -ti

In any case, IPs should work fine, in my experience, but you're welcome to quote it --broker-list '192.168.25.21:9092' . 根据我的经验,无论如何,IP都可以正常工作,但是欢迎您引用--broker-list '192.168.25.21:9092' However, I generally use an exported environment variable of a string for at least three broker addresses, then use that from any CLI tool rather than repeatedly copy and pasting an IP or host 但是,我通常使用至少三个代理地址使用字符串的导出环境变量,然后从任何CLI工具中使用该变量,而不是重复复制和粘贴IP或主机

BTW, not really seeing the need for Docker here. 顺便说一句,在这里并没有真正看到需要Docker。 If you can't/won't install Java or the Kafka downloads themselves, kafkacat is a good alternative 如果您不能/不会安装Java或Kafka自己下载, kafkacat是一个不错的选择

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

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