kafka listeners和advertised配置


https://www.cnblogs.com/xuliang666/p/11871389.html

在 config/server.properties 中 配置项

listeners
listeners就是主要用来定义Kafka Broker的Listener的配置项,用于本机监听。

advertised.listeners
advertised.listeners参数的作用就是将Broker的Listener信息发布到Zookeeper供客户端使用监听,是真正的对外代理地址。如果没有设置,会用listeners。
外部连接访问这个,需要设置这个值,
如 java/spring 代码连接kafka ,如果不设置advertised.listeners,就连接不上 报错:
Connection to node 1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.

# The address the socket server listens on. It will get the value returned from 
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092

#listeners=PLAINTEXT://:9092

# Hostname and port the broker will advertise to producers and consumers. If not set, 
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
#advertised.listeners=PLAINTEXT://your.host.name:9092

advertised.listeners=PLAINTEXT://192.168.20.10:9092   # 配置了本机ip


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM