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