kafka的消费者无法启动

cyvaqqii  于 2021-06-02  发布在  Hadoop
关注(0)|答案(2)|浏览(455)

我键入命令行如下。但它显示它无法连接到localhost:2181. 我已经开始做Zookeeper了。
bin/kafka-console-consumer.sh--缩放器--localhost:2181 --topic 痛苦——从一开始

Exception in thread "main" org.I0Itec.zkclient.exception.ZkException: Unable to connect to --localhost:2181
at org.I0Itec.zkclient.ZkConnection.connect(ZkConnection.java:66)
    at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:876)
    at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:98)
    at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:84)
    at kafka.consumer.ZookeeperConsumerConnector.connectZk(ZookeeperConsumerConnector.scala:171)
    at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:126)
at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:143)
at kafka.consumer.Consumer$.create(ConsumerConnector.scala:94)
at kafka.tools.ConsoleConsumer$.main(ConsoleConsumer.scala:145)
at kafka.tools.ConsoleConsumer.main(ConsoleConsumer.scala)
Caused by: java.net.UnknownHostException: --localhost
at java.net.InetAddress.getAllByName0(InetAddress.java:1252)
at java.net.InetAddress.getAllByName(InetAddress.java:1164)
at java.net.InetAddress.getAllByName(InetAddress.java:1098)
at org.apache.zookeeper.client.StaticHostProvider.init(StaticHostProvider.java:61)
at org.apache.zookeeper.ZooKeeper.<init>(ZooKeeper.java:445)
at org.apache.zookeeper.ZooKeeper.<init>(ZooKeeper.java:380)
at org.I0Itec.zkclient.ZkConnection.connect(ZkConnection.java:64)
... 9 more

[root@crxy2 kafka_2.10-0.8.2.0]# jps
5487 QuorumPeerMain
5862 Jps
5518 Kafka

[root@crxy2 kafka_2.10-0.8.2.0]# bin/kafka-topics.sh --zookeeper localhost:2181 --list
pain
oo7oh9g9

oo7oh9g91#

应该是的 bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic pain --from-beginning 注意 --zookeeper localhost:2181 而不是 --zookeeper --localhost:2181

ddhy6vgd

ddhy6vgd2#

尝试以下命令:

bin/kafka-console-consumer.sh --bootstrap-server localhost:9093 --topic pain --from beginning

这里我假设您的kafka代理或kafka服务器之一正在localhost:9093上运行
如果没有为参数提供任何一个活动kafka代理的地址——引导服务器

相关问题