本文介绍了配置kafka监听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有关于正确配置kafka侦听器属性的问题-听众和做广告的听众.

I have this question regarding configuring kafka listeners properties correctly -listeners and advertised.listeners.

在我的配置中,我正在设置以下道具:

In my config I am setting below props:

listeners=SASL_PLAINTEXT://:9092

advertised.listeners=SASL_PLAINTEXT://u-kafkatst-kafkadev-5.sd.xxx.com:9092

客户端使用 u-kafkatst-kafkadev-5.sd.xxx.com:9092 连接.我是否需要在listener和advertised.listeners中具有相同的值.这里的 u-kafkatst-kafkadev-5.sd.xxx.com 是指向kafka代理运行所在主机的dns记录.

The clients connect using u-kafkatst-kafkadev-5.sd.xxx.com:9092. Do I need to have the same value in listener and advertised.listeners. Here u-kafkatst-kafkadev-5.sd.xxx.com is a dns record that points to the host where kafka broker is running.

在什么情况下我想让它们保持相同和不同?

What are the situations where I would want to keep them same and different?

谢谢!

推荐答案

如果要执行除直接连接到同一网络上的代理之外的其他任何操作,则 advertised.listeners 属性非常重要.如果您使用的是Docker,Kubernetes,IaaS(AWS,GCP等),则需要公开外部地址,以使客户端知道要连接到的位置.

The advertised.listeners property is important if you are doing anything other than connecting to a broker directly on the same network. If you are using Docker, Kubernetes, IaaS (AWS, GCP, etc) then you need to expose the external address for the client to know where to connect to.

本文对此进行了深入的解释.

This article explains it all in depth.

这篇关于配置kafka监听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 19:20