[英]My kafka consumer client doesn't work on my mac, why?
嗨:我是kafka的新手,我按照以下步驟在Mac上安裝和初始化kafka:
brew install kafka
我可以看到配置文件是:
/usr/local/etc/kafka/server.properties
/usr/local/etc/kafka/zookeeper.properties
開始kafka
kafka-server-start /usr/local/etc/kafka/server.properties &
創建一個名為“測試”的主題
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
我可以列出它:
kafka-topics --list --zookeeper localhost:2181
在一個終端中啟動生產者並輸入一些文本:
kafka-console-producer.sh --broker-list localhost:9092 --topic test
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/x/Documents/zk/server1/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/Cellar/kafka/2.0.0/libexec/libs/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
>1st line
>
開始消費
kafka-console-consumer --bootstrap-server localhost:9092 --topic test --from-beginning
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/x/Documents/zk/server1/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/Cellar/kafka/2.0.0/libexec/libs/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
那么,無論我在生產者終端中輸入什么,消費者都不會打印任何內容。 如何解決此問題,我錯過了什么嗎?
從以下位置下載apache Kafka: https ://www.apache.org/dyn/closer.cgi?path =/ kafka/2.0.0/ kafka_2.11-2.0.0.tgz
在任何位置解壓縮並在所有終端中執行以下命令,以便可以執行以下命令,否則您可以替換命令中的安裝路徑並執行。
export kafka=<location-of-unzipped-directory>
$kafka/bin/zookeeper-server-start.sh $kafka/config/zookeeper.properties
執行來運行$kafka/bin/zookeeper-server-start.sh $kafka/config/zookeeper.properties
$kafka/bin/kafka-server-start.sh $kafka/config/server.properties
$kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
$kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
除了記住命令,您可以在.bashrc或.zshrc中添加以下命令
export kafka="/Users/mac-user/standalone/kafka_2.11-2.0.0"
alias startkafka="$kafka/bin/kafka-server-start.sh $kafka/config/server.properties"
alias startzoo="$kafka/bin/zookeeper-server-start.sh $kafka/config/zookeeper.properties"
alias stopkafka="$kafka/bin/kafka-server-stop.sh"
alias stopzoo="$kafka/bin/zookeeper-server-stop.sh"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.