[英]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.