libkafka 由於目標計算機積極拒絕,無法連接

在配置kafka服務器後,使用libkafka去連接遠程(i.e. not localhost)的broker,總是失敗,報錯如下

rdkafka_example -P -b 192.168.150.229:9092,192.168.150.229:9093 -t test
% Created producer rdkafka#producer-1
LOG-3-FAIL: 192.168.150.229:9092/bootstrap: Connect to ipv4#192.168.150.229:9092
 failed: 由於目標計算機積極拒絕,無法連接。


原因如下:

你的config/server.properties需要明確寫出listeners的ip地址,而不能用localhost或者127.0.0.1代替

listeners=PLAINTEXT://192.168.150.229:9092


# The port the socket server listens on
#port=9092


# Hostname the broker will bind to. If not set, the server will bind to all interfaces
#host.name=localhost

你要麼設置listteners要麼設置port、host.name,二選一。

如果你只是本機使用,沒有準備讓其他機器的客戶端連接過來,你可以用localhost或者127.0.0.1代替

如果你在搭建集羣,一定要設置listteners或host.name爲明確的ip

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章